Commit 243c64b2 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] feed devfs through Lindent

Nobody seems to have any outstanding work against devfs, so...
parent 77b92f5b
...@@ -753,22 +753,19 @@ ...@@ -753,22 +753,19 @@
typedef struct devfs_entry *devfs_handle_t; typedef struct devfs_entry *devfs_handle_t;
struct directory_type struct directory_type {
{
rwlock_t lock; /* Lock for searching(R)/updating(W) */ rwlock_t lock; /* Lock for searching(R)/updating(W) */
struct devfs_entry *first; struct devfs_entry *first;
struct devfs_entry *last; struct devfs_entry *last;
unsigned char no_more_additions:1; unsigned char no_more_additions:1;
}; };
struct symlink_type struct symlink_type {
{
unsigned int length; /* Not including the NULL-termimator */ unsigned int length; /* Not including the NULL-termimator */
char *linkname; /* This is NULL-terminated */ char *linkname; /* This is NULL-terminated */
}; };
struct devfs_inode /* This structure is for "persistent" inode storage */ struct devfs_inode { /* This structure is for "persistent" inode storage */
{
struct dentry *dentry; struct dentry *dentry;
struct timespec atime; struct timespec atime;
struct timespec mtime; struct timespec mtime;
...@@ -778,28 +775,25 @@ struct devfs_inode /* This structure is for "persistent" inode storage */ ...@@ -778,28 +775,25 @@ struct devfs_inode /* This structure is for "persistent" inode storage */
gid_t gid; gid_t gid;
}; };
struct devfs_entry struct devfs_entry {
{
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
unsigned int magic_number; unsigned int magic_number;
#endif #endif
void *info; void *info;
atomic_t refcount; /* When this drops to zero, it's unused */ atomic_t refcount; /* When this drops to zero, it's unused */
union union {
{
struct directory_type dir; struct directory_type dir;
dev_t dev; dev_t dev;
struct symlink_type symlink; struct symlink_type symlink;
const char *name; /* Only used for (mode == 0) */ const char *name; /* Only used for (mode == 0) */
} } u;
u;
struct devfs_entry *prev; /* Previous entry in the parent directory */ struct devfs_entry *prev; /* Previous entry in the parent directory */
struct devfs_entry *next; /* Next entry in the parent directory */ struct devfs_entry *next; /* Next entry in the parent directory */
struct devfs_entry *parent; /* The parent directory */ struct devfs_entry *parent; /* The parent directory */
struct devfs_inode inode; struct devfs_inode inode;
umode_t mode; umode_t mode;
unsigned short namelen; /* I think 64k+ filenames are a way off... */ unsigned short namelen; /* I think 64k+ filenames are a way off... */
unsigned char vfs:1;/* Whether the VFS may delete the entry */ unsigned char vfs:1; /* Whether the VFS may delete the entry */
char name[1]; /* This is just a dummy: the allocated array char name[1]; /* This is just a dummy: the allocated array
is bigger. This is NULL-terminated */ is bigger. This is NULL-terminated */
}; };
...@@ -807,8 +801,7 @@ struct devfs_entry ...@@ -807,8 +801,7 @@ struct devfs_entry
/* The root of the device tree */ /* The root of the device tree */
static struct devfs_entry *root_entry; static struct devfs_entry *root_entry;
struct devfsd_buf_entry struct devfsd_buf_entry {
{
struct devfs_entry *de; /* The name is generated with this */ struct devfs_entry *de; /* The name is generated with this */
unsigned short type; /* The type of event */ unsigned short type; /* The type of event */
umode_t mode; umode_t mode;
...@@ -817,8 +810,7 @@ struct devfsd_buf_entry ...@@ -817,8 +810,7 @@ struct devfsd_buf_entry
struct devfsd_buf_entry *next; struct devfsd_buf_entry *next;
}; };
struct fs_info /* This structure is for the mounted devfs */ struct fs_info { /* This structure is for the mounted devfs */
{
struct super_block *sb; struct super_block *sb;
spinlock_t devfsd_buffer_lock; /* Lock when inserting/deleting events */ spinlock_t devfsd_buffer_lock; /* Lock when inserting/deleting events */
struct devfsd_buf_entry *devfsd_first_event; struct devfsd_buf_entry *devfsd_first_event;
...@@ -834,7 +826,7 @@ struct fs_info /* This structure is for the mounted devfs */ ...@@ -834,7 +826,7 @@ struct fs_info /* This structure is for the mounted devfs */
wait_queue_head_t revalidate_wait_queue; /* Wake when devfsd sleeps */ wait_queue_head_t revalidate_wait_queue; /* Wake when devfsd sleeps */
}; };
static struct fs_info fs_info = {.devfsd_buffer_lock = SPIN_LOCK_UNLOCKED}; static struct fs_info fs_info = {.devfsd_buffer_lock = SPIN_LOCK_UNLOCKED };
static kmem_cache_t *devfsd_buf_cache; static kmem_cache_t *devfsd_buf_cache;
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
static unsigned int devfs_debug_init __initdata = DEBUG_NONE; static unsigned int devfs_debug_init __initdata = DEBUG_NONE;
...@@ -844,7 +836,7 @@ static unsigned int stat_num_entries; ...@@ -844,7 +836,7 @@ static unsigned int stat_num_entries;
static unsigned int stat_num_bytes; static unsigned int stat_num_bytes;
#endif #endif
static unsigned char poison_array[8] = static unsigned char poison_array[8] =
{0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a}; { 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a, 0x5a };
#ifdef CONFIG_DEVFS_MOUNT #ifdef CONFIG_DEVFS_MOUNT
static unsigned int boot_options = OPTION_MOUNT; static unsigned int boot_options = OPTION_MOUNT;
...@@ -853,45 +845,41 @@ static unsigned int boot_options = OPTION_NONE; ...@@ -853,45 +845,41 @@ static unsigned int boot_options = OPTION_NONE;
#endif #endif
/* Forward function declarations */ /* Forward function declarations */
static devfs_handle_t _devfs_walk_path (struct devfs_entry *dir, static devfs_handle_t _devfs_walk_path(struct devfs_entry *dir,
const char *name, int namelen, const char *name, int namelen,
int traverse_symlink); int traverse_symlink);
static ssize_t devfsd_read (struct file *file, char *buf, size_t len, static ssize_t devfsd_read(struct file *file, char *buf, size_t len,
loff_t *ppos); loff_t * ppos);
static int devfsd_ioctl (struct inode *inode, struct file *file, static int devfsd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg); unsigned int cmd, unsigned long arg);
static int devfsd_close (struct inode *inode, struct file *file); static int devfsd_close(struct inode *inode, struct file *file);
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
static ssize_t stat_read (struct file *file, char *buf, size_t len, static ssize_t stat_read(struct file *file, char *buf, size_t len,
loff_t *ppos); loff_t * ppos);
static struct file_operations stat_fops = static struct file_operations stat_fops = {
{
.read = stat_read, .read = stat_read,
}; };
#endif #endif
/* Devfs daemon file operations */ /* Devfs daemon file operations */
static struct file_operations devfsd_fops = static struct file_operations devfsd_fops = {
{
.read = devfsd_read, .read = devfsd_read,
.ioctl = devfsd_ioctl, .ioctl = devfsd_ioctl,
.release = devfsd_close, .release = devfsd_close,
}; };
/* Support functions follow */ /* Support functions follow */
/** /**
* devfs_get - Get a reference to a devfs entry. * devfs_get - Get a reference to a devfs entry.
* @de: The devfs entry. * @de: The devfs entry.
*/ */
static struct devfs_entry *devfs_get (struct devfs_entry *de) static struct devfs_entry *devfs_get(struct devfs_entry *de)
{ {
VERIFY_ENTRY (de); VERIFY_ENTRY(de);
if (de) atomic_inc (&de->refcount); if (de)
atomic_inc(&de->refcount);
return de; return de;
} /* End Function devfs_get */ } /* End Function devfs_get */
...@@ -900,27 +888,33 @@ static struct devfs_entry *devfs_get (struct devfs_entry *de) ...@@ -900,27 +888,33 @@ static struct devfs_entry *devfs_get (struct devfs_entry *de)
* @de: The handle to the devfs entry. * @de: The handle to the devfs entry.
*/ */
static void devfs_put (devfs_handle_t de) static void devfs_put(devfs_handle_t de)
{ {
if (!de) return; if (!de)
VERIFY_ENTRY (de); return;
if (de->info == POISON_PTR) OOPS ("(%p): poisoned pointer\n", de); VERIFY_ENTRY(de);
if ( !atomic_dec_and_test (&de->refcount) ) return; if (de->info == POISON_PTR)
if (de == root_entry) OOPS ("(%p): root entry being freed\n", de); OOPS("(%p): poisoned pointer\n", de);
DPRINTK (DEBUG_FREE, "(%s): de: %p, parent: %p \"%s\"\n", if (!atomic_dec_and_test(&de->refcount))
return;
if (de == root_entry)
OOPS("(%p): root entry being freed\n", de);
DPRINTK(DEBUG_FREE, "(%s): de: %p, parent: %p \"%s\"\n",
de->name, de, de->parent, de->name, de, de->parent,
de->parent ? de->parent->name : "no parent"); de->parent ? de->parent->name : "no parent");
if ( S_ISLNK (de->mode) ) kfree (de->u.symlink.linkname); if (S_ISLNK(de->mode))
WRITE_ENTRY_MAGIC (de, 0); kfree(de->u.symlink.linkname);
WRITE_ENTRY_MAGIC(de, 0);
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
spin_lock (&stat_lock); spin_lock(&stat_lock);
--stat_num_entries; --stat_num_entries;
stat_num_bytes -= sizeof *de + de->namelen; stat_num_bytes -= sizeof *de + de->namelen;
if ( S_ISLNK (de->mode) ) stat_num_bytes -= de->u.symlink.length + 1; if (S_ISLNK(de->mode))
spin_unlock (&stat_lock); stat_num_bytes -= de->u.symlink.length + 1;
spin_unlock(&stat_lock);
#endif #endif
de->info = POISON_PTR; de->info = POISON_PTR;
kfree (de); kfree(de);
} /* End Function devfs_put */ } /* End Function devfs_put */
/** /**
...@@ -934,27 +928,26 @@ static void devfs_put (devfs_handle_t de) ...@@ -934,27 +928,26 @@ static void devfs_put (devfs_handle_t de)
* An implicit devfs_get() is performed on the returned entry. * An implicit devfs_get() is performed on the returned entry.
*/ */
static struct devfs_entry *_devfs_search_dir (struct devfs_entry *dir, static struct devfs_entry *_devfs_search_dir(struct devfs_entry *dir,
const char *name, const char *name,
unsigned int namelen) unsigned int namelen)
{ {
struct devfs_entry *curr; struct devfs_entry *curr;
if ( !S_ISDIR (dir->mode) ) if (!S_ISDIR(dir->mode)) {
{ PRINTK("(%s): not a directory\n", dir->name);
PRINTK ("(%s): not a directory\n", dir->name);
return NULL; return NULL;
} }
for (curr = dir->u.dir.first; curr != NULL; curr = curr->next) for (curr = dir->u.dir.first; curr != NULL; curr = curr->next) {
{ if (curr->namelen != namelen)
if (curr->namelen != namelen) continue; continue;
if (memcmp (curr->name, name, namelen) == 0) break; if (memcmp(curr->name, name, namelen) == 0)
break;
/* Not found: try the next one */ /* Not found: try the next one */
} }
return devfs_get (curr); return devfs_get(curr);
} /* End Function _devfs_search_dir */ } /* End Function _devfs_search_dir */
/** /**
* _devfs_alloc_entry - Allocate a devfs entry. * _devfs_alloc_entry - Allocate a devfs entry.
* @name: the name of the entry * @name: the name of the entry
...@@ -965,7 +958,7 @@ static struct devfs_entry *_devfs_search_dir (struct devfs_entry *dir, ...@@ -965,7 +958,7 @@ static struct devfs_entry *_devfs_search_dir (struct devfs_entry *dir,
* %NULL. * %NULL.
*/ */
static struct devfs_entry *_devfs_alloc_entry (const char *name, static struct devfs_entry *_devfs_alloc_entry(const char *name,
unsigned int namelen, unsigned int namelen,
umode_t mode) umode_t mode)
{ {
...@@ -973,29 +966,31 @@ static struct devfs_entry *_devfs_alloc_entry (const char *name, ...@@ -973,29 +966,31 @@ static struct devfs_entry *_devfs_alloc_entry (const char *name,
static unsigned long inode_counter = FIRST_INODE; static unsigned long inode_counter = FIRST_INODE;
static spinlock_t counter_lock = SPIN_LOCK_UNLOCKED; static spinlock_t counter_lock = SPIN_LOCK_UNLOCKED;
if ( name && (namelen < 1) ) namelen = strlen (name); if (name && (namelen < 1))
if ( ( new = kmalloc (sizeof *new + namelen, GFP_KERNEL) ) == NULL ) namelen = strlen(name);
if ((new = kmalloc(sizeof *new + namelen, GFP_KERNEL)) == NULL)
return NULL; return NULL;
memset (new, 0, sizeof *new + namelen); /* Will set '\0' on name */ memset(new, 0, sizeof *new + namelen); /* Will set '\0' on name */
new->mode = mode; new->mode = mode;
if ( S_ISDIR (mode) ) rwlock_init (&new->u.dir.lock); if (S_ISDIR(mode))
atomic_set (&new->refcount, 1); rwlock_init(&new->u.dir.lock);
spin_lock (&counter_lock); atomic_set(&new->refcount, 1);
spin_lock(&counter_lock);
new->inode.ino = inode_counter++; new->inode.ino = inode_counter++;
spin_unlock (&counter_lock); spin_unlock(&counter_lock);
if (name) memcpy (new->name, name, namelen); if (name)
memcpy(new->name, name, namelen);
new->namelen = namelen; new->namelen = namelen;
WRITE_ENTRY_MAGIC (new, MAGIC_VALUE); WRITE_ENTRY_MAGIC(new, MAGIC_VALUE);
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
spin_lock (&stat_lock); spin_lock(&stat_lock);
++stat_num_entries; ++stat_num_entries;
stat_num_bytes += sizeof *new + namelen; stat_num_bytes += sizeof *new + namelen;
spin_unlock (&stat_lock); spin_unlock(&stat_lock);
#endif #endif
return new; return new;
} /* End Function _devfs_alloc_entry */ } /* End Function _devfs_alloc_entry */
/** /**
* _devfs_append_entry - Append a devfs entry to a directory's child list. * _devfs_append_entry - Append a devfs entry to a directory's child list.
* @dir: The directory to add to. * @dir: The directory to add to.
...@@ -1009,41 +1004,46 @@ static struct devfs_entry *_devfs_alloc_entry (const char *name, ...@@ -1009,41 +1004,46 @@ static struct devfs_entry *_devfs_alloc_entry (const char *name,
* On failure, an implicit devfs_put() is performed on %de. * On failure, an implicit devfs_put() is performed on %de.
*/ */
static int _devfs_append_entry (devfs_handle_t dir, devfs_handle_t de, static int _devfs_append_entry(devfs_handle_t dir, devfs_handle_t de,
devfs_handle_t *old_de) devfs_handle_t * old_de)
{ {
int retval; int retval;
if (old_de) *old_de = NULL; if (old_de)
if ( !S_ISDIR (dir->mode) ) *old_de = NULL;
{ if (!S_ISDIR(dir->mode)) {
PRINTK ("(%s): dir: \"%s\" is not a directory\n", de->name, dir->name); PRINTK("(%s): dir: \"%s\" is not a directory\n", de->name,
devfs_put (de); dir->name);
devfs_put(de);
return -ENOTDIR; return -ENOTDIR;
} }
write_lock (&dir->u.dir.lock); write_lock(&dir->u.dir.lock);
if (dir->u.dir.no_more_additions) retval = -ENOENT; if (dir->u.dir.no_more_additions)
else retval = -ENOENT;
{ else {
struct devfs_entry *old; struct devfs_entry *old;
old = _devfs_search_dir (dir, de->name, de->namelen); old = _devfs_search_dir(dir, de->name, de->namelen);
if (old_de) *old_de = old; if (old_de)
else devfs_put (old); *old_de = old;
if (old == NULL) else
{ devfs_put(old);
if (old == NULL) {
de->parent = dir; de->parent = dir;
de->prev = dir->u.dir.last; de->prev = dir->u.dir.last;
/* Append to the directory's list of children */ /* Append to the directory's list of children */
if (dir->u.dir.first == NULL) dir->u.dir.first = de; if (dir->u.dir.first == NULL)
else dir->u.dir.last->next = de; dir->u.dir.first = de;
else
dir->u.dir.last->next = de;
dir->u.dir.last = de; dir->u.dir.last = de;
retval = 0; retval = 0;
} else
retval = -EEXIST;
} }
else retval = -EEXIST; write_unlock(&dir->u.dir.lock);
} if (retval)
write_unlock (&dir->u.dir.lock); devfs_put(de);
if (retval) devfs_put (de);
return retval; return retval;
} /* End Function _devfs_append_entry */ } /* End Function _devfs_append_entry */
...@@ -1067,7 +1067,7 @@ static struct devfs_entry *_devfs_get_root_entry(void) ...@@ -1067,7 +1067,7 @@ static struct devfs_entry *_devfs_get_root_entry(void)
return root_entry; return root_entry;
new = _devfs_alloc_entry(NULL, 0, MODE_DIR); new = _devfs_alloc_entry(NULL, 0, MODE_DIR);
if (new == NULL ) if (new == NULL)
return NULL; return NULL;
spin_lock(&root_lock); spin_lock(&root_lock);
...@@ -1096,139 +1096,131 @@ static struct devfs_entry *_devfs_get_root_entry(void) ...@@ -1096,139 +1096,131 @@ static struct devfs_entry *_devfs_get_root_entry(void)
* An implicit devfs_get() is performed on the returned entry. * An implicit devfs_get() is performed on the returned entry.
*/ */
static struct devfs_entry *_devfs_descend (struct devfs_entry *dir, static struct devfs_entry *_devfs_descend(struct devfs_entry *dir,
const char *name, int namelen, const char *name, int namelen,
int *next_pos) int *next_pos)
{ {
const char *stop, *ptr; const char *stop, *ptr;
struct devfs_entry *entry; struct devfs_entry *entry;
if ( (namelen >= 3) && (strncmp (name, "../", 3) == 0) ) if ((namelen >= 3) && (strncmp(name, "../", 3) == 0)) { /* Special-case going to parent directory */
{ /* Special-case going to parent directory */
*next_pos = 3; *next_pos = 3;
return devfs_get (dir->parent); return devfs_get(dir->parent);
} }
stop = name + namelen; stop = name + namelen;
/* Search for a possible '/' */ /* Search for a possible '/' */
for (ptr = name; (ptr < stop) && (*ptr != '/'); ++ptr); for (ptr = name; (ptr < stop) && (*ptr != '/'); ++ptr) ;
*next_pos = ptr - name; *next_pos = ptr - name;
read_lock (&dir->u.dir.lock); read_lock(&dir->u.dir.lock);
entry = _devfs_search_dir (dir, name, *next_pos); entry = _devfs_search_dir(dir, name, *next_pos);
read_unlock (&dir->u.dir.lock); read_unlock(&dir->u.dir.lock);
return entry; return entry;
} /* End Function _devfs_descend */ } /* End Function _devfs_descend */
static devfs_handle_t _devfs_make_parent_for_leaf(struct devfs_entry *dir,
static devfs_handle_t _devfs_make_parent_for_leaf (struct devfs_entry *dir,
const char *name, const char *name,
int namelen, int *leaf_pos) int namelen, int *leaf_pos)
{ {
int next_pos = 0; int next_pos = 0;
if (dir == NULL) dir = _devfs_get_root_entry (); if (dir == NULL)
if (dir == NULL) return NULL; dir = _devfs_get_root_entry();
devfs_get (dir); if (dir == NULL)
return NULL;
devfs_get(dir);
/* Search for possible trailing component and ignore it */ /* Search for possible trailing component and ignore it */
for (--namelen; (namelen > 0) && (name[namelen] != '/'); --namelen); for (--namelen; (namelen > 0) && (name[namelen] != '/'); --namelen) ;
*leaf_pos = (name[namelen] == '/') ? (namelen + 1) : 0; *leaf_pos = (name[namelen] == '/') ? (namelen + 1) : 0;
for (; namelen > 0; name += next_pos, namelen -= next_pos) for (; namelen > 0; name += next_pos, namelen -= next_pos) {
{
struct devfs_entry *de, *old = NULL; struct devfs_entry *de, *old = NULL;
if ( ( de = _devfs_descend (dir, name, namelen, &next_pos) ) == NULL ) if ((de =
{ _devfs_descend(dir, name, namelen, &next_pos)) == NULL) {
de = _devfs_alloc_entry (name, next_pos, MODE_DIR); de = _devfs_alloc_entry(name, next_pos, MODE_DIR);
devfs_get (de); devfs_get(de);
if ( !de || _devfs_append_entry (dir, de, &old) ) if (!de || _devfs_append_entry(dir, de, &old)) {
{ devfs_put(de);
devfs_put (de); if (!old || !S_ISDIR(old->mode)) {
if ( !old || !S_ISDIR (old->mode) ) devfs_put(old);
{ devfs_put(dir);
devfs_put (old);
devfs_put (dir);
return NULL; return NULL;
} }
de = old; /* Use the existing directory */ de = old; /* Use the existing directory */
} }
} }
if (de == dir->parent) if (de == dir->parent) {
{ devfs_put(dir);
devfs_put (dir); devfs_put(de);
devfs_put (de);
return NULL; return NULL;
} }
devfs_put (dir); devfs_put(dir);
dir = de; dir = de;
if (name[next_pos] == '/') ++next_pos; if (name[next_pos] == '/')
++next_pos;
} }
return dir; return dir;
} /* End Function _devfs_make_parent_for_leaf */ } /* End Function _devfs_make_parent_for_leaf */
static devfs_handle_t _devfs_prepare_leaf(devfs_handle_t * dir,
static devfs_handle_t _devfs_prepare_leaf (devfs_handle_t *dir,
const char *name, umode_t mode) const char *name, umode_t mode)
{ {
int namelen, leaf_pos; int namelen, leaf_pos;
struct devfs_entry *de; struct devfs_entry *de;
namelen = strlen (name); namelen = strlen(name);
if ( ( *dir = _devfs_make_parent_for_leaf (*dir, name, namelen, if ((*dir = _devfs_make_parent_for_leaf(*dir, name, namelen,
&leaf_pos) ) == NULL ) &leaf_pos)) == NULL) {
{ PRINTK("(%s): could not create parent path\n", name);
PRINTK ("(%s): could not create parent path\n", name);
return NULL; return NULL;
} }
if ( ( de = _devfs_alloc_entry (name + leaf_pos, namelen - leaf_pos,mode) ) if ((de = _devfs_alloc_entry(name + leaf_pos, namelen - leaf_pos, mode))
== NULL ) == NULL) {
{ PRINTK("(%s): could not allocate entry\n", name);
PRINTK ("(%s): could not allocate entry\n", name); devfs_put(*dir);
devfs_put (*dir);
return NULL; return NULL;
} }
return de; return de;
} /* End Function _devfs_prepare_leaf */ } /* End Function _devfs_prepare_leaf */
static devfs_handle_t _devfs_walk_path(struct devfs_entry *dir,
static devfs_handle_t _devfs_walk_path (struct devfs_entry *dir,
const char *name, int namelen, const char *name, int namelen,
int traverse_symlink) int traverse_symlink)
{ {
int next_pos = 0; int next_pos = 0;
if (dir == NULL) dir = _devfs_get_root_entry (); if (dir == NULL)
if (dir == NULL) return NULL; dir = _devfs_get_root_entry();
devfs_get (dir); if (dir == NULL)
for (; namelen > 0; name += next_pos, namelen -= next_pos) return NULL;
{ devfs_get(dir);
for (; namelen > 0; name += next_pos, namelen -= next_pos) {
struct devfs_entry *de, *link; struct devfs_entry *de, *link;
if (!S_ISDIR (dir->mode)) if (!S_ISDIR(dir->mode)) {
{ devfs_put(dir);
devfs_put (dir);
return NULL; return NULL;
} }
if ( ( de = _devfs_descend (dir, name, namelen, &next_pos) ) == NULL ) if ((de =
{ _devfs_descend(dir, name, namelen, &next_pos)) == NULL) {
devfs_put (dir); devfs_put(dir);
return NULL; return NULL;
} }
if (S_ISLNK (de->mode) && traverse_symlink) if (S_ISLNK(de->mode) && traverse_symlink) { /* Need to follow the link: this is a stack chomper */
{ /* Need to follow the link: this is a stack chomper */
/* FIXME what if it puts outside of mounted tree? */ /* FIXME what if it puts outside of mounted tree? */
link = _devfs_walk_path (dir, de->u.symlink.linkname, link = _devfs_walk_path(dir, de->u.symlink.linkname,
de->u.symlink.length, TRUE); de->u.symlink.length, TRUE);
devfs_put (de); devfs_put(de);
if (!link) if (!link) {
{ devfs_put(dir);
devfs_put (dir);
return NULL; return NULL;
} }
de = link; de = link;
} }
devfs_put (dir); devfs_put(dir);
dir = de; dir = de;
if (name[next_pos] == '/') ++next_pos; if (name[next_pos] == '/')
++next_pos;
} }
return dir; return dir;
} /* End Function _devfs_walk_path */ } /* End Function _devfs_walk_path */
...@@ -1244,41 +1236,38 @@ static devfs_handle_t _devfs_walk_path (struct devfs_entry *dir, ...@@ -1244,41 +1236,38 @@ static devfs_handle_t _devfs_walk_path (struct devfs_entry *dir,
* devfs_get() is performed. * devfs_get() is performed.
*/ */
static struct devfs_entry *_devfs_find_entry (devfs_handle_t dir, static struct devfs_entry *_devfs_find_entry(devfs_handle_t dir,
const char *name, const char *name,
int traverse_symlink) int traverse_symlink)
{ {
unsigned int namelen = strlen (name); unsigned int namelen = strlen(name);
if (name[0] == '/') if (name[0] == '/') {
{
/* Skip leading pathname component */ /* Skip leading pathname component */
if (namelen < 2) if (namelen < 2) {
{ PRINTK("(%s): too short\n", name);
PRINTK ("(%s): too short\n", name);
return NULL; return NULL;
} }
for (++name, --namelen; (*name != '/') && (namelen > 0); for (++name, --namelen; (*name != '/') && (namelen > 0);
++name, --namelen); ++name, --namelen) ;
if (namelen < 2) if (namelen < 2) {
{ PRINTK("(%s): too short\n", name);
PRINTK ("(%s): too short\n", name);
return NULL; return NULL;
} }
++name; ++name;
--namelen; --namelen;
} }
return _devfs_walk_path (dir, name, namelen, traverse_symlink); return _devfs_walk_path(dir, name, namelen, traverse_symlink);
} /* End Function _devfs_find_entry */ } /* End Function _devfs_find_entry */
static struct devfs_entry *get_devfs_entry_from_vfs_inode (struct inode *inode) static struct devfs_entry *get_devfs_entry_from_vfs_inode(struct inode *inode)
{ {
if (inode == NULL) return NULL; if (inode == NULL)
VERIFY_ENTRY ( (struct devfs_entry *) inode->u.generic_ip ); return NULL;
VERIFY_ENTRY((struct devfs_entry *)inode->u.generic_ip);
return inode->u.generic_ip; return inode->u.generic_ip;
} /* End Function get_devfs_entry_from_vfs_inode */ } /* End Function get_devfs_entry_from_vfs_inode */
/** /**
* free_dentry - Free the dentry for a device entry and invalidate inode. * free_dentry - Free the dentry for a device entry and invalidate inode.
* @de: The entry. * @de: The entry.
...@@ -1287,21 +1276,22 @@ static struct devfs_entry *get_devfs_entry_from_vfs_inode (struct inode *inode) ...@@ -1287,21 +1276,22 @@ static struct devfs_entry *get_devfs_entry_from_vfs_inode (struct inode *inode)
* parent directory. * parent directory.
*/ */
static void free_dentry (struct devfs_entry *de) static void free_dentry(struct devfs_entry *de)
{ {
struct dentry *dentry = de->inode.dentry; struct dentry *dentry = de->inode.dentry;
if (!dentry) return; if (!dentry)
spin_lock (&dcache_lock); return;
dget_locked (dentry); spin_lock(&dcache_lock);
spin_unlock (&dcache_lock); dget_locked(dentry);
spin_unlock(&dcache_lock);
/* Forcefully remove the inode */ /* Forcefully remove the inode */
if (dentry->d_inode != NULL) dentry->d_inode->i_nlink = 0; if (dentry->d_inode != NULL)
d_drop (dentry); dentry->d_inode->i_nlink = 0;
dput (dentry); d_drop(dentry);
dput(dentry);
} /* End Function free_dentry */ } /* End Function free_dentry */
/** /**
* is_devfsd_or_child - Test if the current process is devfsd or one of its children. * is_devfsd_or_child - Test if the current process is devfsd or one of its children.
* @fs_info: The filesystem information. * @fs_info: The filesystem information.
...@@ -1309,26 +1299,25 @@ static void free_dentry (struct devfs_entry *de) ...@@ -1309,26 +1299,25 @@ static void free_dentry (struct devfs_entry *de)
* Returns %TRUE if devfsd or child, else %FALSE. * Returns %TRUE if devfsd or child, else %FALSE.
*/ */
static int is_devfsd_or_child (struct fs_info *fs_info) static int is_devfsd_or_child(struct fs_info *fs_info)
{ {
struct task_struct *p = current; struct task_struct *p = current;
if (p == fs_info->devfsd_task) return (TRUE);
if (process_group(p) == fs_info->devfsd_pgrp) return (TRUE);
read_lock(&tasklist_lock);
for ( ; p != &init_task; p = p->real_parent)
{
if (p == fs_info->devfsd_task) if (p == fs_info->devfsd_task)
{ return (TRUE);
read_unlock (&tasklist_lock); if (process_group(p) == fs_info->devfsd_pgrp)
return (TRUE);
read_lock(&tasklist_lock);
for (; p != &init_task; p = p->real_parent) {
if (p == fs_info->devfsd_task) {
read_unlock(&tasklist_lock);
return (TRUE); return (TRUE);
} }
} }
read_unlock (&tasklist_lock); read_unlock(&tasklist_lock);
return (FALSE); return (FALSE);
} /* End Function is_devfsd_or_child */ } /* End Function is_devfsd_or_child */
/** /**
* devfsd_queue_empty - Test if devfsd has work pending in its event queue. * devfsd_queue_empty - Test if devfsd has work pending in its event queue.
* @fs_info: The filesystem information. * @fs_info: The filesystem information.
...@@ -1336,12 +1325,11 @@ static int is_devfsd_or_child (struct fs_info *fs_info) ...@@ -1336,12 +1325,11 @@ static int is_devfsd_or_child (struct fs_info *fs_info)
* Returns %TRUE if the queue is empty, else %FALSE. * Returns %TRUE if the queue is empty, else %FALSE.
*/ */
static inline int devfsd_queue_empty (struct fs_info *fs_info) static inline int devfsd_queue_empty(struct fs_info *fs_info)
{ {
return (fs_info->devfsd_last_event) ? FALSE : TRUE; return (fs_info->devfsd_last_event) ? FALSE : TRUE;
} /* End Function devfsd_queue_empty */ } /* End Function devfsd_queue_empty */
/** /**
* wait_for_devfsd_finished - Wait for devfsd to finish processing its event queue. * wait_for_devfsd_finished - Wait for devfsd to finish processing its event queue.
* @fs_info: The filesystem information. * @fs_info: The filesystem information.
...@@ -1349,23 +1337,26 @@ static inline int devfsd_queue_empty (struct fs_info *fs_info) ...@@ -1349,23 +1337,26 @@ static inline int devfsd_queue_empty (struct fs_info *fs_info)
* Returns %TRUE if no more waiting will be required, else %FALSE. * Returns %TRUE if no more waiting will be required, else %FALSE.
*/ */
static int wait_for_devfsd_finished (struct fs_info *fs_info) static int wait_for_devfsd_finished(struct fs_info *fs_info)
{ {
DECLARE_WAITQUEUE (wait, current); DECLARE_WAITQUEUE(wait, current);
if (fs_info->devfsd_task == NULL) return (TRUE); if (fs_info->devfsd_task == NULL)
if (devfsd_queue_empty (fs_info) && fs_info->devfsd_sleeping) return TRUE; return (TRUE);
if ( is_devfsd_or_child (fs_info) ) return (FALSE); if (devfsd_queue_empty(fs_info) && fs_info->devfsd_sleeping)
set_current_state (TASK_UNINTERRUPTIBLE); return TRUE;
add_wait_queue (&fs_info->revalidate_wait_queue, &wait); if (is_devfsd_or_child(fs_info))
if (!devfsd_queue_empty (fs_info) || !fs_info->devfsd_sleeping) return (FALSE);
if (fs_info->devfsd_task) schedule (); set_current_state(TASK_UNINTERRUPTIBLE);
remove_wait_queue (&fs_info->revalidate_wait_queue, &wait); add_wait_queue(&fs_info->revalidate_wait_queue, &wait);
__set_current_state (TASK_RUNNING); if (!devfsd_queue_empty(fs_info) || !fs_info->devfsd_sleeping)
if (fs_info->devfsd_task)
schedule();
remove_wait_queue(&fs_info->revalidate_wait_queue, &wait);
__set_current_state(TASK_RUNNING);
return (TRUE); return (TRUE);
} /* End Function wait_for_devfsd_finished */ } /* End Function wait_for_devfsd_finished */
/** /**
* devfsd_notify_de - Notify the devfsd daemon of a change. * devfsd_notify_de - Notify the devfsd daemon of a change.
* @de: The devfs entry that has changed. This and all parent entries will * @de: The devfs entry that has changed. This and all parent entries will
...@@ -1379,36 +1370,38 @@ static int wait_for_devfsd_finished (struct fs_info *fs_info) ...@@ -1379,36 +1370,38 @@ static int wait_for_devfsd_finished (struct fs_info *fs_info)
* Returns %TRUE if an event was queued and devfsd woken up, else %FALSE. * Returns %TRUE if an event was queued and devfsd woken up, else %FALSE.
*/ */
static int devfsd_notify_de (struct devfs_entry *de, static int devfsd_notify_de(struct devfs_entry *de,
unsigned short type, umode_t mode, unsigned short type, umode_t mode,
uid_t uid, gid_t gid, struct fs_info *fs_info) uid_t uid, gid_t gid, struct fs_info *fs_info)
{ {
struct devfsd_buf_entry *entry; struct devfsd_buf_entry *entry;
struct devfs_entry *curr; struct devfs_entry *curr;
if ( !( fs_info->devfsd_event_mask & (1 << type) ) ) return (FALSE); if (!(fs_info->devfsd_event_mask & (1 << type)))
if ( ( entry = kmem_cache_alloc (devfsd_buf_cache, SLAB_KERNEL) ) == NULL ) return (FALSE);
{ if ((entry = kmem_cache_alloc(devfsd_buf_cache, SLAB_KERNEL)) == NULL) {
atomic_inc (&fs_info->devfsd_overrun_count); atomic_inc(&fs_info->devfsd_overrun_count);
return (FALSE); return (FALSE);
} }
for (curr = de; curr != NULL; curr = curr->parent) devfs_get (curr); for (curr = de; curr != NULL; curr = curr->parent)
devfs_get(curr);
entry->de = de; entry->de = de;
entry->type = type; entry->type = type;
entry->mode = mode; entry->mode = mode;
entry->uid = uid; entry->uid = uid;
entry->gid = gid; entry->gid = gid;
entry->next = NULL; entry->next = NULL;
spin_lock (&fs_info->devfsd_buffer_lock); spin_lock(&fs_info->devfsd_buffer_lock);
if (!fs_info->devfsd_first_event) fs_info->devfsd_first_event = entry; if (!fs_info->devfsd_first_event)
if (fs_info->devfsd_last_event) fs_info->devfsd_last_event->next = entry; fs_info->devfsd_first_event = entry;
if (fs_info->devfsd_last_event)
fs_info->devfsd_last_event->next = entry;
fs_info->devfsd_last_event = entry; fs_info->devfsd_last_event = entry;
spin_unlock (&fs_info->devfsd_buffer_lock); spin_unlock(&fs_info->devfsd_buffer_lock);
wake_up_interruptible (&fs_info->devfsd_wait_queue); wake_up_interruptible(&fs_info->devfsd_wait_queue);
return (TRUE); return (TRUE);
} /* End Function devfsd_notify_de */ } /* End Function devfsd_notify_de */
/** /**
* devfsd_notify - Notify the devfsd daemon of a change. * devfsd_notify - Notify the devfsd daemon of a change.
* @de: The devfs entry that has changed. * @de: The devfs entry that has changed.
...@@ -1417,7 +1410,7 @@ static int devfsd_notify_de (struct devfs_entry *de, ...@@ -1417,7 +1410,7 @@ static int devfsd_notify_de (struct devfs_entry *de,
* the event. * the event.
*/ */
static void devfsd_notify (struct devfs_entry *de,unsigned short type) static void devfsd_notify(struct devfs_entry *de, unsigned short type)
{ {
devfsd_notify_de(de, type, de->mode, current->euid, devfsd_notify_de(de, type, de->mode, current->euid,
current->egid, &fs_info); current->egid, &fs_info);
...@@ -1474,7 +1467,6 @@ int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...) ...@@ -1474,7 +1467,6 @@ int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
EXPORT_SYMBOL(devfs_mk_bdev); EXPORT_SYMBOL(devfs_mk_bdev);
int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...) int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
{ {
va_list args; va_list args;
...@@ -1491,7 +1483,6 @@ int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...) ...@@ -1491,7 +1483,6 @@ int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
EXPORT_SYMBOL(devfs_mk_cdev); EXPORT_SYMBOL(devfs_mk_cdev);
/** /**
* _devfs_unhook - Unhook a device entry from its parents list * _devfs_unhook - Unhook a device entry from its parents list
* @de: The entry to unhook. * @de: The entry to unhook.
...@@ -1501,22 +1492,26 @@ EXPORT_SYMBOL(devfs_mk_cdev); ...@@ -1501,22 +1492,26 @@ EXPORT_SYMBOL(devfs_mk_cdev);
* The caller must have a write lock on the parent directory. * The caller must have a write lock on the parent directory.
*/ */
static int _devfs_unhook (struct devfs_entry *de) static int _devfs_unhook(struct devfs_entry *de)
{ {
struct devfs_entry *parent; struct devfs_entry *parent;
if ( !de || (de->prev == de) ) return FALSE; if (!de || (de->prev == de))
return FALSE;
parent = de->parent; parent = de->parent;
if (de->prev == NULL) parent->u.dir.first = de->next; if (de->prev == NULL)
else de->prev->next = de->next; parent->u.dir.first = de->next;
if (de->next == NULL) parent->u.dir.last = de->prev; else
else de->next->prev = de->prev; de->prev->next = de->next;
if (de->next == NULL)
parent->u.dir.last = de->prev;
else
de->next->prev = de->prev;
de->prev = de; /* Indicate we're unhooked */ de->prev = de; /* Indicate we're unhooked */
de->next = NULL; /* Force early termination for <devfs_readdir> */ de->next = NULL; /* Force early termination for <devfs_readdir> */
return TRUE; return TRUE;
} /* End Function _devfs_unhook */ } /* End Function _devfs_unhook */
/** /**
* _devfs_unregister - Unregister a device entry from its parent. * _devfs_unregister - Unregister a device entry from its parent.
* @dir: The parent directory. * @dir: The parent directory.
...@@ -1526,84 +1521,84 @@ static int _devfs_unhook (struct devfs_entry *de) ...@@ -1526,84 +1521,84 @@ static int _devfs_unhook (struct devfs_entry *de)
* unlocked by this function. * unlocked by this function.
*/ */
static void _devfs_unregister (struct devfs_entry *dir, struct devfs_entry *de) static void _devfs_unregister(struct devfs_entry *dir, struct devfs_entry *de)
{ {
int unhooked = _devfs_unhook (de); int unhooked = _devfs_unhook(de);
write_unlock (&dir->u.dir.lock); write_unlock(&dir->u.dir.lock);
if (!unhooked) return; if (!unhooked)
devfs_get (dir); return;
devfsd_notify (de, DEVFSD_NOTIFY_UNREGISTERED); devfs_get(dir);
free_dentry (de); devfsd_notify(de, DEVFSD_NOTIFY_UNREGISTERED);
devfs_put (dir); free_dentry(de);
if ( !S_ISDIR (de->mode) ) return; devfs_put(dir);
while (TRUE) /* Recursively unregister: this is a stack chomper */ if (!S_ISDIR(de->mode))
{ return;
while (TRUE) { /* Recursively unregister: this is a stack chomper */
struct devfs_entry *child; struct devfs_entry *child;
write_lock (&de->u.dir.lock); write_lock(&de->u.dir.lock);
de->u.dir.no_more_additions = TRUE; de->u.dir.no_more_additions = TRUE;
child = de->u.dir.first; child = de->u.dir.first;
VERIFY_ENTRY (child); VERIFY_ENTRY(child);
_devfs_unregister (de, child); _devfs_unregister(de, child);
if (!child) break; if (!child)
DPRINTK (DEBUG_UNREGISTER, "(%s): child: %p refcount: %d\n", break;
child->name, child, atomic_read (&child->refcount) ); DPRINTK(DEBUG_UNREGISTER, "(%s): child: %p refcount: %d\n",
devfs_put (child); child->name, child, atomic_read(&child->refcount));
devfs_put(child);
} }
} /* End Function _devfs_unregister */ } /* End Function _devfs_unregister */
static int devfs_do_symlink (devfs_handle_t dir, const char *name, static int devfs_do_symlink(devfs_handle_t dir, const char *name,
const char *link, devfs_handle_t *handle) const char *link, devfs_handle_t * handle)
{ {
int err; int err;
unsigned int linklength; unsigned int linklength;
char *newlink; char *newlink;
struct devfs_entry *de; struct devfs_entry *de;
if (handle != NULL) *handle = NULL; if (handle != NULL)
if (name == NULL) *handle = NULL;
{ if (name == NULL) {
PRINTK ("(): NULL name pointer\n"); PRINTK("(): NULL name pointer\n");
return -EINVAL; return -EINVAL;
} }
if (link == NULL) if (link == NULL) {
{ PRINTK("(%s): NULL link pointer\n", name);
PRINTK ("(%s): NULL link pointer\n", name);
return -EINVAL; return -EINVAL;
} }
linklength = strlen (link); linklength = strlen(link);
if ( ( newlink = kmalloc (linklength + 1, GFP_KERNEL) ) == NULL ) if ((newlink = kmalloc(linklength + 1, GFP_KERNEL)) == NULL)
return -ENOMEM; return -ENOMEM;
memcpy (newlink, link, linklength); memcpy(newlink, link, linklength);
newlink[linklength] = '\0'; newlink[linklength] = '\0';
if ( ( de = _devfs_prepare_leaf (&dir, name, S_IFLNK | S_IRUGO | S_IXUGO) ) if ((de = _devfs_prepare_leaf(&dir, name, S_IFLNK | S_IRUGO | S_IXUGO))
== NULL ) == NULL) {
{ PRINTK("(%s): could not prepare leaf\n", name);
PRINTK ("(%s): could not prepare leaf\n", name); kfree(newlink);
kfree (newlink);
return -ENOTDIR; return -ENOTDIR;
} }
de->info = NULL; de->info = NULL;
de->u.symlink.linkname = newlink; de->u.symlink.linkname = newlink;
de->u.symlink.length = linklength; de->u.symlink.length = linklength;
if ( ( err = _devfs_append_entry (dir, de, NULL) ) != 0 ) if ((err = _devfs_append_entry(dir, de, NULL)) != 0) {
{ PRINTK("(%s): could not append to parent, err: %d\n", name,
PRINTK ("(%s): could not append to parent, err: %d\n", name, err); err);
devfs_put (dir); devfs_put(dir);
return err; return err;
} }
devfs_put (dir); devfs_put(dir);
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
spin_lock (&stat_lock); spin_lock(&stat_lock);
stat_num_bytes += linklength + 1; stat_num_bytes += linklength + 1;
spin_unlock (&stat_lock); spin_unlock(&stat_lock);
#endif #endif
if (handle != NULL) *handle = de; if (handle != NULL)
*handle = de;
return 0; return 0;
} /* End Function devfs_do_symlink */ } /* End Function devfs_do_symlink */
/** /**
* devfs_mk_symlink Create a symbolic link in the devfs namespace. * devfs_mk_symlink Create a symbolic link in the devfs namespace.
* @from: The name of the entry. * @from: The name of the entry.
...@@ -1626,7 +1621,6 @@ int devfs_mk_symlink(const char *from, const char *to) ...@@ -1626,7 +1621,6 @@ int devfs_mk_symlink(const char *from, const char *to)
return err; return err;
} }
/** /**
* devfs_mk_dir - Create a directory in the devfs namespace. * devfs_mk_dir - Create a directory in the devfs namespace.
* new name is relative to the root of the devfs. * new name is relative to the root of the devfs.
...@@ -1680,7 +1674,6 @@ int devfs_mk_dir(const char *fmt, ...) ...@@ -1680,7 +1674,6 @@ int devfs_mk_dir(const char *fmt, ...)
return error; return error;
} }
void devfs_remove(const char *fmt, ...) void devfs_remove(const char *fmt, ...)
{ {
char buf[64]; char buf[64];
...@@ -1706,7 +1699,6 @@ void devfs_remove(const char *fmt, ...) ...@@ -1706,7 +1699,6 @@ void devfs_remove(const char *fmt, ...)
} }
} }
/** /**
* devfs_generate_path - Generate a pathname for an entry, relative to the devfs root. * devfs_generate_path - Generate a pathname for an entry, relative to the devfs root.
* @de: The devfs entry. * @de: The devfs entry.
...@@ -1718,24 +1710,27 @@ void devfs_remove(const char *fmt, ...) ...@@ -1718,24 +1710,27 @@ void devfs_remove(const char *fmt, ...)
* else a negative error code. * else a negative error code.
*/ */
static int devfs_generate_path (devfs_handle_t de, char *path, int buflen) static int devfs_generate_path(devfs_handle_t de, char *path, int buflen)
{ {
int pos; int pos;
#define NAMEOF(de) ( (de)->mode ? (de)->name : (de)->u.name ) #define NAMEOF(de) ( (de)->mode ? (de)->name : (de)->u.name )
if (de == NULL) return -EINVAL; if (de == NULL)
VERIFY_ENTRY (de); return -EINVAL;
if (de->namelen >= buflen) return -ENAMETOOLONG; /* Must be first */ VERIFY_ENTRY(de);
if (de->namelen >= buflen)
return -ENAMETOOLONG; /* Must be first */
path[buflen - 1] = '\0'; path[buflen - 1] = '\0';
if (de->parent == NULL) return buflen - 1; /* Don't prepend root */ if (de->parent == NULL)
return buflen - 1; /* Don't prepend root */
pos = buflen - de->namelen - 1; pos = buflen - de->namelen - 1;
memcpy (path + pos, NAMEOF (de), de->namelen); memcpy(path + pos, NAMEOF(de), de->namelen);
for (de = de->parent; de->parent != NULL; de = de->parent) for (de = de->parent; de->parent != NULL; de = de->parent) {
{ if (pos - de->namelen - 1 < 0)
if (pos - de->namelen - 1 < 0) return -ENAMETOOLONG; return -ENAMETOOLONG;
path[--pos] = '/'; path[--pos] = '/';
pos -= de->namelen; pos -= de->namelen;
memcpy (path + pos, NAMEOF (de), de->namelen); memcpy(path + pos, NAMEOF(de), de->namelen);
} }
return pos; return pos;
} /* End Function devfs_generate_path */ } /* End Function devfs_generate_path */
...@@ -1745,59 +1740,59 @@ static int devfs_generate_path (devfs_handle_t de, char *path, int buflen) ...@@ -1745,59 +1740,59 @@ static int devfs_generate_path (devfs_handle_t de, char *path, int buflen)
* @str: The boot options after the "devfs=". * @str: The boot options after the "devfs=".
*/ */
static int __init devfs_setup (char *str) static int __init devfs_setup(char *str)
{ {
static struct static struct {
{
char *name; char *name;
unsigned int mask; unsigned int mask;
unsigned int *opt; unsigned int *opt;
} devfs_options_tab[] __initdata = } devfs_options_tab[] __initdata = {
{
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
{"dall", DEBUG_ALL, &devfs_debug_init}, {
{"dmod", DEBUG_MODULE_LOAD, &devfs_debug_init}, "dall", DEBUG_ALL, &devfs_debug_init}, {
{"dreg", DEBUG_REGISTER, &devfs_debug_init}, "dmod", DEBUG_MODULE_LOAD, &devfs_debug_init}, {
{"dunreg", DEBUG_UNREGISTER, &devfs_debug_init}, "dreg", DEBUG_REGISTER, &devfs_debug_init}, {
{"dfree", DEBUG_FREE, &devfs_debug_init}, "dunreg", DEBUG_UNREGISTER, &devfs_debug_init}, {
{"diget", DEBUG_I_GET, &devfs_debug_init}, "dfree", DEBUG_FREE, &devfs_debug_init}, {
{"dchange", DEBUG_SET_FLAGS, &devfs_debug_init}, "diget", DEBUG_I_GET, &devfs_debug_init}, {
{"dsread", DEBUG_S_READ, &devfs_debug_init}, "dchange", DEBUG_SET_FLAGS, &devfs_debug_init}, {
{"dichange", DEBUG_I_CHANGE, &devfs_debug_init}, "dsread", DEBUG_S_READ, &devfs_debug_init}, {
{"dimknod", DEBUG_I_MKNOD, &devfs_debug_init}, "dichange", DEBUG_I_CHANGE, &devfs_debug_init}, {
{"dilookup", DEBUG_I_LOOKUP, &devfs_debug_init}, "dimknod", DEBUG_I_MKNOD, &devfs_debug_init}, {
{"diunlink", DEBUG_I_UNLINK, &devfs_debug_init}, "dilookup", DEBUG_I_LOOKUP, &devfs_debug_init}, {
"diunlink", DEBUG_I_UNLINK, &devfs_debug_init},
#endif /* CONFIG_DEVFS_DEBUG */ #endif /* CONFIG_DEVFS_DEBUG */
{"mount", OPTION_MOUNT, &boot_options}, {
{NULL, 0, NULL} "mount", OPTION_MOUNT, &boot_options}, {
NULL, 0, NULL}
}; };
while ( (*str != '\0') && !isspace (*str) ) while ((*str != '\0') && !isspace(*str)) {
{
int i, found = 0, invert = 0; int i, found = 0, invert = 0;
if (strncmp (str, "no", 2) == 0) if (strncmp(str, "no", 2) == 0) {
{
invert = 1; invert = 1;
str += 2; str += 2;
} }
for (i = 0; devfs_options_tab[i].name != NULL; i++) for (i = 0; devfs_options_tab[i].name != NULL; i++) {
{ int len = strlen(devfs_options_tab[i].name);
int len = strlen (devfs_options_tab[i].name);
if (strncmp (str, devfs_options_tab[i].name, len) == 0) if (strncmp(str, devfs_options_tab[i].name, len) == 0) {
{
if (invert) if (invert)
*devfs_options_tab[i].opt &= ~devfs_options_tab[i].mask; *devfs_options_tab[i].opt &=
~devfs_options_tab[i].mask;
else else
*devfs_options_tab[i].opt |= devfs_options_tab[i].mask; *devfs_options_tab[i].opt |=
devfs_options_tab[i].mask;
str += len; str += len;
found = 1; found = 1;
break; break;
} }
} }
if (!found) return 0; /* No match */ if (!found)
if (*str != ',') return 0; /* No more options */ return 0; /* No match */
if (*str != ',')
return 0; /* No more options */
++str; ++str;
} }
return 1; return 1;
...@@ -1809,7 +1804,6 @@ EXPORT_SYMBOL(devfs_mk_symlink); ...@@ -1809,7 +1804,6 @@ EXPORT_SYMBOL(devfs_mk_symlink);
EXPORT_SYMBOL(devfs_mk_dir); EXPORT_SYMBOL(devfs_mk_dir);
EXPORT_SYMBOL(devfs_remove); EXPORT_SYMBOL(devfs_remove);
/** /**
* try_modload - Notify devfsd of an inode lookup by a non-devfsd process. * try_modload - Notify devfsd of an inode lookup by a non-devfsd process.
* @parent: The parent devfs entry. * @parent: The parent devfs entry.
...@@ -1822,27 +1816,27 @@ EXPORT_SYMBOL(devfs_remove); ...@@ -1822,27 +1816,27 @@ EXPORT_SYMBOL(devfs_remove);
* Returns 0 on success (event was queued), else a negative error code. * Returns 0 on success (event was queued), else a negative error code.
*/ */
static int try_modload (struct devfs_entry *parent, struct fs_info *fs_info, static int try_modload(struct devfs_entry *parent, struct fs_info *fs_info,
const char *name, unsigned namelen, const char *name, unsigned namelen,
struct devfs_entry *buf) struct devfs_entry *buf)
{ {
if ( !( fs_info->devfsd_event_mask & (1 << DEVFSD_NOTIFY_LOOKUP) ) ) if (!(fs_info->devfsd_event_mask & (1 << DEVFSD_NOTIFY_LOOKUP)))
return -ENOENT;
if (is_devfsd_or_child(fs_info))
return -ENOENT; return -ENOENT;
if ( is_devfsd_or_child (fs_info) ) return -ENOENT; memset(buf, 0, sizeof *buf);
memset (buf, 0, sizeof *buf); atomic_set(&buf->refcount, 1);
atomic_set (&buf->refcount, 1);
buf->parent = parent; buf->parent = parent;
buf->namelen = namelen; buf->namelen = namelen;
buf->u.name = name; buf->u.name = name;
WRITE_ENTRY_MAGIC (buf, MAGIC_VALUE); WRITE_ENTRY_MAGIC(buf, MAGIC_VALUE);
if ( !devfsd_notify_de (buf, DEVFSD_NOTIFY_LOOKUP, 0, if (!devfsd_notify_de(buf, DEVFSD_NOTIFY_LOOKUP, 0,
current->euid, current->egid, fs_info) ) current->euid, current->egid, fs_info))
return -ENOENT; return -ENOENT;
/* Possible success: event has been queued */ /* Possible success: event has been queued */
return 0; return 0;
} /* End Function try_modload */ } /* End Function try_modload */
/* Superblock operations follow */ /* Superblock operations follow */
static struct inode_operations devfs_iops; static struct inode_operations devfs_iops;
...@@ -1851,23 +1845,26 @@ static struct file_operations devfs_fops; ...@@ -1851,23 +1845,26 @@ static struct file_operations devfs_fops;
static struct file_operations devfs_dir_fops; static struct file_operations devfs_dir_fops;
static struct inode_operations devfs_symlink_iops; static struct inode_operations devfs_symlink_iops;
static int devfs_notify_change (struct dentry *dentry, struct iattr *iattr) static int devfs_notify_change(struct dentry *dentry, struct iattr *iattr)
{ {
int retval; int retval;
struct devfs_entry *de; struct devfs_entry *de;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct fs_info *fs_info = inode->i_sb->s_fs_info; struct fs_info *fs_info = inode->i_sb->s_fs_info;
de = get_devfs_entry_from_vfs_inode (inode); de = get_devfs_entry_from_vfs_inode(inode);
if (de == NULL) return -ENODEV; if (de == NULL)
retval = inode_change_ok (inode, iattr); return -ENODEV;
if (retval != 0) return retval; retval = inode_change_ok(inode, iattr);
retval = inode_setattr (inode, iattr); if (retval != 0)
if (retval != 0) return retval; return retval;
DPRINTK (DEBUG_I_CHANGE, "(%d): VFS inode: %p devfs_entry: %p\n", retval = inode_setattr(inode, iattr);
(int) inode->i_ino, inode, de); if (retval != 0)
DPRINTK (DEBUG_I_CHANGE, "(): mode: 0%o uid: %d gid: %d\n", return retval;
(int) inode->i_mode, (int) inode->i_uid, (int) inode->i_gid); DPRINTK(DEBUG_I_CHANGE, "(%d): VFS inode: %p devfs_entry: %p\n",
(int)inode->i_ino, inode, de);
DPRINTK(DEBUG_I_CHANGE, "(): mode: 0%o uid: %d gid: %d\n",
(int)inode->i_mode, (int)inode->i_uid, (int)inode->i_gid);
/* Inode is not on hash chains, thus must save permissions here rather /* Inode is not on hash chains, thus must save permissions here rather
than in a write_inode() method */ than in a write_inode() method */
de->mode = inode->i_mode; de->mode = inode->i_mode;
...@@ -1876,20 +1873,18 @@ static int devfs_notify_change (struct dentry *dentry, struct iattr *iattr) ...@@ -1876,20 +1873,18 @@ static int devfs_notify_change (struct dentry *dentry, struct iattr *iattr)
de->inode.atime = inode->i_atime; de->inode.atime = inode->i_atime;
de->inode.mtime = inode->i_mtime; de->inode.mtime = inode->i_mtime;
de->inode.ctime = inode->i_ctime; de->inode.ctime = inode->i_ctime;
if ( ( iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID) ) && if ((iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID)) &&
!is_devfsd_or_child (fs_info) ) !is_devfsd_or_child(fs_info))
devfsd_notify_de (de, DEVFSD_NOTIFY_CHANGE, inode->i_mode, devfsd_notify_de(de, DEVFSD_NOTIFY_CHANGE, inode->i_mode,
inode->i_uid, inode->i_gid, fs_info); inode->i_uid, inode->i_gid, fs_info);
return 0; return 0;
} /* End Function devfs_notify_change */ } /* End Function devfs_notify_change */
static struct super_operations devfs_sops = static struct super_operations devfs_sops = {
{
.drop_inode = generic_delete_inode, .drop_inode = generic_delete_inode,
.statfs = simple_statfs, .statfs = simple_statfs,
}; };
/** /**
* _devfs_get_vfs_inode - Get a VFS inode. * _devfs_get_vfs_inode - Get a VFS inode.
* @sb: The super block. * @sb: The super block.
...@@ -1900,35 +1895,34 @@ static struct super_operations devfs_sops = ...@@ -1900,35 +1895,34 @@ static struct super_operations devfs_sops =
* performed if the inode is created. * performed if the inode is created.
*/ */
static struct inode *_devfs_get_vfs_inode (struct super_block *sb, static struct inode *_devfs_get_vfs_inode(struct super_block *sb,
struct devfs_entry *de, struct devfs_entry *de,
struct dentry *dentry) struct dentry *dentry)
{ {
struct inode *inode; struct inode *inode;
if (de->prev == de) return NULL; /* Quick check to see if unhooked */ if (de->prev == de)
if ( ( inode = new_inode (sb) ) == NULL ) return NULL; /* Quick check to see if unhooked */
{ if ((inode = new_inode(sb)) == NULL) {
PRINTK ("(%s): new_inode() failed, de: %p\n", de->name, de); PRINTK("(%s): new_inode() failed, de: %p\n", de->name, de);
return NULL; return NULL;
} }
if (de->parent) if (de->parent) {
{ read_lock(&de->parent->u.dir.lock);
read_lock (&de->parent->u.dir.lock); if (de->prev != de)
if (de->prev != de) de->inode.dentry = dentry; /* Not unhooked */ de->inode.dentry = dentry; /* Not unhooked */
read_unlock (&de->parent->u.dir.lock); read_unlock(&de->parent->u.dir.lock);
} } else
else de->inode.dentry = dentry; /* Root: no locking needed */ de->inode.dentry = dentry; /* Root: no locking needed */
if (de->inode.dentry != dentry) if (de->inode.dentry != dentry) { /* Must have been unhooked */
{ /* Must have been unhooked */ iput(inode);
iput (inode);
return NULL; return NULL;
} }
/* FIXME where is devfs_put? */ /* FIXME where is devfs_put? */
inode->u.generic_ip = devfs_get (de); inode->u.generic_ip = devfs_get(de);
inode->i_ino = de->inode.ino; inode->i_ino = de->inode.ino;
DPRINTK (DEBUG_I_GET, "(%d): VFS inode: %p devfs_entry: %p\n", DPRINTK(DEBUG_I_GET, "(%d): VFS inode: %p devfs_entry: %p\n",
(int) inode->i_ino, inode, de); (int)inode->i_ino, inode, de);
inode->i_blocks = 0; inode->i_blocks = 0;
inode->i_blksize = FAKE_BLOCK_SIZE; inode->i_blksize = FAKE_BLOCK_SIZE;
inode->i_op = &devfs_iops; inode->i_op = &devfs_iops;
...@@ -1956,15 +1950,14 @@ static struct inode *_devfs_get_vfs_inode (struct super_block *sb, ...@@ -1956,15 +1950,14 @@ static struct inode *_devfs_get_vfs_inode (struct super_block *sb,
inode->i_atime = de->inode.atime; inode->i_atime = de->inode.atime;
inode->i_mtime = de->inode.mtime; inode->i_mtime = de->inode.mtime;
inode->i_ctime = de->inode.ctime; inode->i_ctime = de->inode.ctime;
DPRINTK (DEBUG_I_GET, "(): mode: 0%o uid: %d gid: %d\n", DPRINTK(DEBUG_I_GET, "(): mode: 0%o uid: %d gid: %d\n",
(int) inode->i_mode, (int) inode->i_uid, (int) inode->i_gid); (int)inode->i_mode, (int)inode->i_uid, (int)inode->i_gid);
return inode; return inode;
} /* End Function _devfs_get_vfs_inode */ } /* End Function _devfs_get_vfs_inode */
/* File operations for device entries follow */ /* File operations for device entries follow */
static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir) static int devfs_readdir(struct file *file, void *dirent, filldir_t filldir)
{ {
int err, count; int err, count;
int stored = 0; int stored = 0;
...@@ -1973,52 +1966,60 @@ static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir) ...@@ -1973,52 +1966,60 @@ static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir)
struct inode *inode = file->f_dentry->d_inode; struct inode *inode = file->f_dentry->d_inode;
fs_info = inode->i_sb->s_fs_info; fs_info = inode->i_sb->s_fs_info;
parent = get_devfs_entry_from_vfs_inode (file->f_dentry->d_inode); parent = get_devfs_entry_from_vfs_inode(file->f_dentry->d_inode);
if ( (long) file->f_pos < 0 ) return -EINVAL; if ((long)file->f_pos < 0)
DPRINTK (DEBUG_F_READDIR, "(%s): fs_info: %p pos: %ld\n", return -EINVAL;
parent->name, fs_info, (long) file->f_pos); DPRINTK(DEBUG_F_READDIR, "(%s): fs_info: %p pos: %ld\n",
switch ( (long) file->f_pos ) parent->name, fs_info, (long)file->f_pos);
{ switch ((long)file->f_pos) {
case 0: case 0:
err = (*filldir) (dirent, "..", 2, file->f_pos, err = (*filldir) (dirent, "..", 2, file->f_pos,
parent_ino (file->f_dentry), DT_DIR); parent_ino(file->f_dentry), DT_DIR);
if (err == -EINVAL) break; if (err == -EINVAL)
if (err < 0) return err; break;
if (err < 0)
return err;
file->f_pos++; file->f_pos++;
++stored; ++stored;
/* Fall through */ /* Fall through */
case 1: case 1:
err = (*filldir) (dirent, ".", 1, file->f_pos, inode->i_ino, DT_DIR); err =
if (err == -EINVAL) break; (*filldir) (dirent, ".", 1, file->f_pos, inode->i_ino,
if (err < 0) return err; DT_DIR);
if (err == -EINVAL)
break;
if (err < 0)
return err;
file->f_pos++; file->f_pos++;
++stored; ++stored;
/* Fall through */ /* Fall through */
default: default:
/* Skip entries */ /* Skip entries */
count = file->f_pos - 2; count = file->f_pos - 2;
read_lock (&parent->u.dir.lock); read_lock(&parent->u.dir.lock);
for (de = parent->u.dir.first; de && (count > 0); de = de->next) for (de = parent->u.dir.first; de && (count > 0); de = de->next)
--count; --count;
devfs_get (de); devfs_get(de);
read_unlock (&parent->u.dir.lock); read_unlock(&parent->u.dir.lock);
/* Now add all remaining entries */ /* Now add all remaining entries */
while (de) while (de) {
{
err = (*filldir) (dirent, de->name, de->namelen, err = (*filldir) (dirent, de->name, de->namelen,
file->f_pos, de->inode.ino, de->mode >> 12); file->f_pos, de->inode.ino,
if (err < 0) devfs_put (de); de->mode >> 12);
else if (err < 0)
{ devfs_put(de);
else {
file->f_pos++; file->f_pos++;
++stored; ++stored;
} }
if (err == -EINVAL) break; if (err == -EINVAL)
if (err < 0) return err; break;
read_lock (&parent->u.dir.lock); if (err < 0)
next = devfs_get (de->next); return err;
read_unlock (&parent->u.dir.lock); read_lock(&parent->u.dir.lock);
devfs_put (de); next = devfs_get(de->next);
read_unlock(&parent->u.dir.lock);
devfs_put(de);
de = next; de = next;
} }
break; break;
...@@ -2027,7 +2028,7 @@ static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir) ...@@ -2027,7 +2028,7 @@ static int devfs_readdir (struct file *file, void *dirent, filldir_t filldir)
} /* End Function devfs_readdir */ } /* End Function devfs_readdir */
/* Open devfs specific special files */ /* Open devfs specific special files */
static int devfs_open (struct inode *inode, struct file *file) static int devfs_open(struct inode *inode, struct file *file)
{ {
int err; int err;
int minor = MINOR(inode->i_rdev); int minor = MINOR(inode->i_rdev);
...@@ -2059,29 +2060,25 @@ static int devfs_open (struct inode *inode, struct file *file) ...@@ -2059,29 +2060,25 @@ static int devfs_open (struct inode *inode, struct file *file)
return err; return err;
} /* End Function devfs_open */ } /* End Function devfs_open */
static struct file_operations devfs_fops = static struct file_operations devfs_fops = {
{
.open = devfs_open, .open = devfs_open,
}; };
static struct file_operations devfs_dir_fops = static struct file_operations devfs_dir_fops = {
{
.read = generic_read_dir, .read = generic_read_dir,
.readdir = devfs_readdir, .readdir = devfs_readdir,
}; };
/* Dentry operations for device entries follow */ /* Dentry operations for device entries follow */
/** /**
* devfs_d_release - Callback for when a dentry is freed. * devfs_d_release - Callback for when a dentry is freed.
* @dentry: The dentry. * @dentry: The dentry.
*/ */
static void devfs_d_release (struct dentry *dentry) static void devfs_d_release(struct dentry *dentry)
{ {
DPRINTK (DEBUG_D_RELEASE, "(%p): inode: %p\n", dentry, dentry->d_inode); DPRINTK(DEBUG_D_RELEASE, "(%p): inode: %p\n", dentry, dentry->d_inode);
} /* End Function devfs_d_release */ } /* End Function devfs_d_release */
/** /**
...@@ -2090,34 +2087,33 @@ static void devfs_d_release (struct dentry *dentry) ...@@ -2090,34 +2087,33 @@ static void devfs_d_release (struct dentry *dentry)
* @inode: The inode. * @inode: The inode.
*/ */
static void devfs_d_iput (struct dentry *dentry, struct inode *inode) static void devfs_d_iput(struct dentry *dentry, struct inode *inode)
{ {
struct devfs_entry *de; struct devfs_entry *de;
de = get_devfs_entry_from_vfs_inode (inode); de = get_devfs_entry_from_vfs_inode(inode);
DPRINTK (DEBUG_D_IPUT,"(%s): dentry: %p inode: %p de: %p de->dentry: %p\n", DPRINTK(DEBUG_D_IPUT,
de->name, dentry, inode, de, de->inode.dentry); "(%s): dentry: %p inode: %p de: %p de->dentry: %p\n", de->name,
if ( de->inode.dentry && (de->inode.dentry != dentry) ) dentry, inode, de, de->inode.dentry);
OOPS ("(%s): de: %p dentry: %p de->dentry: %p\n", if (de->inode.dentry && (de->inode.dentry != dentry))
OOPS("(%s): de: %p dentry: %p de->dentry: %p\n",
de->name, de, dentry, de->inode.dentry); de->name, de, dentry, de->inode.dentry);
de->inode.dentry = NULL; de->inode.dentry = NULL;
iput (inode); iput(inode);
devfs_put (de); devfs_put(de);
} /* End Function devfs_d_iput */ } /* End Function devfs_d_iput */
static int devfs_d_delete (struct dentry *dentry); static int devfs_d_delete(struct dentry *dentry);
static struct dentry_operations devfs_dops = static struct dentry_operations devfs_dops = {
{
.d_delete = devfs_d_delete, .d_delete = devfs_d_delete,
.d_release = devfs_d_release, .d_release = devfs_d_release,
.d_iput = devfs_d_iput, .d_iput = devfs_d_iput,
}; };
static int devfs_d_revalidate_wait (struct dentry *dentry, struct nameidata *); static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *);
static struct dentry_operations devfs_wait_dops = static struct dentry_operations devfs_wait_dops = {
{
.d_delete = devfs_d_delete, .d_delete = devfs_d_delete,
.d_release = devfs_d_release, .d_release = devfs_d_release,
.d_iput = devfs_d_iput, .d_iput = devfs_d_iput,
...@@ -2129,35 +2125,35 @@ static struct dentry_operations devfs_wait_dops = ...@@ -2129,35 +2125,35 @@ static struct dentry_operations devfs_wait_dops =
* @dentry: The dentry. * @dentry: The dentry.
*/ */
static int devfs_d_delete (struct dentry *dentry) static int devfs_d_delete(struct dentry *dentry)
{ {
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
if (dentry->d_op == &devfs_wait_dops) dentry->d_op = &devfs_dops; if (dentry->d_op == &devfs_wait_dops)
dentry->d_op = &devfs_dops;
/* Unhash dentry if negative (has no inode) */ /* Unhash dentry if negative (has no inode) */
if (inode == NULL) if (inode == NULL) {
{ DPRINTK(DEBUG_D_DELETE, "(%p): dropping negative dentry\n",
DPRINTK (DEBUG_D_DELETE, "(%p): dropping negative dentry\n", dentry); dentry);
return 1; return 1;
} }
return 0; return 0;
} /* End Function devfs_d_delete */ } /* End Function devfs_d_delete */
struct devfs_lookup_struct struct devfs_lookup_struct {
{
devfs_handle_t de; devfs_handle_t de;
wait_queue_head_t wait_queue; wait_queue_head_t wait_queue;
}; };
/* XXX: this doesn't handle the case where we got a negative dentry /* XXX: this doesn't handle the case where we got a negative dentry
but a devfs entry has been registered in the meanwhile */ but a devfs entry has been registered in the meanwhile */
static int devfs_d_revalidate_wait (struct dentry *dentry, struct nameidata *nd) static int devfs_d_revalidate_wait(struct dentry *dentry, struct nameidata *nd)
{ {
struct inode *dir = dentry->d_parent->d_inode; struct inode *dir = dentry->d_parent->d_inode;
struct fs_info *fs_info = dir->i_sb->s_fs_info; struct fs_info *fs_info = dir->i_sb->s_fs_info;
devfs_handle_t parent = get_devfs_entry_from_vfs_inode (dir); devfs_handle_t parent = get_devfs_entry_from_vfs_inode(dir);
struct devfs_lookup_struct *lookup_info = dentry->d_fsdata; struct devfs_lookup_struct *lookup_info = dentry->d_fsdata;
DECLARE_WAITQUEUE (wait, current); DECLARE_WAITQUEUE(wait, current);
int need_lock; int need_lock;
/* /*
...@@ -2187,48 +2183,45 @@ static int devfs_d_revalidate_wait (struct dentry *dentry, struct nameidata *nd) ...@@ -2187,48 +2183,45 @@ static int devfs_d_revalidate_wait (struct dentry *dentry, struct nameidata *nd)
if (need_lock) if (need_lock)
down(&dir->i_sem); down(&dir->i_sem);
if ( is_devfsd_or_child (fs_info) ) if (is_devfsd_or_child(fs_info)) {
{
devfs_handle_t de = lookup_info->de; devfs_handle_t de = lookup_info->de;
struct inode *inode; struct inode *inode;
DPRINTK (DEBUG_I_LOOKUP, DPRINTK(DEBUG_I_LOOKUP,
"(%s): dentry: %p inode: %p de: %p by: \"%s\"\n", "(%s): dentry: %p inode: %p de: %p by: \"%s\"\n",
dentry->d_name.name, dentry, dentry->d_inode, de, dentry->d_name.name, dentry, dentry->d_inode, de,
current->comm); current->comm);
if (dentry->d_inode) if (dentry->d_inode)
goto out; goto out;
if (de == NULL) if (de == NULL) {
{ read_lock(&parent->u.dir.lock);
read_lock (&parent->u.dir.lock); de = _devfs_search_dir(parent, dentry->d_name.name,
de = _devfs_search_dir (parent, dentry->d_name.name,
dentry->d_name.len); dentry->d_name.len);
read_unlock (&parent->u.dir.lock); read_unlock(&parent->u.dir.lock);
if (de == NULL) if (de == NULL)
goto out; goto out;
lookup_info->de = de; lookup_info->de = de;
} }
/* Create an inode, now that the driver information is available */ /* Create an inode, now that the driver information is available */
inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry); inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry);
if (!inode) if (!inode)
goto out; goto out;
DPRINTK (DEBUG_I_LOOKUP, DPRINTK(DEBUG_I_LOOKUP,
"(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n", "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n",
de->name, de->inode.ino, inode, de, current->comm); de->name, de->inode.ino, inode, de, current->comm);
d_instantiate (dentry, inode); d_instantiate(dentry, inode);
goto out; goto out;
} }
if (lookup_info == NULL) if (lookup_info == NULL)
goto out; /* Early termination */ goto out; /* Early termination */
read_lock (&parent->u.dir.lock); read_lock(&parent->u.dir.lock);
if (dentry->d_fsdata) if (dentry->d_fsdata) {
{ set_current_state(TASK_UNINTERRUPTIBLE);
set_current_state (TASK_UNINTERRUPTIBLE); add_wait_queue(&lookup_info->wait_queue, &wait);
add_wait_queue (&lookup_info->wait_queue, &wait); read_unlock(&parent->u.dir.lock);
read_unlock (&parent->u.dir.lock);
/* at this point it is always (hopefully) locked */ /* at this point it is always (hopefully) locked */
up(&dir->i_sem); up(&dir->i_sem);
schedule (); schedule();
down(&dir->i_sem); down(&dir->i_sem);
/* /*
* This does not need nor should remove wait from wait_queue. * This does not need nor should remove wait from wait_queue.
...@@ -2239,19 +2232,19 @@ static int devfs_d_revalidate_wait (struct dentry *dentry, struct nameidata *nd) ...@@ -2239,19 +2232,19 @@ static int devfs_d_revalidate_wait (struct dentry *dentry, struct nameidata *nd)
* at this point is buggy. * at this point is buggy.
*/ */
} } else
else read_unlock (&parent->u.dir.lock); read_unlock(&parent->u.dir.lock);
out: out:
if (need_lock) if (need_lock)
up(&dir->i_sem); up(&dir->i_sem);
return 1; return 1;
} /* End Function devfs_d_revalidate_wait */ } /* End Function devfs_d_revalidate_wait */
/* Inode operations for device entries follow */ /* Inode operations for device entries follow */
static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry, struct nameidata *nd) static struct dentry *devfs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{ {
struct devfs_entry tmp; /* Must stay in scope until devfsd idle again */ struct devfs_entry tmp; /* Must stay in scope until devfsd idle again */
struct devfs_lookup_struct lookup_info; struct devfs_lookup_struct lookup_info;
...@@ -2264,94 +2257,96 @@ static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry, st ...@@ -2264,94 +2257,96 @@ static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry, st
up on any error */ up on any error */
dentry->d_op = &devfs_dops; dentry->d_op = &devfs_dops;
/* First try to get the devfs entry for this directory */ /* First try to get the devfs entry for this directory */
parent = get_devfs_entry_from_vfs_inode (dir); parent = get_devfs_entry_from_vfs_inode(dir);
DPRINTK (DEBUG_I_LOOKUP, "(%s): dentry: %p parent: %p by: \"%s\"\n", DPRINTK(DEBUG_I_LOOKUP, "(%s): dentry: %p parent: %p by: \"%s\"\n",
dentry->d_name.name, dentry, parent, current->comm); dentry->d_name.name, dentry, parent, current->comm);
if (parent == NULL) return ERR_PTR (-ENOENT); if (parent == NULL)
read_lock (&parent->u.dir.lock); return ERR_PTR(-ENOENT);
de = _devfs_search_dir (parent, dentry->d_name.name, dentry->d_name.len); read_lock(&parent->u.dir.lock);
read_unlock (&parent->u.dir.lock); de = _devfs_search_dir(parent, dentry->d_name.name, dentry->d_name.len);
read_unlock(&parent->u.dir.lock);
lookup_info.de = de; lookup_info.de = de;
init_waitqueue_head (&lookup_info.wait_queue); init_waitqueue_head(&lookup_info.wait_queue);
dentry->d_fsdata = &lookup_info; dentry->d_fsdata = &lookup_info;
if (de == NULL) if (de == NULL) { /* Try with devfsd. For any kind of failure, leave a negative dentry
{ /* Try with devfsd. For any kind of failure, leave a negative dentry
so someone else can deal with it (in the case where the sysadmin so someone else can deal with it (in the case where the sysadmin
does a mknod()). It's important to do this before hashing the does a mknod()). It's important to do this before hashing the
dentry, so that the devfsd queue is filled before revalidates dentry, so that the devfsd queue is filled before revalidates
can start */ can start */
if (try_modload (parent, fs_info, if (try_modload(parent, fs_info, dentry->d_name.name, dentry->d_name.len, &tmp) < 0) { /* Lookup event was not queued to devfsd */
dentry->d_name.name, dentry->d_name.len, &tmp) < 0) d_add(dentry, NULL);
{ /* Lookup event was not queued to devfsd */
d_add (dentry, NULL);
return NULL; return NULL;
} }
} }
dentry->d_op = &devfs_wait_dops; dentry->d_op = &devfs_wait_dops;
d_add (dentry, NULL); /* Open the floodgates */ d_add(dentry, NULL); /* Open the floodgates */
/* Unlock directory semaphore, which will release any waiters. They /* Unlock directory semaphore, which will release any waiters. They
will get the hashed dentry, and may be forced to wait for will get the hashed dentry, and may be forced to wait for
revalidation */ revalidation */
up (&dir->i_sem); up(&dir->i_sem);
wait_for_devfsd_finished (fs_info); /* If I'm not devfsd, must wait */ wait_for_devfsd_finished(fs_info); /* If I'm not devfsd, must wait */
down (&dir->i_sem); /* Grab it again because them's the rules */ down(&dir->i_sem); /* Grab it again because them's the rules */
de = lookup_info.de; de = lookup_info.de;
/* If someone else has been so kind as to make the inode, we go home /* If someone else has been so kind as to make the inode, we go home
early */ early */
if (dentry->d_inode) goto out; if (dentry->d_inode)
if (de == NULL) goto out;
{ if (de == NULL) {
read_lock (&parent->u.dir.lock); read_lock(&parent->u.dir.lock);
de = _devfs_search_dir (parent, dentry->d_name.name, de = _devfs_search_dir(parent, dentry->d_name.name,
dentry->d_name.len); dentry->d_name.len);
read_unlock (&parent->u.dir.lock); read_unlock(&parent->u.dir.lock);
if (de == NULL) goto out; if (de == NULL)
goto out;
/* OK, there's an entry now, but no VFS inode yet */ /* OK, there's an entry now, but no VFS inode yet */
} }
/* Create an inode, now that the driver information is available */ /* Create an inode, now that the driver information is available */
inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry); inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry);
if (!inode) if (!inode) {
{ retval = ERR_PTR(-ENOMEM);
retval = ERR_PTR (-ENOMEM);
goto out; goto out;
} }
DPRINTK (DEBUG_I_LOOKUP, "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n", DPRINTK(DEBUG_I_LOOKUP,
de->name, de->inode.ino, inode, de, current->comm); "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n", de->name,
d_instantiate (dentry, inode); de->inode.ino, inode, de, current->comm);
out: d_instantiate(dentry, inode);
write_lock (&parent->u.dir.lock); out:
write_lock(&parent->u.dir.lock);
dentry->d_op = &devfs_dops; dentry->d_op = &devfs_dops;
dentry->d_fsdata = NULL; dentry->d_fsdata = NULL;
wake_up (&lookup_info.wait_queue); wake_up(&lookup_info.wait_queue);
write_unlock (&parent->u.dir.lock); write_unlock(&parent->u.dir.lock);
devfs_put (de); devfs_put(de);
return retval; return retval;
} /* End Function devfs_lookup */ } /* End Function devfs_lookup */
static int devfs_unlink (struct inode *dir, struct dentry *dentry) static int devfs_unlink(struct inode *dir, struct dentry *dentry)
{ {
int unhooked; int unhooked;
struct devfs_entry *de; struct devfs_entry *de;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
struct fs_info *fs_info = dir->i_sb->s_fs_info; struct fs_info *fs_info = dir->i_sb->s_fs_info;
de = get_devfs_entry_from_vfs_inode (inode); de = get_devfs_entry_from_vfs_inode(inode);
DPRINTK (DEBUG_I_UNLINK, "(%s): de: %p\n", dentry->d_name.name, de); DPRINTK(DEBUG_I_UNLINK, "(%s): de: %p\n", dentry->d_name.name, de);
if (de == NULL) return -ENOENT; if (de == NULL)
if (!de->vfs) return -EPERM; return -ENOENT;
write_lock (&de->parent->u.dir.lock); if (!de->vfs)
unhooked = _devfs_unhook (de); return -EPERM;
write_unlock (&de->parent->u.dir.lock); write_lock(&de->parent->u.dir.lock);
if (!unhooked) return -ENOENT; unhooked = _devfs_unhook(de);
if ( !is_devfsd_or_child (fs_info) ) write_unlock(&de->parent->u.dir.lock);
devfsd_notify_de (de, DEVFSD_NOTIFY_DELETE, inode->i_mode, if (!unhooked)
return -ENOENT;
if (!is_devfsd_or_child(fs_info))
devfsd_notify_de(de, DEVFSD_NOTIFY_DELETE, inode->i_mode,
inode->i_uid, inode->i_gid, fs_info); inode->i_uid, inode->i_gid, fs_info);
free_dentry (de); free_dentry(de);
devfs_put (de); devfs_put(de);
return 0; return 0;
} /* End Function devfs_unlink */ } /* End Function devfs_unlink */
static int devfs_symlink (struct inode *dir, struct dentry *dentry, static int devfs_symlink(struct inode *dir, struct dentry *dentry,
const char *symname) const char *symname)
{ {
int err; int err;
...@@ -2360,30 +2355,32 @@ static int devfs_symlink (struct inode *dir, struct dentry *dentry, ...@@ -2360,30 +2355,32 @@ static int devfs_symlink (struct inode *dir, struct dentry *dentry,
struct inode *inode; struct inode *inode;
/* First try to get the devfs entry for this directory */ /* First try to get the devfs entry for this directory */
parent = get_devfs_entry_from_vfs_inode (dir); parent = get_devfs_entry_from_vfs_inode(dir);
if (parent == NULL) return -ENOENT; if (parent == NULL)
err = devfs_do_symlink (parent, dentry->d_name.name, symname, &de); return -ENOENT;
DPRINTK (DEBUG_DISABLED, "(%s): errcode from <devfs_do_symlink>: %d\n", err = devfs_do_symlink(parent, dentry->d_name.name, symname, &de);
DPRINTK(DEBUG_DISABLED, "(%s): errcode from <devfs_do_symlink>: %d\n",
dentry->d_name.name, err); dentry->d_name.name, err);
if (err < 0) return err; if (err < 0)
return err;
de->vfs = TRUE; de->vfs = TRUE;
de->inode.uid = current->euid; de->inode.uid = current->euid;
de->inode.gid = current->egid; de->inode.gid = current->egid;
de->inode.atime = CURRENT_TIME; de->inode.atime = CURRENT_TIME;
de->inode.mtime = CURRENT_TIME; de->inode.mtime = CURRENT_TIME;
de->inode.ctime = CURRENT_TIME; de->inode.ctime = CURRENT_TIME;
if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) if ((inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry)) == NULL)
return -ENOMEM; return -ENOMEM;
DPRINTK (DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n", DPRINTK(DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n",
dentry->d_name.name, de->inode.ino, inode, dentry); dentry->d_name.name, de->inode.ino, inode, dentry);
d_instantiate (dentry, inode); d_instantiate(dentry, inode);
if ( !is_devfsd_or_child (fs_info) ) if (!is_devfsd_or_child(fs_info))
devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, devfsd_notify_de(de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
inode->i_uid, inode->i_gid, fs_info); inode->i_uid, inode->i_gid, fs_info);
return 0; return 0;
} /* End Function devfs_symlink */ } /* End Function devfs_symlink */
static int devfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) static int devfs_mkdir(struct inode *dir, struct dentry *dentry, int mode)
{ {
int err; int err;
struct fs_info *fs_info = dir->i_sb->s_fs_info; struct fs_info *fs_info = dir->i_sb->s_fs_info;
...@@ -2391,61 +2388,72 @@ static int devfs_mkdir (struct inode *dir, struct dentry *dentry, int mode) ...@@ -2391,61 +2388,72 @@ static int devfs_mkdir (struct inode *dir, struct dentry *dentry, int mode)
struct inode *inode; struct inode *inode;
mode = (mode & ~S_IFMT) | S_IFDIR; /* VFS doesn't pass S_IFMT part */ mode = (mode & ~S_IFMT) | S_IFDIR; /* VFS doesn't pass S_IFMT part */
parent = get_devfs_entry_from_vfs_inode (dir); parent = get_devfs_entry_from_vfs_inode(dir);
if (parent == NULL) return -ENOENT; if (parent == NULL)
de = _devfs_alloc_entry (dentry->d_name.name, dentry->d_name.len, mode); return -ENOENT;
if (!de) return -ENOMEM; de = _devfs_alloc_entry(dentry->d_name.name, dentry->d_name.len, mode);
if (!de)
return -ENOMEM;
de->vfs = TRUE; de->vfs = TRUE;
if ( ( err = _devfs_append_entry (parent, de, NULL) ) != 0 ) if ((err = _devfs_append_entry(parent, de, NULL)) != 0)
return err; return err;
de->inode.uid = current->euid; de->inode.uid = current->euid;
de->inode.gid = current->egid; de->inode.gid = current->egid;
de->inode.atime = CURRENT_TIME; de->inode.atime = CURRENT_TIME;
de->inode.mtime = CURRENT_TIME; de->inode.mtime = CURRENT_TIME;
de->inode.ctime = CURRENT_TIME; de->inode.ctime = CURRENT_TIME;
if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) if ((inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry)) == NULL)
return -ENOMEM; return -ENOMEM;
DPRINTK (DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n", DPRINTK(DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n",
dentry->d_name.name, de->inode.ino, inode, dentry); dentry->d_name.name, de->inode.ino, inode, dentry);
d_instantiate (dentry, inode); d_instantiate(dentry, inode);
if ( !is_devfsd_or_child (fs_info) ) if (!is_devfsd_or_child(fs_info))
devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, devfsd_notify_de(de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
inode->i_uid, inode->i_gid, fs_info); inode->i_uid, inode->i_gid, fs_info);
return 0; return 0;
} /* End Function devfs_mkdir */ } /* End Function devfs_mkdir */
static int devfs_rmdir (struct inode *dir, struct dentry *dentry) static int devfs_rmdir(struct inode *dir, struct dentry *dentry)
{ {
int err = 0; int err = 0;
struct devfs_entry *de; struct devfs_entry *de;
struct fs_info *fs_info = dir->i_sb->s_fs_info; struct fs_info *fs_info = dir->i_sb->s_fs_info;
struct inode *inode = dentry->d_inode; struct inode *inode = dentry->d_inode;
if (dir->i_sb->s_fs_info != inode->i_sb->s_fs_info) return -EINVAL; if (dir->i_sb->s_fs_info != inode->i_sb->s_fs_info)
de = get_devfs_entry_from_vfs_inode (inode); return -EINVAL;
if (de == NULL) return -ENOENT; de = get_devfs_entry_from_vfs_inode(inode);
if ( !S_ISDIR (de->mode) ) return -ENOTDIR; if (de == NULL)
if (!de->vfs) return -EPERM; return -ENOENT;
if (!S_ISDIR(de->mode))
return -ENOTDIR;
if (!de->vfs)
return -EPERM;
/* First ensure the directory is empty and will stay that way */ /* First ensure the directory is empty and will stay that way */
write_lock (&de->u.dir.lock); write_lock(&de->u.dir.lock);
if (de->u.dir.first) err = -ENOTEMPTY; if (de->u.dir.first)
else de->u.dir.no_more_additions = TRUE; err = -ENOTEMPTY;
write_unlock (&de->u.dir.lock); else
if (err) return err; de->u.dir.no_more_additions = TRUE;
write_unlock(&de->u.dir.lock);
if (err)
return err;
/* Now unhook the directory from its parent */ /* Now unhook the directory from its parent */
write_lock (&de->parent->u.dir.lock); write_lock(&de->parent->u.dir.lock);
if ( !_devfs_unhook (de) ) err = -ENOENT; if (!_devfs_unhook(de))
write_unlock (&de->parent->u.dir.lock); err = -ENOENT;
if (err) return err; write_unlock(&de->parent->u.dir.lock);
if ( !is_devfsd_or_child (fs_info) ) if (err)
devfsd_notify_de (de, DEVFSD_NOTIFY_DELETE, inode->i_mode, return err;
if (!is_devfsd_or_child(fs_info))
devfsd_notify_de(de, DEVFSD_NOTIFY_DELETE, inode->i_mode,
inode->i_uid, inode->i_gid, fs_info); inode->i_uid, inode->i_gid, fs_info);
free_dentry (de); free_dentry(de);
devfs_put (de); devfs_put(de);
return 0; return 0;
} /* End Function devfs_rmdir */ } /* End Function devfs_rmdir */
static int devfs_mknod (struct inode *dir, struct dentry *dentry, int mode, static int devfs_mknod(struct inode *dir, struct dentry *dentry, int mode,
dev_t rdev) dev_t rdev)
{ {
int err; int err;
...@@ -2453,62 +2461,64 @@ static int devfs_mknod (struct inode *dir, struct dentry *dentry, int mode, ...@@ -2453,62 +2461,64 @@ static int devfs_mknod (struct inode *dir, struct dentry *dentry, int mode,
struct devfs_entry *parent, *de; struct devfs_entry *parent, *de;
struct inode *inode; struct inode *inode;
DPRINTK (DEBUG_I_MKNOD, "(%s): mode: 0%o dev: %u:%u\n", DPRINTK(DEBUG_I_MKNOD, "(%s): mode: 0%o dev: %u:%u\n",
dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev)); dentry->d_name.name, mode, MAJOR(rdev), MINOR(rdev));
parent = get_devfs_entry_from_vfs_inode (dir); parent = get_devfs_entry_from_vfs_inode(dir);
if (parent == NULL) return -ENOENT; if (parent == NULL)
de = _devfs_alloc_entry (dentry->d_name.name, dentry->d_name.len, mode); return -ENOENT;
if (!de) return -ENOMEM; de = _devfs_alloc_entry(dentry->d_name.name, dentry->d_name.len, mode);
if (!de)
return -ENOMEM;
de->vfs = TRUE; de->vfs = TRUE;
if (S_ISCHR(mode) || S_ISBLK(mode)) if (S_ISCHR(mode) || S_ISBLK(mode))
de->u.dev = rdev; de->u.dev = rdev;
if ( ( err = _devfs_append_entry (parent, de, NULL) ) != 0 ) if ((err = _devfs_append_entry(parent, de, NULL)) != 0)
return err; return err;
de->inode.uid = current->euid; de->inode.uid = current->euid;
de->inode.gid = current->egid; de->inode.gid = current->egid;
de->inode.atime = CURRENT_TIME; de->inode.atime = CURRENT_TIME;
de->inode.mtime = CURRENT_TIME; de->inode.mtime = CURRENT_TIME;
de->inode.ctime = CURRENT_TIME; de->inode.ctime = CURRENT_TIME;
if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL ) if ((inode = _devfs_get_vfs_inode(dir->i_sb, de, dentry)) == NULL)
return -ENOMEM; return -ENOMEM;
DPRINTK (DEBUG_I_MKNOD, ": new VFS inode(%u): %p dentry: %p\n", DPRINTK(DEBUG_I_MKNOD, ": new VFS inode(%u): %p dentry: %p\n",
de->inode.ino, inode, dentry); de->inode.ino, inode, dentry);
d_instantiate (dentry, inode); d_instantiate(dentry, inode);
if ( !is_devfsd_or_child (fs_info) ) if (!is_devfsd_or_child(fs_info))
devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode, devfsd_notify_de(de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
inode->i_uid, inode->i_gid, fs_info); inode->i_uid, inode->i_gid, fs_info);
return 0; return 0;
} /* End Function devfs_mknod */ } /* End Function devfs_mknod */
static int devfs_readlink (struct dentry *dentry, char *buffer, int buflen) static int devfs_readlink(struct dentry *dentry, char *buffer, int buflen)
{ {
int err; int err;
struct devfs_entry *de; struct devfs_entry *de;
de = get_devfs_entry_from_vfs_inode (dentry->d_inode); de = get_devfs_entry_from_vfs_inode(dentry->d_inode);
if (!de) return -ENODEV; if (!de)
err = vfs_readlink (dentry, buffer, buflen, de->u.symlink.linkname); return -ENODEV;
err = vfs_readlink(dentry, buffer, buflen, de->u.symlink.linkname);
return err; return err;
} /* End Function devfs_readlink */ } /* End Function devfs_readlink */
static int devfs_follow_link (struct dentry *dentry, struct nameidata *nd) static int devfs_follow_link(struct dentry *dentry, struct nameidata *nd)
{ {
int err; int err;
struct devfs_entry *de; struct devfs_entry *de;
de = get_devfs_entry_from_vfs_inode (dentry->d_inode); de = get_devfs_entry_from_vfs_inode(dentry->d_inode);
if (!de) return -ENODEV; if (!de)
err = vfs_follow_link (nd, de->u.symlink.linkname); return -ENODEV;
err = vfs_follow_link(nd, de->u.symlink.linkname);
return err; return err;
} /* End Function devfs_follow_link */ } /* End Function devfs_follow_link */
static struct inode_operations devfs_iops = static struct inode_operations devfs_iops = {
{
.setattr = devfs_notify_change, .setattr = devfs_notify_change,
}; };
static struct inode_operations devfs_dir_iops = static struct inode_operations devfs_dir_iops = {
{
.lookup = devfs_lookup, .lookup = devfs_lookup,
.unlink = devfs_unlink, .unlink = devfs_unlink,
.symlink = devfs_symlink, .symlink = devfs_symlink,
...@@ -2518,49 +2528,50 @@ static struct inode_operations devfs_dir_iops = ...@@ -2518,49 +2528,50 @@ static struct inode_operations devfs_dir_iops =
.setattr = devfs_notify_change, .setattr = devfs_notify_change,
}; };
static struct inode_operations devfs_symlink_iops = static struct inode_operations devfs_symlink_iops = {
{
.readlink = devfs_readlink, .readlink = devfs_readlink,
.follow_link = devfs_follow_link, .follow_link = devfs_follow_link,
.setattr = devfs_notify_change, .setattr = devfs_notify_change,
}; };
static int devfs_fill_super (struct super_block *sb, void *data, int silent) static int devfs_fill_super(struct super_block *sb, void *data, int silent)
{ {
struct inode *root_inode = NULL; struct inode *root_inode = NULL;
if (_devfs_get_root_entry () == NULL) goto out_no_root; if (_devfs_get_root_entry() == NULL)
atomic_set (&fs_info.devfsd_overrun_count, 0); goto out_no_root;
init_waitqueue_head (&fs_info.devfsd_wait_queue); atomic_set(&fs_info.devfsd_overrun_count, 0);
init_waitqueue_head (&fs_info.revalidate_wait_queue); init_waitqueue_head(&fs_info.devfsd_wait_queue);
init_waitqueue_head(&fs_info.revalidate_wait_queue);
fs_info.sb = sb; fs_info.sb = sb;
sb->s_fs_info = &fs_info; sb->s_fs_info = &fs_info;
sb->s_blocksize = 1024; sb->s_blocksize = 1024;
sb->s_blocksize_bits = 10; sb->s_blocksize_bits = 10;
sb->s_magic = DEVFS_SUPER_MAGIC; sb->s_magic = DEVFS_SUPER_MAGIC;
sb->s_op = &devfs_sops; sb->s_op = &devfs_sops;
if ( ( root_inode = _devfs_get_vfs_inode (sb, root_entry, NULL) ) == NULL ) if ((root_inode = _devfs_get_vfs_inode(sb, root_entry, NULL)) == NULL)
goto out_no_root; goto out_no_root;
sb->s_root = d_alloc_root (root_inode); sb->s_root = d_alloc_root(root_inode);
if (!sb->s_root) goto out_no_root; if (!sb->s_root)
DPRINTK (DEBUG_S_READ, "(): made devfs ptr: %p\n", sb->s_fs_info); goto out_no_root;
DPRINTK(DEBUG_S_READ, "(): made devfs ptr: %p\n", sb->s_fs_info);
return 0; return 0;
out_no_root: out_no_root:
PRINTK ("(): get root inode failed\n"); PRINTK("(): get root inode failed\n");
if (root_inode) iput (root_inode); if (root_inode)
iput(root_inode);
return -EINVAL; return -EINVAL;
} /* End Function devfs_fill_super */ } /* End Function devfs_fill_super */
static struct super_block * static struct super_block *devfs_get_sb(struct file_system_type *fs_type,
devfs_get_sb (struct file_system_type *fs_type, int flags, int flags, const char *dev_name,
const char *dev_name, void *data) void *data)
{ {
return get_sb_single (fs_type, flags, data, devfs_fill_super); return get_sb_single(fs_type, flags, data, devfs_fill_super);
} }
static struct file_system_type devfs_fs_type = static struct file_system_type devfs_fs_type = {
{
.name = DEVFS_NAME, .name = DEVFS_NAME,
.get_sb = devfs_get_sb, .get_sb = devfs_get_sb,
.kill_sb = kill_anon_super, .kill_sb = kill_anon_super,
...@@ -2568,8 +2579,8 @@ static struct file_system_type devfs_fs_type = ...@@ -2568,8 +2579,8 @@ static struct file_system_type devfs_fs_type =
/* File operations for devfsd follow */ /* File operations for devfsd follow */
static ssize_t devfsd_read (struct file *file, char *buf, size_t len, static ssize_t devfsd_read(struct file *file, char *buf, size_t len,
loff_t *ppos) loff_t * ppos)
{ {
int done = FALSE; int done = FALSE;
int ival; int ival;
...@@ -2578,35 +2589,35 @@ static ssize_t devfsd_read (struct file *file, char *buf, size_t len, ...@@ -2578,35 +2589,35 @@ static ssize_t devfsd_read (struct file *file, char *buf, size_t len,
struct devfsd_buf_entry *entry; struct devfsd_buf_entry *entry;
struct fs_info *fs_info = file->f_dentry->d_inode->i_sb->s_fs_info; struct fs_info *fs_info = file->f_dentry->d_inode->i_sb->s_fs_info;
struct devfsd_notify_struct *info = fs_info->devfsd_info; struct devfsd_notify_struct *info = fs_info->devfsd_info;
DECLARE_WAITQUEUE (wait, current); DECLARE_WAITQUEUE(wait, current);
/* Can't seek (pread) on this device */ /* Can't seek (pread) on this device */
if (ppos != &file->f_pos) return -ESPIPE; if (ppos != &file->f_pos)
return -ESPIPE;
/* Verify the task has grabbed the queue */ /* Verify the task has grabbed the queue */
if (fs_info->devfsd_task != current) return -EPERM; if (fs_info->devfsd_task != current)
return -EPERM;
info->major = 0; info->major = 0;
info->minor = 0; info->minor = 0;
/* Block for a new entry */ /* Block for a new entry */
set_current_state (TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
add_wait_queue (&fs_info->devfsd_wait_queue, &wait); add_wait_queue(&fs_info->devfsd_wait_queue, &wait);
while ( devfsd_queue_empty (fs_info) ) while (devfsd_queue_empty(fs_info)) {
{
fs_info->devfsd_sleeping = TRUE; fs_info->devfsd_sleeping = TRUE;
wake_up (&fs_info->revalidate_wait_queue); wake_up(&fs_info->revalidate_wait_queue);
schedule (); schedule();
fs_info->devfsd_sleeping = FALSE; fs_info->devfsd_sleeping = FALSE;
if ( signal_pending (current) ) if (signal_pending(current)) {
{ remove_wait_queue(&fs_info->devfsd_wait_queue, &wait);
remove_wait_queue (&fs_info->devfsd_wait_queue, &wait); __set_current_state(TASK_RUNNING);
__set_current_state (TASK_RUNNING);
return -EINTR; return -EINTR;
} }
set_current_state (TASK_INTERRUPTIBLE); set_current_state(TASK_INTERRUPTIBLE);
} }
remove_wait_queue (&fs_info->devfsd_wait_queue, &wait); remove_wait_queue(&fs_info->devfsd_wait_queue, &wait);
__set_current_state (TASK_RUNNING); __set_current_state(TASK_RUNNING);
/* Now play with the data */ /* Now play with the data */
ival = atomic_read (&fs_info->devfsd_overrun_count); ival = atomic_read(&fs_info->devfsd_overrun_count);
info->overrun_count = ival; info->overrun_count = ival;
entry = fs_info->devfsd_first_event; entry = fs_info->devfsd_first_event;
info->type = entry->type; info->type = entry->type;
...@@ -2618,109 +2629,111 @@ static ssize_t devfsd_read (struct file *file, char *buf, size_t len, ...@@ -2618,109 +2629,111 @@ static ssize_t devfsd_read (struct file *file, char *buf, size_t len,
info->major = MAJOR(de->u.dev); info->major = MAJOR(de->u.dev);
info->minor = MINOR(de->u.dev); info->minor = MINOR(de->u.dev);
} }
pos = devfs_generate_path (de, info->devname, DEVFS_PATHLEN); pos = devfs_generate_path(de, info->devname, DEVFS_PATHLEN);
if (pos < 0) return pos; if (pos < 0)
return pos;
info->namelen = DEVFS_PATHLEN - pos - 1; info->namelen = DEVFS_PATHLEN - pos - 1;
if (info->mode == 0) info->mode = de->mode; if (info->mode == 0)
devname_offset = info->devname - (char *) info; info->mode = de->mode;
devname_offset = info->devname - (char *)info;
rpos = *ppos; rpos = *ppos;
if (rpos < devname_offset) if (rpos < devname_offset) {
{
/* Copy parts of the header */ /* Copy parts of the header */
tlen = devname_offset - rpos; tlen = devname_offset - rpos;
if (tlen > len) tlen = len; if (tlen > len)
if ( copy_to_user (buf, (char *) info + rpos, tlen) ) tlen = len;
{ if (copy_to_user(buf, (char *)info + rpos, tlen)) {
return -EFAULT; return -EFAULT;
} }
rpos += tlen; rpos += tlen;
buf += tlen; buf += tlen;
len -= tlen; len -= tlen;
} }
if ( (rpos >= devname_offset) && (len > 0) ) if ((rpos >= devname_offset) && (len > 0)) {
{
/* Copy the name */ /* Copy the name */
tlen = info->namelen + 1; tlen = info->namelen + 1;
if (tlen > len) tlen = len; if (tlen > len)
else done = TRUE; tlen = len;
if ( copy_to_user (buf, info->devname + pos + rpos - devname_offset, else
tlen) ) done = TRUE;
{ if (copy_to_user
(buf, info->devname + pos + rpos - devname_offset, tlen)) {
return -EFAULT; return -EFAULT;
} }
rpos += tlen; rpos += tlen;
} }
tlen = rpos - *ppos; tlen = rpos - *ppos;
if (done) if (done) {
{
devfs_handle_t parent; devfs_handle_t parent;
spin_lock (&fs_info->devfsd_buffer_lock); spin_lock(&fs_info->devfsd_buffer_lock);
fs_info->devfsd_first_event = entry->next; fs_info->devfsd_first_event = entry->next;
if (entry->next == NULL) fs_info->devfsd_last_event = NULL; if (entry->next == NULL)
spin_unlock (&fs_info->devfsd_buffer_lock); fs_info->devfsd_last_event = NULL;
for (; de != NULL; de = parent) spin_unlock(&fs_info->devfsd_buffer_lock);
{ for (; de != NULL; de = parent) {
parent = de->parent; parent = de->parent;
devfs_put (de); devfs_put(de);
} }
kmem_cache_free (devfsd_buf_cache, entry); kmem_cache_free(devfsd_buf_cache, entry);
if (ival > 0) atomic_sub (ival, &fs_info->devfsd_overrun_count); if (ival > 0)
atomic_sub(ival, &fs_info->devfsd_overrun_count);
*ppos = 0; *ppos = 0;
} } else
else *ppos = rpos; *ppos = rpos;
return tlen; return tlen;
} /* End Function devfsd_read */ } /* End Function devfsd_read */
static int devfsd_ioctl (struct inode *inode, struct file *file, static int devfsd_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
int ival; int ival;
struct fs_info *fs_info = inode->i_sb->s_fs_info; struct fs_info *fs_info = inode->i_sb->s_fs_info;
switch (cmd) switch (cmd) {
{
case DEVFSDIOC_GET_PROTO_REV: case DEVFSDIOC_GET_PROTO_REV:
ival = DEVFSD_PROTOCOL_REVISION_KERNEL; ival = DEVFSD_PROTOCOL_REVISION_KERNEL;
if ( copy_to_user ( (void *)arg, &ival, sizeof ival ) ) return -EFAULT; if (copy_to_user((void *)arg, &ival, sizeof ival))
return -EFAULT;
break; break;
case DEVFSDIOC_SET_EVENT_MASK: case DEVFSDIOC_SET_EVENT_MASK:
/* Ensure only one reader has access to the queue. This scheme will /* Ensure only one reader has access to the queue. This scheme will
work even if the global kernel lock were to be removed, because it work even if the global kernel lock were to be removed, because it
doesn't matter who gets in first, as long as only one gets it */ doesn't matter who gets in first, as long as only one gets it */
if (fs_info->devfsd_task == NULL) if (fs_info->devfsd_task == NULL) {
{
static spinlock_t lock = SPIN_LOCK_UNLOCKED; static spinlock_t lock = SPIN_LOCK_UNLOCKED;
if ( !spin_trylock (&lock) ) return -EBUSY; if (!spin_trylock(&lock))
if (fs_info->devfsd_task != NULL) return -EBUSY;
{ /* We lost the race... */ if (fs_info->devfsd_task != NULL) { /* We lost the race... */
spin_unlock (&lock); spin_unlock(&lock);
return -EBUSY; return -EBUSY;
} }
fs_info->devfsd_task = current; fs_info->devfsd_task = current;
spin_unlock (&lock); spin_unlock(&lock);
fs_info->devfsd_pgrp = (process_group(current) == current->pid) ? fs_info->devfsd_pgrp =
process_group(current) : 0; (process_group(current) ==
current->pid) ? process_group(current) : 0;
fs_info->devfsd_file = file; fs_info->devfsd_file = file;
fs_info->devfsd_info = kmalloc (sizeof *fs_info->devfsd_info, fs_info->devfsd_info =
GFP_KERNEL); kmalloc(sizeof *fs_info->devfsd_info, GFP_KERNEL);
if (!fs_info->devfsd_info) if (!fs_info->devfsd_info) {
{ devfsd_close(inode, file);
devfsd_close (inode, file);
return -ENOMEM; return -ENOMEM;
} }
} } else if (fs_info->devfsd_task != current)
else if (fs_info->devfsd_task != current) return -EBUSY; return -EBUSY;
fs_info->devfsd_event_mask = arg; /* Let the masses come forth */ fs_info->devfsd_event_mask = arg; /* Let the masses come forth */
break; break;
case DEVFSDIOC_RELEASE_EVENT_QUEUE: case DEVFSDIOC_RELEASE_EVENT_QUEUE:
if (fs_info->devfsd_file != file) return -EPERM; if (fs_info->devfsd_file != file)
return devfsd_close (inode, file); return -EPERM;
/*break;*/ return devfsd_close(inode, file);
/*break; */
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
case DEVFSDIOC_SET_DEBUG_MASK: case DEVFSDIOC_SET_DEBUG_MASK:
if ( copy_from_user (&ival, (void *) arg, sizeof ival) )return -EFAULT; if (copy_from_user(&ival, (void *)arg, sizeof ival))
return -EFAULT;
devfs_debug = ival; devfs_debug = ival;
break; break;
#endif #endif
...@@ -2730,49 +2743,52 @@ static int devfsd_ioctl (struct inode *inode, struct file *file, ...@@ -2730,49 +2743,52 @@ static int devfsd_ioctl (struct inode *inode, struct file *file,
return 0; return 0;
} /* End Function devfsd_ioctl */ } /* End Function devfsd_ioctl */
static int devfsd_close (struct inode *inode, struct file *file) static int devfsd_close(struct inode *inode, struct file *file)
{ {
struct devfsd_buf_entry *entry, *next; struct devfsd_buf_entry *entry, *next;
struct fs_info *fs_info = inode->i_sb->s_fs_info; struct fs_info *fs_info = inode->i_sb->s_fs_info;
if (fs_info->devfsd_file != file) return 0; if (fs_info->devfsd_file != file)
return 0;
fs_info->devfsd_event_mask = 0; fs_info->devfsd_event_mask = 0;
fs_info->devfsd_file = NULL; fs_info->devfsd_file = NULL;
spin_lock (&fs_info->devfsd_buffer_lock); spin_lock(&fs_info->devfsd_buffer_lock);
entry = fs_info->devfsd_first_event; entry = fs_info->devfsd_first_event;
fs_info->devfsd_first_event = NULL; fs_info->devfsd_first_event = NULL;
fs_info->devfsd_last_event = NULL; fs_info->devfsd_last_event = NULL;
if (fs_info->devfsd_info) if (fs_info->devfsd_info) {
{ kfree(fs_info->devfsd_info);
kfree (fs_info->devfsd_info);
fs_info->devfsd_info = NULL; fs_info->devfsd_info = NULL;
} }
spin_unlock (&fs_info->devfsd_buffer_lock); spin_unlock(&fs_info->devfsd_buffer_lock);
fs_info->devfsd_pgrp = 0; fs_info->devfsd_pgrp = 0;
fs_info->devfsd_task = NULL; fs_info->devfsd_task = NULL;
wake_up (&fs_info->revalidate_wait_queue); wake_up(&fs_info->revalidate_wait_queue);
for (; entry; entry = next) for (; entry; entry = next) {
{
next = entry->next; next = entry->next;
kmem_cache_free (devfsd_buf_cache, entry); kmem_cache_free(devfsd_buf_cache, entry);
} }
return 0; return 0;
} /* End Function devfsd_close */ } /* End Function devfsd_close */
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
static ssize_t stat_read (struct file *file, char *buf, size_t len, static ssize_t stat_read(struct file *file, char *buf, size_t len,
loff_t *ppos) loff_t * ppos)
{ {
ssize_t num; ssize_t num;
char txt[80]; char txt[80];
num = sprintf (txt, "Number of entries: %u number of bytes: %u\n", num = sprintf(txt, "Number of entries: %u number of bytes: %u\n",
stat_num_entries, stat_num_bytes) + 1; stat_num_entries, stat_num_bytes) + 1;
/* Can't seek (pread) on this device */ /* Can't seek (pread) on this device */
if (ppos != &file->f_pos) return -ESPIPE; if (ppos != &file->f_pos)
if (*ppos >= num) return 0; return -ESPIPE;
if (*ppos + len > num) len = num - *ppos; if (*ppos >= num)
if ( copy_to_user (buf, txt + *ppos, len) ) return -EFAULT; return 0;
if (*ppos + len > num)
len = num - *ppos;
if (copy_to_user(buf, txt + *ppos, len))
return -EFAULT;
*ppos += len; *ppos += len;
return len; return len;
} /* End Function stat_read */ } /* End Function stat_read */
...@@ -2793,7 +2809,7 @@ static int __init init_devfs_fs(void) ...@@ -2793,7 +2809,7 @@ static int __init init_devfs_fs(void)
printk(KERN_INFO "%s: %s Richard Gooch (rgooch@atnf.csiro.au)\n", printk(KERN_INFO "%s: %s Richard Gooch (rgooch@atnf.csiro.au)\n",
DEVFS_NAME, DEVFS_VERSION); DEVFS_NAME, DEVFS_VERSION);
devfsd_buf_cache = kmem_cache_create("devfsd_event", devfsd_buf_cache = kmem_cache_create("devfsd_event",
sizeof (struct devfsd_buf_entry), sizeof(struct devfsd_buf_entry),
0, 0, NULL, NULL); 0, 0, NULL, NULL);
if (!devfsd_buf_cache) if (!devfsd_buf_cache)
OOPS("(): unable to allocate event slab\n"); OOPS("(): unable to allocate event slab\n");
...@@ -2809,32 +2825,35 @@ static int __init init_devfs_fs(void) ...@@ -2809,32 +2825,35 @@ static int __init init_devfs_fs(void)
return major; return major;
/* And create the entry for ".devfsd" */ /* And create the entry for ".devfsd" */
devfsd = _devfs_alloc_entry(".devfsd", 0, S_IFCHR|S_IRUSR|S_IWUSR); devfsd = _devfs_alloc_entry(".devfsd", 0, S_IFCHR | S_IRUSR | S_IWUSR);
if (devfsd == NULL ) if (devfsd == NULL)
return -ENOMEM; return -ENOMEM;
devfsd->u.dev = MKDEV(major, 0); devfsd->u.dev = MKDEV(major, 0);
_devfs_append_entry(root_entry, devfsd, NULL); _devfs_append_entry(root_entry, devfsd, NULL);
#ifdef CONFIG_DEVFS_DEBUG #ifdef CONFIG_DEVFS_DEBUG
stat = _devfs_alloc_entry(".stat", 0, S_IFCHR|S_IRUGO); stat = _devfs_alloc_entry(".stat", 0, S_IFCHR | S_IRUGO);
if (stat == NULL ) if (stat == NULL)
return -ENOMEM; return -ENOMEM;
stat->u.dev = MKDEV(major, 1); stat->u.dev = MKDEV(major, 1);
_devfs_append_entry (root_entry, stat, NULL); _devfs_append_entry(root_entry, stat, NULL);
#endif #endif
err = register_filesystem(&devfs_fs_type); err = register_filesystem(&devfs_fs_type);
return err; return err;
} /* End Function init_devfs_fs */ } /* End Function init_devfs_fs */
void __init mount_devfs_fs (void) void __init mount_devfs_fs(void)
{ {
int err; int err;
if ( !(boot_options & OPTION_MOUNT) ) return; if (!(boot_options & OPTION_MOUNT))
err = do_mount ("none", "/dev", "devfs", 0, NULL); return;
if (err == 0) printk (KERN_INFO "Mounted devfs on /dev\n"); err = do_mount("none", "/dev", "devfs", 0, NULL);
else PRINTK ("(): unable to mount devfs, err: %d\n", err); if (err == 0)
printk(KERN_INFO "Mounted devfs on /dev\n");
else
PRINTK("(): unable to mount devfs, err: %d\n", err);
} /* End Function mount_devfs_fs */ } /* End Function mount_devfs_fs */
module_init(init_devfs_fs) module_init(init_devfs_fs)
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
#include <linux/genhd.h> #include <linux/genhd.h>
#include <asm/bitops.h> #include <asm/bitops.h>
int devfs_register_tape(const char *name) int devfs_register_tape(const char *name)
{ {
char tname[32], dest[64]; char tname[32], dest[64];
...@@ -86,6 +85,7 @@ int devfs_register_tape(const char *name) ...@@ -86,6 +85,7 @@ int devfs_register_tape(const char *name)
return n; return n;
} }
EXPORT_SYMBOL(devfs_register_tape); EXPORT_SYMBOL(devfs_register_tape);
void devfs_unregister_tape(int num) void devfs_unregister_tape(int num)
......
...@@ -25,8 +25,7 @@ ...@@ -25,8 +25,7 @@
#define DEVFS_PATHLEN 1024 /* Never change this otherwise the #define DEVFS_PATHLEN 1024 /* Never change this otherwise the
binary interface will change */ binary interface will change */
struct devfsd_notify_struct struct devfsd_notify_struct { /* Use native C types to ensure same types in kernel and user space */
{ /* Use native C types to ensure same types in kernel and user space */
unsigned int type; /* DEVFSD_NOTIFY_* value */ unsigned int type; /* DEVFSD_NOTIFY_* value */
unsigned int mode; /* Mode of the inode or device entry */ unsigned int mode; /* Mode of the inode or device entry */
unsigned int major; /* Major number of device entry */ unsigned int major; /* Major number of device entry */
...@@ -39,5 +38,4 @@ struct devfsd_notify_struct ...@@ -39,5 +38,4 @@ struct devfsd_notify_struct
char devname[DEVFS_PATHLEN]; /* This will be '\0' terminated */ char devname[DEVFS_PATHLEN]; /* This will be '\0' terminated */
}; };
#endif /* _LINUX_DEVFS_FS_H */ #endif /* _LINUX_DEVFS_FS_H */
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
#ifdef CONFIG_DEVFS_FS #ifdef CONFIG_DEVFS_FS
extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...) extern int devfs_mk_bdev(dev_t dev, umode_t mode, const char *fmt, ...)
__attribute__((format (printf, 3, 4))); __attribute__ ((format(printf, 3, 4)));
extern int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...) extern int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
__attribute__((format (printf, 3, 4))); __attribute__ ((format(printf, 3, 4)));
extern int devfs_mk_symlink(const char *name, const char *link); extern int devfs_mk_symlink(const char *name, const char *link);
extern int devfs_mk_dir(const char *fmt, ...) extern int devfs_mk_dir(const char *fmt, ...)
__attribute__((format (printf, 1, 2))); __attribute__ ((format(printf, 1, 2)));
extern void devfs_remove(const char *fmt, ...) extern void devfs_remove(const char *fmt, ...)
__attribute__((format (printf, 1, 2))); __attribute__ ((format(printf, 1, 2)));
extern int devfs_register_tape(const char *name); extern int devfs_register_tape(const char *name);
extern void devfs_unregister_tape(int num); extern void devfs_unregister_tape(int num);
extern void mount_devfs_fs(void); extern void mount_devfs_fs(void);
...@@ -32,7 +32,7 @@ static inline int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...) ...@@ -32,7 +32,7 @@ static inline int devfs_mk_cdev(dev_t dev, umode_t mode, const char *fmt, ...)
{ {
return 0; return 0;
} }
static inline int devfs_mk_symlink (const char *name, const char *link) static inline int devfs_mk_symlink(const char *name, const char *link)
{ {
return 0; return 0;
} }
...@@ -43,14 +43,14 @@ static inline int devfs_mk_dir(const char *fmt, ...) ...@@ -43,14 +43,14 @@ static inline int devfs_mk_dir(const char *fmt, ...)
static inline void devfs_remove(const char *fmt, ...) static inline void devfs_remove(const char *fmt, ...)
{ {
} }
static inline int devfs_register_tape (const char *name) static inline int devfs_register_tape(const char *name)
{ {
return -1; return -1;
} }
static inline void devfs_unregister_tape(int num) static inline void devfs_unregister_tape(int num)
{ {
} }
static inline void mount_devfs_fs (void) static inline void mount_devfs_fs(void)
{ {
return; return;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment