Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
788c45bd77 | ||
|
|
a667d5412c | ||
|
|
8db24fbd1d | ||
|
|
57dc545fad | ||
|
|
bd9d3e1df3 | ||
|
|
cc3e84dfbf | ||
|
|
0bf42c8088 | ||
|
|
41185bd56b | ||
|
|
55b0389911 | ||
|
|
243da80fc6 | ||
|
|
48511c545d | ||
|
|
0922adc0b1 | ||
|
|
5880dc8fe1 |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
* ident=true
|
||||||
23
.gitignore
vendored
Normal file
23
.gitignore
vendored
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
# Ignore all generated files
|
||||||
|
*.o
|
||||||
|
*.ko
|
||||||
|
*.cmd
|
||||||
|
*.a
|
||||||
|
*.d
|
||||||
|
*.mod
|
||||||
|
*.mod.c
|
||||||
|
*.order
|
||||||
|
*.so*
|
||||||
|
*~
|
||||||
|
|
||||||
|
# Generated demo executables
|
||||||
|
examples/console-read
|
||||||
|
examples/drums
|
||||||
|
examples/drums2
|
||||||
|
examples/drums3
|
||||||
|
examples/echo
|
||||||
|
examples/helloworld
|
||||||
|
examples/ioctl
|
||||||
|
examples/logring
|
||||||
|
examples/pager
|
||||||
|
examples/uid-filter
|
||||||
11
Makefile
11
Makefile
@@ -6,10 +6,10 @@ PREFIX = /usr/local
|
|||||||
LIBDIR = $(PREFIX)/lib
|
LIBDIR = $(PREFIX)/lib
|
||||||
INCDIR = $(PREFIX)/include
|
INCDIR = $(PREFIX)/include
|
||||||
|
|
||||||
CC = gcc
|
CC = $(CROSS_COMPILE)gcc
|
||||||
LD = gcc
|
LD = $(CROSS_COMPILE)gcc
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
STRIP = strip
|
STRIP = $(CROSS_COMPILE)strip
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
BINDIR = $(PREFIX)/bin
|
BINDIR = $(PREFIX)/bin
|
||||||
ETCDIR = /etc/$(TARGET)
|
ETCDIR = /etc/$(TARGET)
|
||||||
@@ -23,16 +23,19 @@ export
|
|||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
|
|
||||||
SUBDIRS = kfusd libfusd
|
SUBDIRS = kfusd libfusd examples
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$(MAKE) -C libfusd
|
$(MAKE) -C libfusd
|
||||||
$(MAKE) -C kfusd
|
$(MAKE) -C kfusd
|
||||||
|
$(MAKE) -C examples
|
||||||
|
|
||||||
install:
|
install:
|
||||||
$(MAKE) -C libfusd install
|
$(MAKE) -C libfusd install
|
||||||
$(MAKE) -C kfusd install
|
$(MAKE) -C kfusd install
|
||||||
|
$(MAKE) -C examples install
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(MAKE) -C kfusd clean
|
$(MAKE) -C kfusd clean
|
||||||
$(MAKE) -C libfusd clean
|
$(MAKE) -C libfusd clean
|
||||||
|
$(MAKE) -C examples clean
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
default: docs
|
default: docs
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -f *.[ch].example
|
rm -f *.[ch].example
|
||||||
|
rm -f fusd.dvi
|
||||||
|
|
||||||
examples:
|
docs:
|
||||||
@rm -f *.[ch].example
|
|
||||||
@./make-examples.pl ../examples/*.[ch]
|
|
||||||
|
|
||||||
docs: examples
|
|
||||||
latex fusd
|
latex fusd
|
||||||
latex fusd
|
latex fusd
|
||||||
|
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
#!/usr/bin/perl -w
|
|
||||||
|
|
||||||
|
|
||||||
foreach $path (@ARGV) {
|
|
||||||
$writing = 0;
|
|
||||||
|
|
||||||
if (!open(IN, $path)) {
|
|
||||||
print "trying to open $path: $!\n";
|
|
||||||
next;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ($line = <IN>) {
|
|
||||||
if ($line =~ /EXAMPLE (\w*) ([\w\-\.]*)/) {
|
|
||||||
$command = $1;
|
|
||||||
$filename = $2 . ".example";
|
|
||||||
|
|
||||||
if ($command eq 'START') {
|
|
||||||
if ($writing == 0) {
|
|
||||||
if (!open(OUT, ">>$filename")) {
|
|
||||||
print "trying to write to $filename: $!\n";
|
|
||||||
} else {
|
|
||||||
print "$path: writing to $filename\n";
|
|
||||||
$writing = 1;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
print "$path: got $line while already writing!\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($command eq 'STOP') {
|
|
||||||
if ($writing == 1) {
|
|
||||||
close(OUT);
|
|
||||||
$writing = 0;
|
|
||||||
} else {
|
|
||||||
chomp($line);
|
|
||||||
die "$path line $.: got $line when not writing!\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($writing && $line !~ /SKIPLINE/) {
|
|
||||||
print OUT $line;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($writing) {
|
|
||||||
close(OUT);
|
|
||||||
}
|
|
||||||
close(IN);
|
|
||||||
}
|
|
||||||
|
|
||||||
24
examples/Makefile
Normal file
24
examples/Makefile
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
SRC = console-read.c drums3.c echo.c helloworld.c logring.c pager.c\
|
||||||
|
drums2.c drums.c ioctl.c uid-filter.c
|
||||||
|
OBJ = console-read.o drums3.o echo.o helloworld.o logring.o pager.o\
|
||||||
|
drums2.o drums.o ioctl.o uid-filter.o
|
||||||
|
TARGETS = console-read drums3 echo helloworld logring pager\
|
||||||
|
drums2 drums ioctl uid-filter
|
||||||
|
|
||||||
|
default: $(TARGETS)
|
||||||
|
|
||||||
|
install: $(TARGETS)
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o *.d $(TARGETS) gmon.out *~
|
||||||
|
|
||||||
|
$(TARGETS): %: %.c
|
||||||
|
$(CC) $(GCF) $< -o $@ ../libfusd/libfusd.a
|
||||||
|
|
||||||
|
%.d: %.c
|
||||||
|
$(CC) -M $(CFLAGS) $< > $@.$$$$; sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; rm -f $@.$$$$
|
||||||
|
|
||||||
|
ifeq ($(MAKECMDGOALS),target)
|
||||||
|
include $(SRC:.c=.d)
|
||||||
|
endif
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
* need a template from which to start on a real driver, use pager.c
|
* need a template from which to start on a real driver, use pager.c
|
||||||
* instead.
|
* instead.
|
||||||
*
|
*
|
||||||
* $Id: console-read.c,v 1.4 2003/07/11 22:29:38 cerpa Exp $
|
* $Id: console-read.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -57,7 +57,7 @@ int do_open_or_close(struct fusd_file_info *file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* EXAMPLE START console-read.c */
|
/* EXAMPLE START console-read.c */
|
||||||
int do_read(struct fusd_file_info *file, char *user_buffer,
|
ssize_t do_read(struct fusd_file_info *file, char *user_buffer,
|
||||||
size_t user_length, loff_t *offset)
|
size_t user_length, loff_t *offset)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
@@ -88,7 +88,7 @@ int main(int argc, char *argv[])
|
|||||||
read: do_read,
|
read: do_read,
|
||||||
close: do_open_or_close };
|
close: do_open_or_close };
|
||||||
|
|
||||||
if (fusd_register("/dev/console-read", "misc", "console-read", 0666, NULL, &fops) < 0)
|
if (fusd_register("/dev/console-read", "test", "console-read", 0666, NULL, &fops) < 0)
|
||||||
perror("Unable to register device");
|
perror("Unable to register device");
|
||||||
else {
|
else {
|
||||||
printf("/dev/console-read should now exist - calling fusd_run...\n");
|
printf("/dev/console-read should now exist - calling fusd_run...\n");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
* directory: /dev/drums/bam, /dev/drums/bum, etc. If you cat one of
|
* directory: /dev/drums/bam, /dev/drums/bum, etc. If you cat one of
|
||||||
* these devices, it returns a string that's the same as its name.
|
* these devices, it returns a string that's the same as its name.
|
||||||
*
|
*
|
||||||
* $Id: drums.c,v 1.4 2003/07/11 22:29:38 cerpa Exp $
|
* $Id: drums.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -59,7 +59,7 @@
|
|||||||
static char *drums_strings[] = {"bam", "bum", "beat", "boom",
|
static char *drums_strings[] = {"bam", "bum", "beat", "boom",
|
||||||
"bang", "crash", NULL};
|
"bang", "crash", NULL};
|
||||||
|
|
||||||
int drums_read(struct fusd_file_info *file, char *user_buffer,
|
ssize_t drums_read(struct fusd_file_info *file, char *user_buffer,
|
||||||
size_t user_length, loff_t *offset)
|
size_t user_length, loff_t *offset)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
* to remember if this user has read before; cat /dev/drums/X will
|
* to remember if this user has read before; cat /dev/drums/X will
|
||||||
* read infinitely
|
* read infinitely
|
||||||
*
|
*
|
||||||
* $Id: drums2.c,v 1.6 2003/07/11 22:29:38 cerpa Exp $
|
* $Id: drums2.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -82,14 +82,16 @@ int drums_open(struct fusd_file_info *file)
|
|||||||
/* file->device_info is what we passed to fusd_register when we
|
/* file->device_info is what we passed to fusd_register when we
|
||||||
* registered the device. It's a pointer into the "drums" struct. */
|
* registered the device. It's a pointer into the "drums" struct. */
|
||||||
struct drum_info *d = (struct drum_info *) file->device_info;
|
struct drum_info *d = (struct drum_info *) file->device_info;
|
||||||
|
int *user_num = calloc(1, sizeof(*user_num));
|
||||||
|
|
||||||
/* Store this user's unique user number in their private_data */
|
/* Store this user's unique user number in their private_data */
|
||||||
file->private_data = (void *) ++(d->num_users);
|
*user_num = ++(d->num_users);
|
||||||
|
file->private_data = (void *) user_num;
|
||||||
|
|
||||||
return 0; /* return success */
|
return 0; /* return success */
|
||||||
}
|
}
|
||||||
|
|
||||||
int drums_read(struct fusd_file_info *file, char *user_buffer,
|
ssize_t drums_read(struct fusd_file_info *file, char *user_buffer,
|
||||||
size_t user_length, loff_t *offset)
|
size_t user_length, loff_t *offset)
|
||||||
{
|
{
|
||||||
struct drum_info *d = (struct drum_info *) file->device_info;
|
struct drum_info *d = (struct drum_info *) file->device_info;
|
||||||
@@ -97,10 +99,11 @@ int drums_read(struct fusd_file_info *file, char *user_buffer,
|
|||||||
char sound[128];
|
char sound[128];
|
||||||
|
|
||||||
sprintf(sound, "You are user %d to hear a drum go '%s'!\n",
|
sprintf(sound, "You are user %d to hear a drum go '%s'!\n",
|
||||||
(int) file->private_data, d->name);
|
*(int *) file->private_data, d->name);
|
||||||
|
|
||||||
len = MIN(user_length, strlen(sound));
|
len = MIN(user_length, strlen(sound));
|
||||||
memcpy(user_buffer, sound, len);
|
memcpy(user_buffer, sound, len);
|
||||||
|
*offset += len;
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
/* EXAMPLE STOP */
|
/* EXAMPLE STOP */
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
* However, it also prints a prompt to the console, asking the user if
|
* However, it also prints a prompt to the console, asking the user if
|
||||||
* how loud the drums should be.
|
* how loud the drums should be.
|
||||||
*
|
*
|
||||||
* $Id: drums3.c,v 1.3 2003/07/11 22:29:38 cerpa Exp $
|
* $Id: drums3.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -63,7 +63,7 @@ static char *drums_strings[] = {"bam", "bum", "beat", "boom",
|
|||||||
|
|
||||||
int volume = 2; /* default volume is 2 */
|
int volume = 2; /* default volume is 2 */
|
||||||
|
|
||||||
int drums_read(struct fusd_file_info *file, char *user_buffer,
|
ssize_t drums_read(struct fusd_file_info *file, char *user_buffer,
|
||||||
size_t user_length, loff_t *offset)
|
size_t user_length, loff_t *offset)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
* stored. Then, when you read (e.g. "cat /dev/echo"), you get back
|
* stored. Then, when you read (e.g. "cat /dev/echo"), you get back
|
||||||
* whatever you wrote most recently.
|
* whatever you wrote most recently.
|
||||||
*
|
*
|
||||||
* $Id: echo.c,v 1.6 2003/07/11 22:29:38 cerpa Exp $
|
* $Id: echo.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
char *data = NULL;
|
char *data = NULL;
|
||||||
int data_length = 0;
|
int data_length = 0;
|
||||||
|
|
||||||
int echo_read(struct fusd_file_info *file, char *user_buffer,
|
ssize_t echo_read(struct fusd_file_info *file, char *user_buffer,
|
||||||
size_t user_length, loff_t *offset)
|
size_t user_length, loff_t *offset)
|
||||||
{
|
{
|
||||||
/* if the user has read past the end of the data, return EOF */
|
/* if the user has read past the end of the data, return EOF */
|
||||||
|
|||||||
Binary file not shown.
@@ -37,7 +37,7 @@
|
|||||||
* hello-world: Simply creates a device called /dev/hello-world, which
|
* hello-world: Simply creates a device called /dev/hello-world, which
|
||||||
* greets you when you try to get it.
|
* greets you when you try to get it.
|
||||||
*
|
*
|
||||||
* $Id: helloworld.c,v 1.11 2003/07/11 22:29:38 cerpa Exp $
|
* $Id: helloworld.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* EXAMPLE START helloworld.c */
|
/* EXAMPLE START helloworld.c */
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
* the other examples, anyway), because this program is both an
|
* the other examples, anyway), because this program is both an
|
||||||
* example and part of the regression test suite.
|
* example and part of the regression test suite.
|
||||||
*
|
*
|
||||||
* $Id: ioctl.c,v 1.4 2003/07/11 22:29:39 cerpa Exp $
|
* $Id: ioctl.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -115,8 +115,9 @@ int do_ioctl(struct fusd_file_info *file, int cmd, void *arg)
|
|||||||
|
|
||||||
case IOCTL_TEST1:
|
case IOCTL_TEST1:
|
||||||
case IOCTL_TEST2:
|
case IOCTL_TEST2:
|
||||||
printf("ioctl server: got test1/2, arg=%d, returning it\n", (int) arg);
|
printf("ioctl server: got test1/2, arg=%p, *arg= %d, returning it\n",
|
||||||
return (int) arg;
|
arg, *(int *)arg);
|
||||||
|
return *(int *) arg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* EXAMPLE START ioctl-server.c */
|
/* EXAMPLE START ioctl-server.c */
|
||||||
@@ -185,7 +186,8 @@ int main(int argc, char *argv[])
|
|||||||
/* ioctl server */
|
/* ioctl server */
|
||||||
struct fusd_file_operations f = { open: zeroreturn, close: zeroreturn,
|
struct fusd_file_operations f = { open: zeroreturn, close: zeroreturn,
|
||||||
ioctl: do_ioctl};
|
ioctl: do_ioctl};
|
||||||
if (fusd_register("ioctltest", 0666, NULL, &f) < 0)
|
if (fusd_register("/dev/ioctltest", "misc", "ioctltest",
|
||||||
|
0666, NULL, &f) < 0)
|
||||||
perror("registering ioctltest");
|
perror("registering ioctltest");
|
||||||
printf("server starting\n");
|
printf("server starting\n");
|
||||||
fusd_run();
|
fusd_run();
|
||||||
@@ -216,18 +218,24 @@ int main(int argc, char *argv[])
|
|||||||
CHECK(ret == 0);
|
CHECK(ret == 0);
|
||||||
|
|
||||||
/* test1: issue a command with a simple (integer) argument */
|
/* test1: issue a command with a simple (integer) argument */
|
||||||
ret = ioctl(fd, IOCTL_TEST1, TEST1_NUM);
|
{
|
||||||
CHECK(ret == TEST1_NUM);
|
int arg = TEST1_NUM;
|
||||||
CHECK(errno == 0);
|
ret = ioctl(fd, IOCTL_TEST1, &arg);
|
||||||
printf("ioctl test1: got %d, errno=%d (expecting %d, errno=0)\n\n",
|
CHECK(ret == TEST1_NUM);
|
||||||
ret, errno, TEST1_NUM);
|
CHECK(errno == 0);
|
||||||
|
printf("ioctl test1: got %d, errno=%d (expecting %d, errno=0)\n\n",
|
||||||
|
ret, errno, TEST1_NUM);
|
||||||
|
}
|
||||||
|
|
||||||
/* test2 again: make sure errno is set properly */
|
/* test2 again: make sure errno is set properly */
|
||||||
ret = ioctl(fd, IOCTL_TEST2, -ELIBBAD);
|
{
|
||||||
CHECK(errno == ELIBBAD);
|
int arg = -ELIBBAD;
|
||||||
CHECK(ret == -1);
|
ret = ioctl(fd, IOCTL_TEST2, &arg);
|
||||||
printf("ioctl test2: got %d, errno=%d (expecting -1, errno=%d)\n\n",
|
CHECK(errno == ELIBBAD);
|
||||||
ret, errno, ELIBBAD);
|
CHECK(ret == -1);
|
||||||
|
printf("ioctl test2: got %d, errno=%d (expecting -1, errno=%d)\n\n",
|
||||||
|
ret, errno, ELIBBAD);
|
||||||
|
}
|
||||||
|
|
||||||
printf("ioctl test3: expecting retval 0, string This Is Test3\n");
|
printf("ioctl test3: expecting retval 0, string This Is Test3\n");
|
||||||
/* EXAMPLE START ioctl-client.c */
|
/* EXAMPLE START ioctl-client.c */
|
||||||
|
|||||||
@@ -71,7 +71,7 @@
|
|||||||
* but want to use it on a system that does not have FUSD, check out
|
* but want to use it on a system that does not have FUSD, check out
|
||||||
* emlog at http://www.circlemud.org/~jelson/software/emlog.
|
* emlog at http://www.circlemud.org/~jelson/software/emlog.
|
||||||
*
|
*
|
||||||
* $Id: logring.c,v 1.8 2003/07/11 22:29:39 cerpa Exp $
|
* $Id: logring.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -340,7 +340,7 @@ void logring_complete_polldiff(struct logring_client *c)
|
|||||||
* may come from the kernel before the driver has returned the first
|
* may come from the kernel before the driver has returned the first
|
||||||
* one; if this happens, use fusd_destroy() to get rid of the older one.
|
* one; if this happens, use fusd_destroy() to get rid of the older one.
|
||||||
*/
|
*/
|
||||||
ssize_t logring_polldiff(struct fusd_file_info *file, unsigned int flags)
|
int logring_polldiff(struct fusd_file_info *file, unsigned int flags)
|
||||||
{
|
{
|
||||||
struct logring_client *c = (struct logring_client *) file->private_data;
|
struct logring_client *c = (struct logring_client *) file->private_data;
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
* If you close the FD and then reopen it, there will be a race (pages
|
* If you close the FD and then reopen it, there will be a race (pages
|
||||||
* that arrive between the close and open will not be delivered).
|
* that arrive between the close and open will not be delivered).
|
||||||
*
|
*
|
||||||
* $Id: pager.c,v 1.9 2003/07/11 22:29:39 cerpa Exp $
|
* $Id: pager.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -247,7 +247,7 @@ void pager_notify_complete_read(struct pager_client *c)
|
|||||||
* one; if this happens, use fusd_destroy() to get rid of the older one.
|
* one; if this happens, use fusd_destroy() to get rid of the older one.
|
||||||
*/
|
*/
|
||||||
/* EXAMPLE START pager-polldiff.c */
|
/* EXAMPLE START pager-polldiff.c */
|
||||||
ssize_t pager_notify_polldiff(struct fusd_file_info *file,
|
int pager_notify_polldiff(struct fusd_file_info *file,
|
||||||
unsigned int cached_state)
|
unsigned int cached_state)
|
||||||
{
|
{
|
||||||
struct pager_client *c = (struct pager_client *) file->private_data;
|
struct pager_client *c = (struct pager_client *) file->private_data;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
* not be read by anyone other than the driver owner (not even root!).
|
* not be read by anyone other than the driver owner (not even root!).
|
||||||
* When you read from the device, it returns your PID to you.
|
* When you read from the device, it returns your PID to you.
|
||||||
*
|
*
|
||||||
* $Id: uid-filter.c,v 1.4 2003/07/11 22:29:39 cerpa Exp $
|
* $Id: uid-filter.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -71,7 +71,7 @@ int do_open(struct fusd_file_info *file)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int do_read(struct fusd_file_info *file, char *user_buffer,
|
ssize_t do_read(struct fusd_file_info *file, char *user_buffer,
|
||||||
size_t user_length, loff_t *offset)
|
size_t user_length, loff_t *offset)
|
||||||
{
|
{
|
||||||
char buf[128];
|
char buf[128];
|
||||||
|
|||||||
112
include/kfusd.h
112
include/kfusd.h
@@ -37,28 +37,28 @@
|
|||||||
*
|
*
|
||||||
* Private header file used by the Linux Kernel Module
|
* Private header file used by the Linux Kernel Module
|
||||||
*
|
*
|
||||||
* $Id: kfusd.h,v 1.41 2003/07/11 22:29:39 cerpa Exp $
|
* $Id: kfusd.h 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __KFUSD_H__
|
#ifndef __KFUSD_H__
|
||||||
#define __KFUSD_H__
|
# define __KFUSD_H__
|
||||||
|
|
||||||
#include "fusd_msg.h"
|
# include "fusd_msg.h"
|
||||||
|
|
||||||
/* magic numbers for structure checking; unique w.r.t
|
/* magic numbers for structure checking; unique w.r.t
|
||||||
* /usr/src/linux/Documentation/magic-number.txt */
|
* /usr/src/linux/Documentation/magic-number.txt */
|
||||||
#define FUSD_DEV_MAGIC 0x8b43a123
|
# define FUSD_DEV_MAGIC 0x8b43a123
|
||||||
#define FUSD_FILE_MAGIC 0x613aa8fe
|
# define FUSD_FILE_MAGIC 0x613aa8fe
|
||||||
|
|
||||||
/* number of devices that can be created with fusd */
|
/* number of devices that can be created with fusd */
|
||||||
#define MAX_FUSD_DEVICES 128
|
# define MAX_FUSD_DEVICES 128
|
||||||
|
|
||||||
/* number of times each device can be opened simultaneously */
|
/* number of times each device can be opened simultaneously */
|
||||||
#define MIN_FILEARRAY_SIZE 8 /* initialize allocation */
|
# define MIN_FILEARRAY_SIZE 8 /* initialize allocation */
|
||||||
#define MAX_FILEARRAY_SIZE 1024 /* maximum it can grow to */
|
# define MAX_FILEARRAY_SIZE 1024 /* maximum it can grow to */
|
||||||
|
|
||||||
/* maximum read/write size we're willing to service */
|
/* maximum read/write size we're willing to service */
|
||||||
#define MAX_RW_SIZE (1024*128)
|
# define MAX_RW_SIZE (1024*128)
|
||||||
|
|
||||||
|
|
||||||
/********************** Structure Definitions *******************************/
|
/********************** Structure Definitions *******************************/
|
||||||
@@ -88,7 +88,7 @@ struct fusd_transaction
|
|||||||
struct fusd_dev_t_s;
|
struct fusd_dev_t_s;
|
||||||
typedef struct fusd_dev_t_s fusd_dev_t;
|
typedef struct fusd_dev_t_s fusd_dev_t;
|
||||||
struct CLASS;
|
struct CLASS;
|
||||||
struct class_device;
|
struct device;
|
||||||
|
|
||||||
/* state kept per opened file (i.e., an instance of a device) */
|
/* state kept per opened file (i.e., an instance of a device) */
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -121,16 +121,15 @@ struct fusd_dev_t_s {
|
|||||||
struct task_struct* task;
|
struct task_struct* task;
|
||||||
|
|
||||||
char *name; /* Name of the device under devfs (/dev) */
|
char *name; /* Name of the device under devfs (/dev) */
|
||||||
char *class_name;
|
char *class_name;
|
||||||
char *dev_name;
|
char *dev_name;
|
||||||
struct CLASS *clazz;
|
struct CLASS *clazz;
|
||||||
int owns_class;
|
int owns_class;
|
||||||
struct class_device *class_device;
|
struct device *device;
|
||||||
|
|
||||||
void *private_data; /* User's private data */
|
void *private_data; /* User's private data */
|
||||||
struct cdev* handle;
|
struct cdev* handle;
|
||||||
dev_t dev_id;
|
dev_t dev_id;
|
||||||
// devfs_handle_t handle; /* The devfs-provided handle */
|
|
||||||
|
|
||||||
fusd_file_t **files; /* Array of this device's open files */
|
fusd_file_t **files; /* Array of this device's open files */
|
||||||
int array_size; /* Size of the array pointed to by 'files' */
|
int array_size; /* Size of the array pointed to by 'files' */
|
||||||
@@ -175,34 +174,34 @@ STATIC struct fusd_transaction* fusd_find_transaction_by_pid(fusd_file_t *fusd_f
|
|||||||
|
|
||||||
/**** Utility functions & macros ****/
|
/**** Utility functions & macros ****/
|
||||||
|
|
||||||
#ifdef CONFIG_FUSD_USE_WAKEUPSYNC
|
# ifdef CONFIG_FUSD_USE_WAKEUPSYNC
|
||||||
#define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible_sync(x)
|
# define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible_sync(x)
|
||||||
#else
|
# else
|
||||||
#define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible(x)
|
# define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible(x)
|
||||||
#endif /* CONFIG_FUSD_USE_WAKEUPSYNC */
|
# endif /* CONFIG_FUSD_USE_WAKEUPSYNC */
|
||||||
|
|
||||||
#ifdef CONFIG_FUSD_DEBUG
|
# ifdef CONFIG_FUSD_DEBUG
|
||||||
static void rdebug_real(char *fmt, ...)
|
static void rdebug_real(char *fmt, ...)
|
||||||
__attribute__ ((format (printf, 1, 2)));
|
__attribute__ ((format (printf, 1, 2)));
|
||||||
|
|
||||||
#define RDEBUG(message_level, args...) do { \
|
# define RDEBUG(message_level, args...) do { \
|
||||||
if (fusd_debug_level >= message_level) rdebug_real(args); \
|
if (fusd_debug_level >= message_level) rdebug_real(args); \
|
||||||
} while(0)
|
} while(0)
|
||||||
#else
|
# else
|
||||||
#define RDEBUG(message_level, args...)
|
# define RDEBUG(message_level, args...)
|
||||||
#endif /* CONFIG_FUSD_DEBUG */
|
# endif /* CONFIG_FUSD_DEBUG */
|
||||||
|
|
||||||
|
|
||||||
#define ZOMBIE(fusd_dev) ((fusd_dev)->zombie)
|
# define ZOMBIE(fusd_dev) ((fusd_dev)->zombie)
|
||||||
|
|
||||||
|
|
||||||
#define GET_FUSD_DEV(candidate, fusd_dev) do { \
|
# define GET_FUSD_DEV(candidate, fusd_dev) do { \
|
||||||
fusd_dev = candidate; \
|
fusd_dev = candidate; \
|
||||||
if (fusd_dev == NULL || fusd_dev->magic != FUSD_DEV_MAGIC) \
|
if (fusd_dev == NULL || fusd_dev->magic != FUSD_DEV_MAGIC) \
|
||||||
goto invalid_dev; \
|
goto invalid_dev; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define GET_FUSD_FILE_AND_DEV(candidate, fusd_file, fusd_dev) do { \
|
# define GET_FUSD_FILE_AND_DEV(candidate, fusd_file, fusd_dev) do { \
|
||||||
fusd_file = candidate; \
|
fusd_file = candidate; \
|
||||||
if (fusd_file == NULL || fusd_file->magic != FUSD_FILE_MAGIC) \
|
if (fusd_file == NULL || fusd_file->magic != FUSD_FILE_MAGIC) \
|
||||||
goto invalid_file; \
|
goto invalid_file; \
|
||||||
@@ -211,36 +210,40 @@ static void rdebug_real(char *fmt, ...)
|
|||||||
goto invalid_file; \
|
goto invalid_file; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
# define LOCK_FUSD_DEV(fusd_dev) \
|
||||||
#define LOCK_FUSD_DEV(fusd_dev) \
|
|
||||||
do { down(&fusd_dev->dev_sem); \
|
do { down(&fusd_dev->dev_sem); \
|
||||||
if (ZOMBIE(fusd_dev)) { up(&fusd_dev->dev_sem); goto zombie_dev; } \
|
if (ZOMBIE(fusd_dev)) { up(&fusd_dev->dev_sem); goto zombie_dev; } \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/* rawlock does not do a zombie check */
|
/* rawlock does not do a zombie check */
|
||||||
#define RAWLOCK_FUSD_DEV(fusd_dev) \
|
|
||||||
|
# define RAWLOCK_FUSD_DEV(fusd_dev) \
|
||||||
do { down(&fusd_dev->dev_sem); } while (0)
|
do { down(&fusd_dev->dev_sem); } while (0)
|
||||||
|
|
||||||
#define UNLOCK_FUSD_DEV(fusd_dev) \
|
# define UNLOCK_FUSD_DEV(fusd_dev) \
|
||||||
do { up(&fusd_dev->dev_sem); } while (0)
|
do { up(&fusd_dev->dev_sem); } while (0)
|
||||||
|
|
||||||
|
# define LOCK_FUSD_FILE(fusd_file) \
|
||||||
#define LOCK_FUSD_FILE(fusd_file) \
|
|
||||||
do { down(&fusd_file->file_sem); \
|
do { down(&fusd_file->file_sem); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define UNLOCK_FUSD_FILE(fusd_file) \
|
# define UNLOCK_FUSD_FILE(fusd_file) \
|
||||||
do { up(&fusd_file->file_sem); } while (0)
|
do { up(&fusd_file->file_sem); } while (0)
|
||||||
|
|
||||||
#define FREE_FUSD_MSGC(fusd_msgc) do { \
|
# define FREE_FUSD_MSGC(fusd_msgc) do { \
|
||||||
if ((fusd_msgc)->fusd_msg.data != NULL) VFREE(fusd_msgc->fusd_msg.data); \
|
if ((fusd_msgc)->fusd_msg.data != NULL) VFREE(fusd_msgc->fusd_msg.data); \
|
||||||
KFREE(fusd_msgc); \
|
KFREE(fusd_msgc); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define NAME(fusd_dev) ((fusd_dev)->name == NULL ? \
|
# define FREE_FUSD_MSGC(fusd_msgc) do { \
|
||||||
|
if ((fusd_msgc)->fusd_msg.data != NULL) VFREE(fusd_msgc->fusd_msg.data); \
|
||||||
|
KFREE(fusd_msgc); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define NAME(fusd_dev) ((fusd_dev)->name == NULL ? \
|
||||||
"<noname>" : (fusd_dev)->name)
|
"<noname>" : (fusd_dev)->name)
|
||||||
|
|
||||||
#ifdef CONFIG_FUSD_MEMDEBUG
|
# ifdef CONFIG_FUSD_MEMDEBUG
|
||||||
static int fusd_mem_init(void);
|
static int fusd_mem_init(void);
|
||||||
static void fusd_mem_cleanup(void);
|
static void fusd_mem_cleanup(void);
|
||||||
static void fusd_mem_add(void *ptr, int line, int size);
|
static void fusd_mem_add(void *ptr, int line, int size);
|
||||||
@@ -249,22 +252,22 @@ static void *fusd_kmalloc(size_t size, int type, int line);
|
|||||||
static void fusd_kfree(void *ptr);
|
static void fusd_kfree(void *ptr);
|
||||||
static void *fusd_vmalloc(size_t size, int line);
|
static void *fusd_vmalloc(size_t size, int line);
|
||||||
static void fusd_vfree(void *ptr);
|
static void fusd_vfree(void *ptr);
|
||||||
# define KMALLOC(size, type) fusd_kmalloc(size, type, __LINE__)
|
# define KMALLOC(size, type) fusd_kmalloc(size, type, __LINE__)
|
||||||
# define KFREE(ptr) fusd_kfree(ptr)
|
# define KFREE(ptr) fusd_kfree(ptr)
|
||||||
# define VMALLOC(size) fusd_vmalloc(size, __LINE__)
|
# define VMALLOC(size) fusd_vmalloc(size, __LINE__)
|
||||||
# define VFREE(ptr) fusd_vfree(ptr)
|
# define VFREE(ptr) fusd_vfree(ptr)
|
||||||
#else /* no memory debugging */
|
# else /* no memory debugging */
|
||||||
# define KMALLOC(size, type) kmalloc(size, type)
|
# define KMALLOC(size, type) kmalloc(size, type)
|
||||||
# define KFREE(ptr) kfree(ptr)
|
# define KFREE(ptr) kfree(ptr)
|
||||||
/*# define VMALLOC(size) vmalloc(size)*/
|
/*# define VMALLOC(size) vmalloc(size)*/
|
||||||
# define VMALLOC(size) kmalloc(size, GFP_KERNEL)
|
# define VMALLOC(size) kmalloc(size, GFP_KERNEL)
|
||||||
# define VFREE(ptr) kfree(ptr)
|
# define VFREE(ptr) kfree(ptr)
|
||||||
#endif /* CONFIG_FUSD_MEMDEBUG */
|
# endif /* CONFIG_FUSD_MEMDEBUG */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Functions like this should be in the kernel, but they are not. Sigh. */
|
/* Functions like this should be in the kernel, but they are not. Sigh. */
|
||||||
#ifdef CONFIG_SMP
|
# ifdef CONFIG_SMP
|
||||||
|
|
||||||
DECLARE_MUTEX(atomic_ops);
|
DECLARE_MUTEX(atomic_ops);
|
||||||
|
|
||||||
@@ -277,12 +280,11 @@ static __inline__ int atomic_inc_and_ret(int *i)
|
|||||||
up(&atomic_ops);
|
up(&atomic_ops);
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
#else
|
# else
|
||||||
static __inline__ int atomic_inc_and_ret(int *i)
|
static __inline__ int atomic_inc_and_ret(int *i)
|
||||||
{
|
{
|
||||||
return (++(*i));
|
return (++(*i));
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
|
|
||||||
#endif /* __KFUSD_H__ */
|
#endif /* __KFUSD_H__ */
|
||||||
|
|||||||
@@ -1,16 +1,21 @@
|
|||||||
ifneq ($(KERNELRELEASE),)
|
ifneq ($(KERNELRELEASE),)
|
||||||
obj-m := kfusd.o
|
obj-m := kfusd.o
|
||||||
|
KERNEL_VER ?= $(KERNELRELEASE)
|
||||||
else
|
else
|
||||||
KDIR ?= /lib/modules/$(shell uname -r)/build
|
KDIR ?= /lib/modules/$(shell uname -r)/build
|
||||||
PWD := $(shell pwd)
|
PWD := $(shell pwd)
|
||||||
|
ROOTFS ?=
|
||||||
|
|
||||||
|
KERNEL_VER ?= 2.6.32.7
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS=-I$(PWD)/../include modules
|
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS=-I$(PWD)/../include modules
|
||||||
|
|
||||||
install:
|
install:
|
||||||
$(INSTALL) -d -m 0755 /lib/modules/$(shell uname -r)/kernel/drivers/misc
|
install -d -m 0755 $(ROOTFS)/lib/modules/$(KERNEL_VER)/kernel/drivers/misc
|
||||||
$(INSTALL) -m 0755 kfusd.ko /lib/modules/$(shell uname -r)/kernel/drivers/misc
|
install -m 0755 kfusd.ko $(ROOTFS)/lib/modules/$(KERNEL_VER)/kernel/drivers/misc
|
||||||
/sbin/depmod -a
|
|
||||||
|
# /sbin/depmod -a
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f .kfusd* Modules.symvers \
|
rm -f .kfusd* Modules.symvers \
|
||||||
|
|||||||
4318
kfusd/kfusd.c
4318
kfusd/kfusd.c
File diff suppressed because it is too large
Load Diff
@@ -35,10 +35,10 @@
|
|||||||
*
|
*
|
||||||
* authors: jelson and girod
|
* authors: jelson and girod
|
||||||
*
|
*
|
||||||
* $Id: libfusd.c,v 1.61 2003/07/11 22:29:39 cerpa Exp $
|
* $Id: libfusd.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char libfusd_c_id[] = "$Id: libfusd.c,v 1.61 2003/07/11 22:29:39 cerpa Exp $";
|
char libfusd_c_id[] = "$Id: libfusd.c 12351 2007-01-19 07:22:54Z xiphmont $";
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -328,8 +328,6 @@ void fusd_fdset_add(fd_set *set, int *max)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fusd_dispatch_fdset: given an fd_set full of descriptors, call
|
* fusd_dispatch_fdset: given an fd_set full of descriptors, call
|
||||||
* fusd_dispatch on every descriptor in the set which is a valid FUSD
|
* fusd_dispatch on every descriptor in the set which is a valid FUSD
|
||||||
@@ -410,16 +408,21 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
|||||||
|
|
||||||
/* dispatch on operation type */
|
/* dispatch on operation type */
|
||||||
user_retval = -ENOSYS;
|
user_retval = -ENOSYS;
|
||||||
|
//printf("dispatch_one: subcmd: %d - ", msg->subcmd);
|
||||||
|
|
||||||
switch (msg->subcmd) {
|
switch (msg->subcmd) {
|
||||||
case FUSD_OPEN:
|
case FUSD_OPEN:
|
||||||
|
//printf("FUSD_OPEN\n");
|
||||||
if (fops && fops->open)
|
if (fops && fops->open)
|
||||||
user_retval = fops->open(file);
|
user_retval = fops->open(file);
|
||||||
break;
|
break;
|
||||||
case FUSD_CLOSE:
|
case FUSD_CLOSE:
|
||||||
|
//printf("FUSD_CLOSE\n");
|
||||||
if (fops && fops->close)
|
if (fops && fops->close)
|
||||||
user_retval = fops->close(file);
|
user_retval = fops->close(file);
|
||||||
break;
|
break;
|
||||||
case FUSD_READ:
|
case FUSD_READ:
|
||||||
|
//printf("FUSD_READ\n");
|
||||||
/* allocate a buffer and make the call */
|
/* allocate a buffer and make the call */
|
||||||
if (fops && fops->read) {
|
if (fops && fops->read) {
|
||||||
if ((msg->data = malloc(msg->parm.fops_msg.length)) == NULL) {
|
if ((msg->data = malloc(msg->parm.fops_msg.length)) == NULL) {
|
||||||
@@ -433,11 +436,13 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FUSD_WRITE:
|
case FUSD_WRITE:
|
||||||
|
//printf("FUSD_WRITE\n");
|
||||||
if (fops && fops->write)
|
if (fops && fops->write)
|
||||||
user_retval = fops->write(file, msg->data, msg->datalen,
|
user_retval = fops->write(file, msg->data, msg->datalen,
|
||||||
&msg->parm.fops_msg.offset);
|
&msg->parm.fops_msg.offset);
|
||||||
break;
|
break;
|
||||||
case FUSD_MMAP:
|
case FUSD_MMAP:
|
||||||
|
//printf("FUSD_MMAP\n");
|
||||||
if (fops && fops->mmap)
|
if (fops && fops->mmap)
|
||||||
{
|
{
|
||||||
user_retval = fops->mmap(file, msg->parm.fops_msg.offset, msg->parm.fops_msg.length, msg->parm.fops_msg.flags,
|
user_retval = fops->mmap(file, msg->parm.fops_msg.offset, msg->parm.fops_msg.length, msg->parm.fops_msg.flags,
|
||||||
@@ -445,6 +450,7 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case FUSD_IOCTL:
|
case FUSD_IOCTL:
|
||||||
|
//printf("FUSD_IOCTL\n");
|
||||||
if (fops && fops->ioctl) {
|
if (fops && fops->ioctl) {
|
||||||
/* in the case of an ioctl read, allocate a buffer for the
|
/* in the case of an ioctl read, allocate a buffer for the
|
||||||
* driver to write to, IF there isn't already a buffer. (there
|
* driver to write to, IF there isn't already a buffer. (there
|
||||||
@@ -466,6 +472,7 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FUSD_POLL_DIFF:
|
case FUSD_POLL_DIFF:
|
||||||
|
//printf("FUSD_POLL_DIFF\n");
|
||||||
/* This callback requests notification when an event occurs on a file,
|
/* This callback requests notification when an event occurs on a file,
|
||||||
* e.g. becoming readable or writable */
|
* e.g. becoming readable or writable */
|
||||||
if (fops && fops->poll_diff)
|
if (fops && fops->poll_diff)
|
||||||
@@ -473,6 +480,7 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case FUSD_UNBLOCK:
|
case FUSD_UNBLOCK:
|
||||||
|
//printf("FUSD_UNBLOCK\n");
|
||||||
/* This callback is called when a system call is interrupted */
|
/* This callback is called when a system call is interrupted */
|
||||||
if (fops && fops->unblock)
|
if (fops && fops->unblock)
|
||||||
user_retval = fops->unblock(file);
|
user_retval = fops->unblock(file);
|
||||||
@@ -533,6 +541,7 @@ void fusd_dispatch(int fd)
|
|||||||
if (!FUSD_FD_VALID(fd)) {
|
if (!FUSD_FD_VALID(fd)) {
|
||||||
errno = EBADF;
|
errno = EBADF;
|
||||||
retval = -1;
|
retval = -1;
|
||||||
|
fprintf(stderr, "libfusd: not a valid FUSD FD\n");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
fops = FUSD_GET_FOPS(fd);
|
fops = FUSD_GET_FOPS(fd);
|
||||||
@@ -555,7 +564,7 @@ void fusd_dispatch(int fd)
|
|||||||
|
|
||||||
out:
|
out:
|
||||||
if (retval < 0 && errno != EPIPE)
|
if (retval < 0 && errno != EPIPE)
|
||||||
fprintf(stderr, "libfusd: fusd_dispatch error on fd %d: %m\n", fd);
|
fprintf(stderr, "libfusd: fusd_dispatch error on fd %d: [%d] %m \n", fd, retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -648,11 +657,16 @@ int fusd_return(fusd_file_info_t *file, ssize_t retval)
|
|||||||
|
|
||||||
/* send message to kernel */
|
/* send message to kernel */
|
||||||
if (msg->datalen && msg->data != NULL) {
|
if (msg->datalen && msg->data != NULL) {
|
||||||
|
//printf("(msg->datalen [%d] && msg->data != NULL [%p]", msg->datalen, msg->data);
|
||||||
iov[0].iov_base = msg;
|
iov[0].iov_base = msg;
|
||||||
iov[0].iov_len = sizeof(fusd_msg_t);
|
iov[0].iov_len = sizeof(fusd_msg_t);
|
||||||
iov[1].iov_base = msg->data;
|
iov[1].iov_base = msg->data;
|
||||||
iov[1].iov_len = msg->datalen;
|
iov[1].iov_len = msg->datalen;
|
||||||
|
#if 0
|
||||||
driver_retval = writev(fd, iov, 2);
|
driver_retval = writev(fd, iov, 2);
|
||||||
|
#else
|
||||||
|
driver_retval = ioctl(fd, 0xb16b00b5, iov);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
driver_retval = write(fd, msg, sizeof(fusd_msg_t));
|
driver_retval = write(fd, msg, sizeof(fusd_msg_t));
|
||||||
|
|||||||
149
make.include
149
make.include
@@ -1,149 +0,0 @@
|
|||||||
|
|
||||||
# auto-dependency generation makefile
|
|
||||||
|
|
||||||
|
|
||||||
#### Default values
|
|
||||||
|
|
||||||
SRCEXTENSIONS := c C cpp
|
|
||||||
CC := gcc
|
|
||||||
CPP := g++
|
|
||||||
LD := ld
|
|
||||||
AR := ar
|
|
||||||
|
|
||||||
#### build object directory token
|
|
||||||
|
|
||||||
CPU := $(shell uname -m)
|
|
||||||
OS := $(shell uname -s | tr '[A-Z]' '[a-z]')
|
|
||||||
|
|
||||||
DEFAULT_ARCH := $(CPU)-$(OS)
|
|
||||||
|
|
||||||
ifeq ($(strip $(ARCH)),)
|
|
||||||
ARCH := $(DEFAULT_ARCH)
|
|
||||||
endif
|
|
||||||
|
|
||||||
OBJTOKEN := obj.$(ARCH)
|
|
||||||
|
|
||||||
#
|
|
||||||
# Under most circumstances, paths are simple
|
|
||||||
#
|
|
||||||
|
|
||||||
ifeq ($(POSTROOT),..)
|
|
||||||
MODPATH := .
|
|
||||||
OBJDIR := $(OBJTOKEN)
|
|
||||||
else
|
|
||||||
MODPATH := $(POSTROOT)/$(MODULENAME)
|
|
||||||
OBJDIR := $(MODPATH)/$(OBJTOKEN)
|
|
||||||
endif
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Directories
|
|
||||||
#
|
|
||||||
|
|
||||||
MODLIBS := \
|
|
||||||
-L$(OBJDIR) \
|
|
||||||
$(foreach dir, $(MODULES), -L$(POSTROOT)/$(dir)/$(OBJTOKEN))
|
|
||||||
MODINCLUDES := \
|
|
||||||
-I$(MODPATH)/include \
|
|
||||||
$(foreach dir, $(MODULES), -I$(POSTROOT)/$(dir)/include)
|
|
||||||
ALLTARGETS := \
|
|
||||||
$(foreach targ, $(TARGETS), $(OBJDIR)/$(targ))
|
|
||||||
VPATH := \
|
|
||||||
$(MODPATH)/include \
|
|
||||||
$(foreach dir, $(SRCDIRS), $(MODPATH)/$(dir)) \
|
|
||||||
$(foreach dir, $(MODULES), $(POSTROOT)/$(dir)/include)
|
|
||||||
|
|
||||||
|
|
||||||
#### include paths
|
|
||||||
|
|
||||||
LIBPATH := $(MODLIBS)
|
|
||||||
INCLUDEPATH += -I. -Iinclude $(MODINCLUDES)
|
|
||||||
KCFLAGS = -O2 \
|
|
||||||
-Wall -Werror -Wstrict-prototypes \
|
|
||||||
-fno-strict-aliasing -fomit-frame-pointer \
|
|
||||||
-DMODULE -D__KERNEL__
|
|
||||||
|
|
||||||
CFLAGS := -fPIC -Wall -O2 -g
|
|
||||||
CCFLAGS := -Werror
|
|
||||||
CPPFLAGS := -ftemplate-depth-30
|
|
||||||
|
|
||||||
#### Architecture deps
|
|
||||||
|
|
||||||
KERNEL_INCLUDE := $(KERNEL_HOME)/include
|
|
||||||
BINSTRIP := strip
|
|
||||||
|
|
||||||
KCFLAGS += $(INCLUDEPATH)
|
|
||||||
CFLAGS += $(INCLUDEPATH) $(LIBPATH)
|
|
||||||
|
|
||||||
CCFLAGS += $(CFLAGS)
|
|
||||||
CPPFLAGS += $(CFLAGS)
|
|
||||||
|
|
||||||
#
|
|
||||||
# targets
|
|
||||||
#
|
|
||||||
|
|
||||||
default: $(ALLTARGETS)
|
|
||||||
|
|
||||||
####################################################
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Dependency generation
|
|
||||||
#
|
|
||||||
|
|
||||||
|
|
||||||
# Get list of all source files
|
|
||||||
SOURCES := \
|
|
||||||
$(notdir $(wildcard \
|
|
||||||
$(foreach dir, $(SRCDIRS), \
|
|
||||||
$(foreach ext, $(SRCEXTENSIONS), $(dir)/*.$(ext)))))
|
|
||||||
|
|
||||||
# Convert all .c, .cpp, .C to .d
|
|
||||||
SRC_AND_DEPENDS := $(foreach ext, $(SRCEXTENSIONS),\
|
|
||||||
$(patsubst %.$(ext),%.d,$(SOURCES)))
|
|
||||||
|
|
||||||
DEPENDS := $(foreach file, $(filter %.d,$(SRC_AND_DEPENDS)), $(OBJDIR)/$(file))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BASE = $(subst /,\/,$*)
|
|
||||||
ODIR = $(subst /,\/,$(OBJDIR))
|
|
||||||
|
|
||||||
# This magic is from the 'make' manual (with mods by jelson)
|
|
||||||
$(OBJDIR)/%.d: %.c
|
|
||||||
@mkdir -p $(OBJDIR)
|
|
||||||
set -e; $(CC) -MM -I$(KERNEL_INCLUDE) $(CFLAGS) $< \
|
|
||||||
| sed 's/\($(BASE)\)\.o[ :]*/$(ODIR)\/$(BASE).o $(ODIR)\/$(BASE).d : /g' > $@; \
|
|
||||||
[ -s $@ ] || rm -f $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.d: %.C
|
|
||||||
@mkdir -p $(OBJDIR)
|
|
||||||
set -e; $(CC) -MM $(CPPFLAGS) $< \
|
|
||||||
| sed 's/\($(BASE)\)\.o[ :]*/$(ODIR)\/$(BASE).o $(ODIR)\/$(BASE).d : /g' > $@; \
|
|
||||||
[ -s $@ ] || rm -f $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.d: %.cpp
|
|
||||||
@mkdir -p $(OBJDIR)
|
|
||||||
set -e; $(CC) -MM $(CPPFLAGS) $< \
|
|
||||||
| sed 's/\($(BASE)\)\.o[ :]*/$(ODIR)\/$(BASE).o $(ODIR)\/$(BASE).d : /g' > $@; \
|
|
||||||
[ -s $@ ] || rm -f $@
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Rules
|
|
||||||
#
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.cpp
|
|
||||||
$(CPP) $(CPPFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.C
|
|
||||||
$(CPP) $(CPPFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
$(OBJDIR)/%.o: %.c
|
|
||||||
$(CC) $(CCFLAGS) $< -c -o $@
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f $(ALLTARGETS) $(OBJDIR)/*.[oa] $(OBJDIR)/*.so.* $(DEPENDS)
|
|
||||||
|
|
||||||
|
|
||||||
include $(DEPENDS)
|
|
||||||
Reference in New Issue
Block a user