Update to lastest version
This commit is contained in:
parent
a667d5412c
commit
788c45bd77
@ -40,7 +40,7 @@
|
||||
* need a template from which to start on a real driver, use pager.c
|
||||
* instead.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: console-read.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -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$
|
||||
* $Id: drums.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -47,7 +47,7 @@
|
||||
* to remember if this user has read before; cat /dev/drums/X will
|
||||
* read infinitely
|
||||
*
|
||||
* $Id$
|
||||
* $Id: drums2.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||
*/
|
||||
|
||||
#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$
|
||||
* $Id: drums3.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
* stored. Then, when you read (e.g. "cat /dev/echo"), you get back
|
||||
* whatever you wrote most recently.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: echo.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
* hello-world: Simply creates a device called /dev/hello-world, which
|
||||
* greets you when you try to get it.
|
||||
*
|
||||
* $Id$
|
||||
* $Id: helloworld.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
/* 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$
|
||||
* $Id: ioctl.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -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$
|
||||
* $Id: logring.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -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$
|
||||
* $Id: pager.c 12355 2007-01-19 17:44:17Z xiphmont $
|
||||
*/
|
||||
|
||||
#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$
|
||||
* $Id: uid-filter.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -37,28 +37,28 @@
|
||||
*
|
||||
* Private header file used by the Linux Kernel Module
|
||||
*
|
||||
* $Id$
|
||||
* $Id: kfusd.h 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
#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
|
||||
* /usr/src/linux/Documentation/magic-number.txt */
|
||||
#define FUSD_DEV_MAGIC 0x8b43a123
|
||||
#define FUSD_FILE_MAGIC 0x613aa8fe
|
||||
# define FUSD_DEV_MAGIC 0x8b43a123
|
||||
# define FUSD_FILE_MAGIC 0x613aa8fe
|
||||
|
||||
/* 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 */
|
||||
#define MIN_FILEARRAY_SIZE 8 /* initialize allocation */
|
||||
#define MAX_FILEARRAY_SIZE 1024 /* maximum it can grow to */
|
||||
# define MIN_FILEARRAY_SIZE 8 /* initialize allocation */
|
||||
# define MAX_FILEARRAY_SIZE 1024 /* maximum it can grow to */
|
||||
|
||||
/* maximum read/write size we're willing to service */
|
||||
#define MAX_RW_SIZE (1024*128)
|
||||
# define MAX_RW_SIZE (1024*128)
|
||||
|
||||
|
||||
/********************** Structure Definitions *******************************/
|
||||
@ -174,34 +174,34 @@ STATIC struct fusd_transaction* fusd_find_transaction_by_pid(fusd_file_t *fusd_f
|
||||
|
||||
/**** Utility functions & macros ****/
|
||||
|
||||
#ifdef CONFIG_FUSD_USE_WAKEUPSYNC
|
||||
#define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible_sync(x)
|
||||
#else
|
||||
#define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible(x)
|
||||
#endif /* CONFIG_FUSD_USE_WAKEUPSYNC */
|
||||
# ifdef CONFIG_FUSD_USE_WAKEUPSYNC
|
||||
# define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible_sync(x)
|
||||
# else
|
||||
# define WAKE_UP_INTERRUPTIBLE_SYNC(x) wake_up_interruptible(x)
|
||||
# endif /* CONFIG_FUSD_USE_WAKEUPSYNC */
|
||||
|
||||
#ifdef CONFIG_FUSD_DEBUG
|
||||
# ifdef CONFIG_FUSD_DEBUG
|
||||
static void rdebug_real(char *fmt, ...)
|
||||
__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); \
|
||||
} while(0)
|
||||
#else
|
||||
#define RDEBUG(message_level, args...)
|
||||
#endif /* CONFIG_FUSD_DEBUG */
|
||||
# else
|
||||
# define RDEBUG(message_level, args...)
|
||||
# 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; \
|
||||
if (fusd_dev == NULL || fusd_dev->magic != FUSD_DEV_MAGIC) \
|
||||
goto invalid_dev; \
|
||||
} 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; \
|
||||
if (fusd_file == NULL || fusd_file->magic != FUSD_FILE_MAGIC) \
|
||||
goto invalid_file; \
|
||||
@ -210,36 +210,40 @@ static void rdebug_real(char *fmt, ...)
|
||||
goto invalid_file; \
|
||||
} while (0)
|
||||
|
||||
|
||||
#define LOCK_FUSD_DEV(fusd_dev) \
|
||||
# define LOCK_FUSD_DEV(fusd_dev) \
|
||||
do { down(&fusd_dev->dev_sem); \
|
||||
if (ZOMBIE(fusd_dev)) { up(&fusd_dev->dev_sem); goto zombie_dev; } \
|
||||
} while (0)
|
||||
|
||||
/* 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)
|
||||
|
||||
#define UNLOCK_FUSD_DEV(fusd_dev) \
|
||||
# define UNLOCK_FUSD_DEV(fusd_dev) \
|
||||
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); \
|
||||
} while (0)
|
||||
|
||||
#define UNLOCK_FUSD_FILE(fusd_file) \
|
||||
# define UNLOCK_FUSD_FILE(fusd_file) \
|
||||
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); \
|
||||
KFREE(fusd_msgc); \
|
||||
} 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)
|
||||
|
||||
#ifdef CONFIG_FUSD_MEMDEBUG
|
||||
# ifdef CONFIG_FUSD_MEMDEBUG
|
||||
static int fusd_mem_init(void);
|
||||
static void fusd_mem_cleanup(void);
|
||||
static void fusd_mem_add(void *ptr, int line, int size);
|
||||
@ -248,22 +252,22 @@ static void *fusd_kmalloc(size_t size, int type, int line);
|
||||
static void fusd_kfree(void *ptr);
|
||||
static void *fusd_vmalloc(size_t size, int line);
|
||||
static void fusd_vfree(void *ptr);
|
||||
# define KMALLOC(size, type) fusd_kmalloc(size, type, __LINE__)
|
||||
# define KFREE(ptr) fusd_kfree(ptr)
|
||||
# define VMALLOC(size) fusd_vmalloc(size, __LINE__)
|
||||
# define VFREE(ptr) fusd_vfree(ptr)
|
||||
#else /* no memory debugging */
|
||||
# define KMALLOC(size, type) kmalloc(size, type)
|
||||
# define KFREE(ptr) kfree(ptr)
|
||||
# define KMALLOC(size, type) fusd_kmalloc(size, type, __LINE__)
|
||||
# define KFREE(ptr) fusd_kfree(ptr)
|
||||
# define VMALLOC(size) fusd_vmalloc(size, __LINE__)
|
||||
# define VFREE(ptr) fusd_vfree(ptr)
|
||||
# else /* no memory debugging */
|
||||
# define KMALLOC(size, type) kmalloc(size, type)
|
||||
# define KFREE(ptr) kfree(ptr)
|
||||
/*# define VMALLOC(size) vmalloc(size)*/
|
||||
# define VMALLOC(size) kmalloc(size, GFP_KERNEL)
|
||||
# define VFREE(ptr) kfree(ptr)
|
||||
#endif /* CONFIG_FUSD_MEMDEBUG */
|
||||
# define VMALLOC(size) kmalloc(size, GFP_KERNEL)
|
||||
# define VFREE(ptr) kfree(ptr)
|
||||
# endif /* CONFIG_FUSD_MEMDEBUG */
|
||||
|
||||
|
||||
|
||||
/* Functions like this should be in the kernel, but they are not. Sigh. */
|
||||
#ifdef CONFIG_SMP
|
||||
# ifdef CONFIG_SMP
|
||||
|
||||
DECLARE_MUTEX(atomic_ops);
|
||||
|
||||
@ -276,12 +280,11 @@ static __inline__ int atomic_inc_and_ret(int *i)
|
||||
up(&atomic_ops);
|
||||
return val;
|
||||
}
|
||||
#else
|
||||
# else
|
||||
static __inline__ int atomic_inc_and_ret(int *i)
|
||||
{
|
||||
return (++(*i));
|
||||
}
|
||||
#endif
|
||||
|
||||
# endif
|
||||
|
||||
#endif /* __KFUSD_H__ */
|
||||
|
||||
@ -1,16 +1,21 @@
|
||||
ifneq ($(KERNELRELEASE),)
|
||||
obj-m := kfusd.o
|
||||
KERNEL_VER ?= $(KERNELRELEASE)
|
||||
else
|
||||
KDIR ?= /lib/modules/$(shell uname -r)/build
|
||||
PWD := $(shell pwd)
|
||||
ROOTFS ?=
|
||||
|
||||
KERNEL_VER ?= 2.6.32.7
|
||||
|
||||
default:
|
||||
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS=-I$(PWD)/../include modules
|
||||
|
||||
install:
|
||||
$(INSTALL) -d -m 0755 /lib/modules/$(shell uname -r)/kernel/drivers/misc
|
||||
$(INSTALL) -m 0755 kfusd.ko /lib/modules/$(shell uname -r)/kernel/drivers/misc
|
||||
/sbin/depmod -a
|
||||
install:
|
||||
install -d -m 0755 $(ROOTFS)/lib/modules/$(KERNEL_VER)/kernel/drivers/misc
|
||||
install -m 0755 kfusd.ko $(ROOTFS)/lib/modules/$(KERNEL_VER)/kernel/drivers/misc
|
||||
|
||||
# /sbin/depmod -a
|
||||
|
||||
clean:
|
||||
rm -f .kfusd* Modules.symvers \
|
||||
|
||||
@ -1945,7 +1945,7 @@ STATIC struct file_operations fusd_client_fops = {
|
||||
.release = fusd_client_release,
|
||||
.read = fusd_client_read,
|
||||
.write = fusd_client_write,
|
||||
.unlocked_ioctl = fusd_client_ioctl,
|
||||
.ioctl = fusd_client_ioctl,
|
||||
.poll = fusd_client_poll,
|
||||
.mmap = fusd_client_mmap
|
||||
};
|
||||
@ -2846,7 +2846,7 @@ STATIC struct file_operations fusd_fops = {
|
||||
.read = fusd_read,
|
||||
.write = fusd_write,
|
||||
//writev: fusd_writev,
|
||||
.unlocked_ioctl = fusd_ioctl,
|
||||
.ioctl = fusd_ioctl,
|
||||
.release = fusd_release,
|
||||
.poll = fusd_poll,
|
||||
};
|
||||
@ -3127,7 +3127,7 @@ STATIC unsigned int fusd_status_poll (struct file *file, poll_table *wait)
|
||||
STATIC struct file_operations fusd_status_fops = {
|
||||
.owner = THIS_MODULE,
|
||||
.open = fusd_status_open,
|
||||
.unlocked_ioctl = fusd_status_ioctl,
|
||||
.ioctl = fusd_status_ioctl,
|
||||
.read = fusd_status_read,
|
||||
.release = fusd_status_release,
|
||||
.poll = fusd_status_poll,
|
||||
|
||||
@ -35,10 +35,10 @@
|
||||
*
|
||||
* authors: jelson and girod
|
||||
*
|
||||
* $Id$
|
||||
* $Id: libfusd.c 12351 2007-01-19 07:22:54Z xiphmont $
|
||||
*/
|
||||
|
||||
char libfusd_c_id[] = "$Id$";
|
||||
char libfusd_c_id[] = "$Id: libfusd.c 12351 2007-01-19 07:22:54Z xiphmont $";
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@ -408,21 +408,21 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
||||
|
||||
/* dispatch on operation type */
|
||||
user_retval = -ENOSYS;
|
||||
printf("dispatch_one: subcmd: %d - ", msg->subcmd);
|
||||
//printf("dispatch_one: subcmd: %d - ", msg->subcmd);
|
||||
|
||||
switch (msg->subcmd) {
|
||||
case FUSD_OPEN:
|
||||
printf("FUSD_OPEN\n");
|
||||
//printf("FUSD_OPEN\n");
|
||||
if (fops && fops->open)
|
||||
user_retval = fops->open(file);
|
||||
break;
|
||||
case FUSD_CLOSE:
|
||||
printf("FUSD_CLOSE\n");
|
||||
//printf("FUSD_CLOSE\n");
|
||||
if (fops && fops->close)
|
||||
user_retval = fops->close(file);
|
||||
break;
|
||||
case FUSD_READ:
|
||||
printf("FUSD_READ\n");
|
||||
//printf("FUSD_READ\n");
|
||||
/* allocate a buffer and make the call */
|
||||
if (fops && fops->read) {
|
||||
if ((msg->data = malloc(msg->parm.fops_msg.length)) == NULL) {
|
||||
@ -436,13 +436,13 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
||||
}
|
||||
break;
|
||||
case FUSD_WRITE:
|
||||
printf("FUSD_WRITE\n");
|
||||
//printf("FUSD_WRITE\n");
|
||||
if (fops && fops->write)
|
||||
user_retval = fops->write(file, msg->data, msg->datalen,
|
||||
&msg->parm.fops_msg.offset);
|
||||
break;
|
||||
case FUSD_MMAP:
|
||||
printf("FUSD_MMAP\n");
|
||||
//printf("FUSD_MMAP\n");
|
||||
if (fops && fops->mmap)
|
||||
{
|
||||
user_retval = fops->mmap(file, msg->parm.fops_msg.offset, msg->parm.fops_msg.length, msg->parm.fops_msg.flags,
|
||||
@ -450,7 +450,7 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
||||
}
|
||||
break;
|
||||
case FUSD_IOCTL:
|
||||
printf("FUSD_IOCTL\n");
|
||||
//printf("FUSD_IOCTL\n");
|
||||
if (fops && fops->ioctl) {
|
||||
/* in the case of an ioctl read, allocate a buffer for the
|
||||
* driver to write to, IF there isn't already a buffer. (there
|
||||
@ -472,7 +472,7 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
||||
break;
|
||||
|
||||
case FUSD_POLL_DIFF:
|
||||
printf("FUSD_POLL_DIFF\n");
|
||||
//printf("FUSD_POLL_DIFF\n");
|
||||
/* This callback requests notification when an event occurs on a file,
|
||||
* e.g. becoming readable or writable */
|
||||
if (fops && fops->poll_diff)
|
||||
@ -480,7 +480,7 @@ static int fusd_dispatch_one(int fd, fusd_file_operations_t *fops)
|
||||
break;
|
||||
|
||||
case FUSD_UNBLOCK:
|
||||
printf("FUSD_UNBLOCK\n");
|
||||
//printf("FUSD_UNBLOCK\n");
|
||||
/* This callback is called when a system call is interrupted */
|
||||
if (fops && fops->unblock)
|
||||
user_retval = fops->unblock(file);
|
||||
@ -657,7 +657,7 @@ int fusd_return(fusd_file_info_t *file, ssize_t retval)
|
||||
|
||||
/* send message to kernel */
|
||||
if (msg->datalen && msg->data != NULL) {
|
||||
printf("(msg->datalen [%d] && msg->data != NULL [%p]", msg->datalen, msg->data);
|
||||
//printf("(msg->datalen [%d] && msg->data != NULL [%p]", msg->datalen, msg->data);
|
||||
iov[0].iov_base = msg;
|
||||
iov[0].iov_len = sizeof(fusd_msg_t);
|
||||
iov[1].iov_base = msg->data;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user