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/fusd@12316 0101bb08-14d6-0310-b084-bc0e0c8e3800
This commit is contained in:
parent
48511c545d
commit
243da80fc6
@ -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
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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 <stdio.h>
|
||||
@ -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");
|
||||
|
||||
@ -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 <stdio.h>
|
||||
|
||||
@ -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 <stdio.h>
|
||||
|
||||
@ -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 <stdio.h>
|
||||
@ -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;
|
||||
|
||||
@ -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 <stdio.h>
|
||||
@ -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 */
|
||||
|
||||
@ -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 */
|
||||
|
||||
@ -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 <stdio.h>
|
||||
@ -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 */
|
||||
|
||||
@ -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 <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
|
||||
* 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;
|
||||
|
||||
|
||||
@ -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 <stdio.h>
|
||||
|
||||
@ -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 <stdio.h>
|
||||
@ -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];
|
||||
|
||||
@ -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__
|
||||
|
||||
@ -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$
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
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)
|
||||
Loading…
x
Reference in New Issue
Block a user