From a55dc93a55cebff74f7227a1ce9b318fe82e022d Mon Sep 17 00:00:00 2001 From: xiphmont Date: Sat, 13 Jan 2007 09:30:10 +0000 Subject: [PATCH] Sufficiently updated docs, build system and a few of the examples for an initial release. Primary remaining problem: udev-style kernels don't allow registration of a preexisting class right now. This will need to be fixed semi-immediately. git-svn-id: http://svn.xiph.org/trunk@12316 0101bb08-14d6-0310-b084-bc0e0c8e3800 --- fusd/doc/Makefile | 9 +-- fusd/doc/make-examples.pl | 50 --------------- fusd/examples/Makefile | 12 +++- fusd/examples/console-read.c | 6 +- fusd/examples/drums.c | 2 +- fusd/examples/drums2.c | 2 +- fusd/examples/drums3.c | 4 +- fusd/examples/echo.c | 4 +- fusd/examples/helloworld.c | 2 +- fusd/examples/ioctl.c | 36 +++++++---- fusd/examples/logring.c | 4 +- fusd/examples/pager.c | 2 +- fusd/examples/uid-filter.c | 4 +- fusd/include/kfusd.h | 2 +- fusd/kfusd/kfusd.c | 2 +- fusd/libfusd/libfusd.c | 4 +- fusd/make.include | 149 ------------------------------------------- 17 files changed, 54 insertions(+), 240 deletions(-) delete mode 100755 fusd/doc/make-examples.pl delete mode 100644 fusd/make.include diff --git a/fusd/doc/Makefile b/fusd/doc/Makefile index be12586a2..2b7981f4d 100644 --- a/fusd/doc/Makefile +++ b/fusd/doc/Makefile @@ -1,13 +1,10 @@ default: docs clean: - @rm -f *.[ch].example + rm -f *.[ch].example + rm -f fusd.dvi -examples: - @rm -f *.[ch].example - @./make-examples.pl ../examples/*.[ch] - -docs: examples +docs: latex fusd latex fusd diff --git a/fusd/doc/make-examples.pl b/fusd/doc/make-examples.pl deleted file mode 100755 index ea3d2398e..000000000 --- a/fusd/doc/make-examples.pl +++ /dev/null @@ -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 = ) { - 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); -} - diff --git a/fusd/examples/Makefile b/fusd/examples/Makefile index 67d882655..c3f8c8f6c 100644 --- a/fusd/examples/Makefile +++ b/fusd/examples/Makefile @@ -2,8 +2,16 @@ 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 +TARGETS = helloworld + +# right now, several examples do not work properly; the current +# version of fusd is unable to add new devices to a preexisting class +# (unless the device calsss is 'sound') and for that reason, examples +# that register multiple devices build but do not run properly. Will +# be fixed soon (requires a minor kernel extension). + +#TARGETS = console-read drums3 echo helloworld logring pager\ +# drums2 drums ioctl uid-filter default: $(TARGETS) diff --git a/fusd/examples/console-read.c b/fusd/examples/console-read.c index 3d595e99c..f5560d47f 100644 --- a/fusd/examples/console-read.c +++ b/fusd/examples/console-read.c @@ -40,7 +40,7 @@ * need a template from which to start on a real driver, use pager.c * instead. * - * $Id: console-read.c,v 1.4 2003/07/11 22:29:38 cerpa Exp $ + * $Id$ */ #include @@ -57,7 +57,7 @@ int do_open_or_close(struct fusd_file_info *file) } /* 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) { char buf[128]; @@ -88,7 +88,7 @@ int main(int argc, char *argv[]) read: do_read, 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"); else { printf("/dev/console-read should now exist - calling fusd_run...\n"); diff --git a/fusd/examples/drums.c b/fusd/examples/drums.c index cdf313902..f39ccf560 100644 --- a/fusd/examples/drums.c +++ b/fusd/examples/drums.c @@ -42,7 +42,7 @@ * 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. * - * $Id: drums.c,v 1.4 2003/07/11 22:29:38 cerpa Exp $ + * $Id$ */ #include diff --git a/fusd/examples/drums2.c b/fusd/examples/drums2.c index 62ccd46b8..3146aaa59 100644 --- a/fusd/examples/drums2.c +++ b/fusd/examples/drums2.c @@ -47,7 +47,7 @@ * to remember if this user has read before; cat /dev/drums/X will * read infinitely * - * $Id: drums2.c,v 1.6 2003/07/11 22:29:38 cerpa Exp $ + * $Id$ */ #include diff --git a/fusd/examples/drums3.c b/fusd/examples/drums3.c index 3361d69aa..68ee6b24a 100644 --- a/fusd/examples/drums3.c +++ b/fusd/examples/drums3.c @@ -43,7 +43,7 @@ * However, it also prints a prompt to the console, asking the user if * how loud the drums should be. * - * $Id: drums3.c,v 1.3 2003/07/11 22:29:38 cerpa Exp $ + * $Id$ */ #include @@ -63,7 +63,7 @@ static char *drums_strings[] = {"bam", "bum", "beat", "boom", 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) { int len; diff --git a/fusd/examples/echo.c b/fusd/examples/echo.c index b367b7cba..7a6aa4461 100644 --- a/fusd/examples/echo.c +++ b/fusd/examples/echo.c @@ -41,7 +41,7 @@ * stored. Then, when you read (e.g. "cat /dev/echo"), you get back * whatever you wrote most recently. * - * $Id: echo.c,v 1.6 2003/07/11 22:29:38 cerpa Exp $ + * $Id$ */ #include @@ -58,7 +58,7 @@ char *data = NULL; 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) { /* if the user has read past the end of the data, return EOF */ diff --git a/fusd/examples/helloworld.c b/fusd/examples/helloworld.c index 9fcb07ba2..28df8a6d0 100644 --- a/fusd/examples/helloworld.c +++ b/fusd/examples/helloworld.c @@ -37,7 +37,7 @@ * hello-world: Simply creates a device called /dev/hello-world, which * greets you when you try to get it. * - * $Id: helloworld.c,v 1.11 2003/07/11 22:29:38 cerpa Exp $ + * $Id$ */ /* EXAMPLE START helloworld.c */ diff --git a/fusd/examples/ioctl.c b/fusd/examples/ioctl.c index fdadaf164..efd741adf 100644 --- a/fusd/examples/ioctl.c +++ b/fusd/examples/ioctl.c @@ -41,7 +41,7 @@ * the other examples, anyway), because this program is both an * example and part of the regression test suite. * - * $Id: ioctl.c,v 1.4 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ #include @@ -115,8 +115,9 @@ int do_ioctl(struct fusd_file_info *file, int cmd, void *arg) case IOCTL_TEST1: case IOCTL_TEST2: - printf("ioctl server: got test1/2, arg=%d, returning it\n", (int) arg); - return (int) arg; + printf("ioctl server: got test1/2, arg=%p, *arg= %d, returning it\n", + arg, *(int *)arg); + return *(int *) arg; break; /* EXAMPLE START ioctl-server.c */ @@ -185,7 +186,8 @@ int main(int argc, char *argv[]) /* ioctl server */ struct fusd_file_operations f = { open: zeroreturn, close: zeroreturn, 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"); printf("server starting\n"); fusd_run(); @@ -216,18 +218,24 @@ int main(int argc, char *argv[]) CHECK(ret == 0); /* test1: issue a command with a simple (integer) argument */ - ret = ioctl(fd, IOCTL_TEST1, TEST1_NUM); - CHECK(ret == TEST1_NUM); - CHECK(errno == 0); - printf("ioctl test1: got %d, errno=%d (expecting %d, errno=0)\n\n", - ret, errno, TEST1_NUM); + { + int arg = TEST1_NUM; + ret = ioctl(fd, IOCTL_TEST1, &arg); + CHECK(ret == 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 */ - ret = ioctl(fd, IOCTL_TEST2, -ELIBBAD); - CHECK(errno == ELIBBAD); - CHECK(ret == -1); - printf("ioctl test2: got %d, errno=%d (expecting -1, errno=%d)\n\n", - ret, errno, ELIBBAD); + { + int arg = -ELIBBAD; + ret = ioctl(fd, IOCTL_TEST2, &arg); + CHECK(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"); /* EXAMPLE START ioctl-client.c */ diff --git a/fusd/examples/logring.c b/fusd/examples/logring.c index 31cafe34c..72164770b 100644 --- a/fusd/examples/logring.c +++ b/fusd/examples/logring.c @@ -71,7 +71,7 @@ * but want to use it on a system that does not have FUSD, check out * emlog at http://www.circlemud.org/~jelson/software/emlog. * - * $Id: logring.c,v 1.8 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ #include @@ -340,7 +340,7 @@ void logring_complete_polldiff(struct logring_client *c) * 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. */ -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; diff --git a/fusd/examples/pager.c b/fusd/examples/pager.c index 6288e5a8f..3d8fa87b6 100644 --- a/fusd/examples/pager.c +++ b/fusd/examples/pager.c @@ -60,7 +60,7 @@ * 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). * - * $Id: pager.c,v 1.9 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ #include diff --git a/fusd/examples/uid-filter.c b/fusd/examples/uid-filter.c index 628688bf3..45ba68111 100644 --- a/fusd/examples/uid-filter.c +++ b/fusd/examples/uid-filter.c @@ -42,7 +42,7 @@ * 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. * - * $Id: uid-filter.c,v 1.4 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ #include @@ -71,7 +71,7 @@ int do_open(struct fusd_file_info *file) 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) { char buf[128]; diff --git a/fusd/include/kfusd.h b/fusd/include/kfusd.h index a3e8f0599..5fc70fb03 100755 --- a/fusd/include/kfusd.h +++ b/fusd/include/kfusd.h @@ -37,7 +37,7 @@ * * Private header file used by the Linux Kernel Module * - * $Id: kfusd.h,v 1.41 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ #ifndef __KFUSD_H__ diff --git a/fusd/kfusd/kfusd.c b/fusd/kfusd/kfusd.c index d73633436..685d18c99 100755 --- a/fusd/kfusd/kfusd.c +++ b/fusd/kfusd/kfusd.c @@ -38,7 +38,7 @@ * Copyright (c) 2001, Sensoria Corporation * Copyright (c) 2002-2003, Regents of the University of California * - * $Id: kfusd.c,v 1.97 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ /* diff --git a/fusd/libfusd/libfusd.c b/fusd/libfusd/libfusd.c index fc6da7b96..b199b604c 100755 --- a/fusd/libfusd/libfusd.c +++ b/fusd/libfusd/libfusd.c @@ -35,10 +35,10 @@ * * authors: jelson and girod * - * $Id: libfusd.c,v 1.61 2003/07/11 22:29:39 cerpa Exp $ + * $Id$ */ -char libfusd_c_id[] = "$Id: libfusd.c,v 1.61 2003/07/11 22:29:39 cerpa Exp $"; +char libfusd_c_id[] = "$Id$"; #include #include diff --git a/fusd/make.include b/fusd/make.include deleted file mode 100644 index 3e595542d..000000000 --- a/fusd/make.include +++ /dev/null @@ -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) -- 2.11.4.GIT