1 diff -urN linux-2.4.18-pre3/Documentation/filesystems/devfs/ChangeLog linux/Documentation/filesystems/devfs/ChangeLog
2 --- linux-2.4.18-pre3/Documentation/filesystems/devfs/ChangeLog Fri Dec 21 10:41:53 2001
3 +++ linux/Documentation/filesystems/devfs/ChangeLog Sun Jan 13 18:53:59 2002
5 - Improved debugging messages
7 - Fixed unregister bugs in drivers/md/lvm-fs.c
8 +===============================================================================
9 +Changes for patch v199.6
11 +- Corrected (made useful) debugging message in <unregister>
13 +- Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs>
15 +- Fixed drivers/md/lvm-fs.c to create "lvm" entry
17 +- Added magic number to guard against scribbling drivers
19 +- Only return old entry in <devfs_mk_dir> if a directory
21 +- Defined macros for error and debug messages
23 +- Updated README from master HTML file
24 +===============================================================================
25 +Changes for patch v199.7
27 +- Unregister /dev/root symlink prior to creating second one (for
30 +- Added support for multiple Compaq cpqarray controllers
32 +- Fixed (rare, old) race in <devfs_lookup>
33 diff -urN linux-2.4.18-pre3/Documentation/filesystems/devfs/README linux/Documentation/filesystems/devfs/README
34 --- linux-2.4.18-pre3/Documentation/filesystems/devfs/README Fri Dec 21 10:41:53 2001
35 +++ linux/Documentation/filesystems/devfs/README Sun Jan 13 18:53:59 2002
38 Linux Devfs (Device File System) FAQ
43 -----------------------------------------------------------------------------
47 What I don't like about devfs
49 +Strange kernel messages
55 What I don't like about devfs
57 +Strange kernel messages
61 @@ -1789,6 +1791,42 @@
62 a bug to report, you should also read
64 http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
67 +Strange kernel messages
69 +You may see devfs-related messages in your kernel logs. Below are some
70 +messages and what they mean (and what you should do about them, if
75 +devfs_register(fred): could not append to parent, err: -17
77 +You need to check what the error code means, but usually 17 means
78 +EEXIST. This means that a driver attempted to create an entry
79 +fred in a directory, but there already was an entry with that
80 +name. This is often caused by flawed boot scripts which untar a bunch
81 +of inodes into /dev, as a way to restore permissions. This
82 +message is harmless, as the device nodes will still
83 +provide access to the driver (unless you use the devfs=only
84 +boot option, which is only for dedicated souls:-). If you want to get
85 +rid of these annoying messages, upgrade to devfsd-v1.3.20 and use the
86 +recommended RESTORE directive to restore permissions.
89 +devfs_mk_dir(bill): using old entry in dir: c1808724 ""
91 +This is similar to the message above, except that a driver attempted
92 +to create a directory named bill, and the parent directory
93 +has an entry with the same name. In this case, to ensure that drivers
94 +continue to work properly, the old entry is re-used and given to the
95 +driver. In 2.5 kernels, the driver is given a NULL entry, and thus,
96 +under rare circumstances, may not create the require device nodes.
97 +The solution is the same as above.
102 -----------------------------------------------------------------------------
104 diff -urN linux-2.4.18-pre3/drivers/block/cpqarray.c linux/drivers/block/cpqarray.c
105 --- linux-2.4.18-pre3/drivers/block/cpqarray.c Fri Nov 9 15:28:46 2001
106 +++ linux/drivers/block/cpqarray.c Sun Jan 13 18:53:59 2002
108 #include <linux/blkpg.h>
109 #include <linux/timer.h>
110 #include <linux/proc_fs.h>
111 +#include <linux/devfs_fs_kernel.h>
112 #include <linux/init.h>
113 #include <linux/hdreg.h>
114 #include <linux/spinlock.h>
118 static ctlr_info_t *hba[MAX_CTLR];
119 +static devfs_handle_t de_arr[MAX_CTLR][NWD];
125 del_gendisk(&ida_gendisk[i]);
127 + devfs_unregister(devfs_find_handle(NULL, "ida", 0, 0, 0, 0));
128 remove_proc_entry("cpqarray", proc_root_driver);
132 ida_gendisk[i].part = ida + (i*256);
133 ida_gendisk[i].sizes = ida_sizes + (i*256);
134 ida_gendisk[i].nr_real = 0;
135 + ida_gendisk[i].de_arr = de_arr[i];
136 + ida_gendisk[i].fops = &ida_fops;
138 /* Get on the disk list */
139 add_gendisk(&ida_gendisk[i]);
140 @@ -1881,6 +1886,14 @@
145 + if (!de_arr[ctlr][log_unit]) {
148 + sprintf(txt, "ida/c%dd%d", ctlr,
150 + de_arr[ctlr][log_unit] =
151 + devfs_mk_dir(NULL, txt, NULL);
153 info_p->phys_drives =
154 sense_config_buf->ctlr_phys_drv;
155 diff -urN linux-2.4.18-pre3/drivers/md/lvm-fs.c linux/drivers/md/lvm-fs.c
156 --- linux-2.4.18-pre3/drivers/md/lvm-fs.c Fri Dec 21 10:41:54 2001
157 +++ linux/drivers/md/lvm-fs.c Sun Jan 13 18:53:59 2002
160 static void _show_uuid(const char *src, char *b, char *e);
163 static devfs_handle_t lvm_devfs_handle;
165 static devfs_handle_t vg_devfs_handle[MAX_VG];
166 static devfs_handle_t ch_devfs_handle[MAX_VG];
167 static devfs_handle_t lv_devfs_handle[MAX_LV];
169 void __init lvm_init_fs() {
170 struct proc_dir_entry *pde;
172 -/* User-space has already registered this */
174 + /* Must create device node. Think about "devfs=only" situation */
175 lvm_devfs_handle = devfs_register(
176 0 , "lvm", 0, LVM_CHAR_MAJOR, 0,
177 S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP,
178 &lvm_chr_fops, NULL);
180 lvm_proc_dir = create_proc_entry(LVM_DIR, S_IFDIR, &proc_root);
182 lvm_proc_vg_subdir = create+proc_entry(LVM_VG_SUBDIR, S_IFDIR
188 devfs_unregister (lvm_devfs_handle);
190 remove_proc_entry(LVM_GLOBAL, lvm_proc_dir);
191 remove_proc_entry(LVM_VG_SUBDIR, lvm_proc_dir);
192 remove_proc_entry(LVM_DIR, &proc_root);
193 diff -urN linux-2.4.18-pre3/fs/devfs/base.c linux/fs/devfs/base.c
194 --- linux-2.4.18-pre3/fs/devfs/base.c Fri Dec 21 10:41:55 2001
195 +++ linux/fs/devfs/base.c Sun Jan 13 18:53:59 2002
197 Added poisoning to <devfs_put>.
198 Improved debugging messages.
200 + 20011221 Richard Gooch <rgooch@atnf.csiro.au>
201 + Corrected (made useful) debugging message in <unregister>.
202 + Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs>
203 + 20011224 Richard Gooch <rgooch@atnf.csiro.au>
204 + Added magic number to guard against scribbling drivers.
205 + 20011226 Richard Gooch <rgooch@atnf.csiro.au>
206 + Only return old entry in <devfs_mk_dir> if a directory.
207 + Defined macros for error and debug messages.
209 + 20020113 Richard Gooch <rgooch@atnf.csiro.au>
210 + Fixed (rare, old) race in <devfs_lookup>.
213 #include <linux/types.h>
214 #include <linux/errno.h>
216 #include <asm/bitops.h>
217 #include <asm/atomic.h>
219 -#define DEVFS_VERSION "1.7 (20011216)"
220 +#define DEVFS_VERSION "1.9 (20020113)"
222 #define DEVFS_NAME "devfs"
225 #define STRING_LENGTH 256
226 #define FAKE_BLOCK_SIZE 1024
227 #define POISON_PTR ( *(void **) poison_array )
228 +#define MAGIC_VALUE 0x327db823
233 #define OPTION_MOUNT 0x01
234 #define OPTION_ONLY 0x02
236 -#define OOPS(format, args...) {printk (format, ## args); \
237 - printk ("Forcing Oops\n"); \
239 +#define PRINTK(format, args...) \
240 + {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
242 +#define OOPS(format, args...) \
243 + {printk (KERN_CRIT "%s" format, __FUNCTION__ , ## args); \
244 + printk ("Forcing Oops\n"); \
247 +#ifdef CONFIG_DEVFS_DEBUG
248 +# define VERIFY_ENTRY(de) \
249 + {if ((de) && (de)->magic_number != MAGIC_VALUE) \
250 + OOPS ("(%p): bad magic value: %x\n", (de), (de)->magic_number);}
251 +# define WRITE_ENTRY_MAGIC(de,magic) (de)->magic_number = (magic)
252 +# define DPRINTK(flag, format, args...) \
253 + {if (devfs_debug & flag) \
254 + printk (KERN_INFO "%s" format, __FUNCTION__ , ## args);}
256 +# define VERIFY_ENTRY(de)
257 +# define WRITE_ENTRY_MAGIC(de,magic)
258 +# define DPRINTK(flag, format, args...)
262 struct directory_type
268 +#ifdef CONFIG_DEVFS_DEBUG
269 + unsigned int magic_number;
272 atomic_t refcount; /* When this drops to zero, it's unused */
276 static struct devfs_entry *devfs_get (struct devfs_entry *de)
279 if (de) atomic_inc (&de->refcount);
281 } /* End Function devfs_get */
282 @@ -849,17 +885,13 @@
283 void devfs_put (devfs_handle_t de)
286 - if (de->info == POISON_PTR)
287 - OOPS ("%s: devfs_put(%p): poisoned pointer\n", DEVFS_NAME, de);
289 + if (de->info == POISON_PTR) OOPS ("(%p): poisoned pointer\n", de);
290 if ( !atomic_dec_and_test (&de->refcount) ) return;
291 - if (de == root_entry)
292 - OOPS ("%s: devfs_put(): root entry being freed\n", DEVFS_NAME);
293 -#ifdef CONFIG_DEVFS_DEBUG
294 - if (devfs_debug & DEBUG_FREE)
295 - printk ("%s: devfs_put(%s): de: %p, parent: %p \"%s\"\n",
296 - DEVFS_NAME, de->name, de, de->parent,
297 - de->parent ? de->parent->name : "no parent");
299 + if (de == root_entry) OOPS ("(%p): root entry being freed\n", de);
300 + DPRINTK (DEBUG_FREE, "(%s): de: %p, parent: %p \"%s\"\n",
301 + de->name, de, de->parent,
302 + de->parent ? de->parent->name : "no parent");
303 if ( S_ISLNK (de->mode) ) kfree (de->u.symlink.linkname);
304 if ( ( S_ISCHR (de->mode) || S_ISBLK (de->mode) ) && de->u.fcb.autogen )
307 MKDEV (de->u.fcb.u.device.major,
308 de->u.fcb.u.device.minor) );
310 + WRITE_ENTRY_MAGIC (de, 0);
311 #ifdef CONFIG_DEVFS_DEBUG
312 spin_lock (&stat_lock);
316 if ( !S_ISDIR (dir->mode) )
318 - printk ("%s: search_dir(%s): not a directory\n", DEVFS_NAME,dir->name);
319 + PRINTK ("(%s): not a directory\n", dir->name);
322 for (curr = dir->u.dir.first; curr != NULL; curr = curr->next)
324 spin_unlock (&counter_lock);
325 if (name) memcpy (new->name, name, namelen);
326 new->namelen = namelen;
327 + WRITE_ENTRY_MAGIC (new, MAGIC_VALUE);
328 #ifdef CONFIG_DEVFS_DEBUG
329 spin_lock (&stat_lock);
332 if (old_de) *old_de = NULL;
333 if ( !S_ISDIR (dir->mode) )
335 - printk ("%s: append_entry(%s): dir: \"%s\" is not a directory\n",
336 - DEVFS_NAME, de->name, dir->name);
337 + PRINTK ("(%s): dir: \"%s\" is not a directory\n", de->name, dir->name);
341 @@ -1143,15 +1176,13 @@
342 if ( ( *dir = _devfs_make_parent_for_leaf (*dir, name, namelen,
343 &leaf_pos) ) == NULL )
345 - printk ("%s: prepare_leaf(%s): could not create parent path\n",
347 + PRINTK ("(%s): could not create parent path\n", name);
350 if ( ( de = _devfs_alloc_entry (name + leaf_pos, namelen - leaf_pos,mode) )
353 - printk ("%s: prepare_leaf(%s): could not allocate entry\n",
355 + PRINTK ("(%s): could not allocate entry\n", name);
359 @@ -1198,7 +1229,7 @@
363 - * find_by_dev - Find a devfs entry in a directory.
364 + * _devfs_find_by_dev - Find a devfs entry in a directory.
365 * @dir: The directory where to search
366 * @major: The major number to search for.
367 * @minor: The minor number to search for.
368 @@ -1209,9 +1240,9 @@
369 * devfs_get() is performed.
372 -static struct devfs_entry *find_by_dev (struct devfs_entry *dir,
373 - unsigned int major, unsigned int minor,
375 +static struct devfs_entry *_devfs_find_by_dev (struct devfs_entry *dir,
376 + unsigned int major,
377 + unsigned int minor, char type)
379 struct devfs_entry *entry, *de;
381 @@ -1219,7 +1250,7 @@
382 if (dir == NULL) return NULL;
383 if ( !S_ISDIR (dir->mode) )
385 - printk ("%s: find_by_dev(): not a directory\n", DEVFS_NAME);
386 + PRINTK ("(%p): not a directory\n", dir);
390 @@ -1244,7 +1275,7 @@
391 for (entry = dir->u.dir.first; entry != NULL; entry = entry->next)
393 if ( !S_ISDIR (entry->mode) ) continue;
394 - de = find_by_dev (entry, major, minor, type);
395 + de = _devfs_find_by_dev (entry, major, minor, type);
398 read_unlock (&dir->u.dir.lock);
399 @@ -1255,11 +1286,11 @@
400 read_unlock (&dir->u.dir.lock);
403 -} /* End Function find_by_dev */
404 +} /* End Function _devfs_find_by_dev */
408 - * find_entry - Find a devfs entry.
409 + * _devfs_find_entry - Find a devfs entry.
410 * @dir: The handle to the parent devfs directory entry. If this is %NULL the
411 * name is relative to the root of the devfs.
412 * @name: The name of the entry. This may be %NULL.
413 @@ -1275,9 +1306,11 @@
414 * devfs_get() is performed.
417 -static struct devfs_entry *find_entry (devfs_handle_t dir, const char *name,
418 - unsigned int major, unsigned int minor,
419 - char type, int traverse_symlink)
420 +static struct devfs_entry *_devfs_find_entry (devfs_handle_t dir,
422 + unsigned int major,
423 + unsigned int minor,
424 + char type, int traverse_symlink)
426 struct devfs_entry *entry;
428 @@ -1290,14 +1323,14 @@
429 /* Skip leading pathname component */
432 - printk ("%s: find_entry(%s): too short\n", DEVFS_NAME, name);
433 + PRINTK ("(%s): too short\n", name);
436 for (++name, --namelen; (*name != '/') && (namelen > 0);
440 - printk ("%s: find_entry(%s): too short\n", DEVFS_NAME, name);
441 + PRINTK ("(%s): too short\n", name);
445 @@ -1308,12 +1341,13 @@
447 /* Have to search by major and minor: slow */
448 if ( (major == 0) && (minor == 0) ) return NULL;
449 - return find_by_dev (root_entry, major, minor, type);
450 -} /* End Function find_entry */
451 + return _devfs_find_by_dev (root_entry, major, minor, type);
452 +} /* End Function _devfs_find_entry */
454 static struct devfs_entry *get_devfs_entry_from_vfs_inode (struct inode *inode)
456 if (inode == NULL) return NULL;
457 + VERIFY_ENTRY ( (struct devfs_entry *) inode->u.generic_ip );
458 return inode->u.generic_ip;
459 } /* End Function get_devfs_entry_from_vfs_inode */
461 @@ -1495,7 +1529,7 @@
465 - printk ("%s: devfs_register(): NULL name pointer\n", DEVFS_NAME);
466 + PRINTK ("(): NULL name pointer\n");
470 @@ -1503,23 +1537,19 @@
471 if ( S_ISBLK (mode) ) ops = (void *) get_blkfops (major);
474 - printk ("%s: devfs_register(%s): NULL ops pointer\n",
476 + PRINTK ("(%s): NULL ops pointer\n", name);
479 - printk ("%s: devfs_register(%s): NULL ops, got %p from major table\n",
480 - DEVFS_NAME, name, ops);
481 + PRINTK ("(%s): NULL ops, got %p from major table\n", name, ops);
483 if ( S_ISDIR (mode) )
485 - printk("%s: devfs_register(%s): creating directories is not allowed\n",
487 + PRINTK ("(%s): creating directories is not allowed\n", name);
490 if ( S_ISLNK (mode) )
492 - printk ("%s: devfs_register(%s): creating symlinks is not allowed\n",
494 + PRINTK ("(%s): creating symlinks is not allowed\n", name);
497 if ( ( S_ISCHR (mode) || S_ISBLK (mode) ) &&
498 @@ -1527,8 +1557,8 @@
500 if ( ( devnum = devfs_alloc_devnum (devtype) ) == NODEV )
502 - printk ("%s: devfs_register(%s): exhausted %s device numbers\n",
503 - DEVFS_NAME, name, S_ISCHR (mode) ? "char" : "block");
504 + PRINTK ("(%s): exhausted %s device numbers\n",
505 + name, S_ISCHR (mode) ? "char" : "block");
508 major = MAJOR (devnum);
509 @@ -1536,8 +1566,7 @@
511 if ( ( de = _devfs_prepare_leaf (&dir, name, mode) ) == NULL )
513 - printk ("%s: devfs_register(%s): could not prepare leaf\n",
515 + PRINTK ("(%s): could not prepare leaf\n", name);
516 if (devnum != NODEV) devfs_dealloc_devnum (devtype, devnum);
519 @@ -1549,8 +1578,7 @@
521 else if ( !S_ISREG (mode) )
523 - printk ("%s: devfs_register(%s): illegal mode: %x\n",
524 - DEVFS_NAME, name, mode);
525 + PRINTK ("(%s): illegal mode: %x\n", name, mode);
529 @@ -1574,17 +1602,13 @@
530 if ( ( err = _devfs_append_entry (dir, de, de->u.fcb.removable, NULL) )
533 - printk("%s: devfs_register(%s): could not append to parent, err: %d\n",
534 - DEVFS_NAME, name, err);
535 + PRINTK ("(%s): could not append to parent, err: %d\n", name, err);
537 if (devnum != NODEV) devfs_dealloc_devnum (devtype, devnum);
540 -#ifdef CONFIG_DEVFS_DEBUG
541 - if (devfs_debug & DEBUG_REGISTER)
542 - printk ("%s: devfs_register(%s): de: %p dir: %p \"%s\" pp: %p\n",
543 - DEVFS_NAME, name, de, dir, dir->name, dir->parent);
545 + DPRINTK (DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\" pp: %p\n",
546 + name, de, dir, dir->name, dir->parent);
547 devfsd_notify (de, DEVFSD_NOTIFY_REGISTERED, flags & DEVFS_FL_WAIT);
550 @@ -1620,7 +1644,7 @@
554 - * unregister - Unregister a device entry from it's parent.
555 + * _devfs_unregister - Unregister a device entry from it's parent.
556 * @dir: The parent directory.
557 * @de: The entry to unregister.
559 @@ -1628,7 +1652,7 @@
560 * unlocked by this function.
563 -static void unregister (struct devfs_entry *dir, struct devfs_entry *de)
564 +static void _devfs_unregister (struct devfs_entry *dir, struct devfs_entry *de)
566 int unhooked = _devfs_unhook (de);
568 @@ -1647,17 +1671,14 @@
569 write_lock (&de->u.dir.lock);
570 de->u.dir.no_more_additions = TRUE;
571 child = de->u.dir.first;
572 - unregister (de, child);
573 + VERIFY_ENTRY (child);
574 + _devfs_unregister (de, child);
576 -#ifdef CONFIG_DEVFS_DEBUG
577 - if (devfs_debug & DEBUG_UNREGISTER)
578 - printk ( "%s: unregister(%s): child: %p refcount: %d\n",
579 - DEVFS_NAME, child->name, child,
580 - atomic_read (&de->refcount) );
582 + DPRINTK (DEBUG_UNREGISTER, "(%s): child: %p refcount: %d\n",
583 + child->name, child, atomic_read (&child->refcount) );
586 -} /* End Function unregister */
587 +} /* End Function _devfs_unregister */
591 @@ -1668,14 +1689,12 @@
593 void devfs_unregister (devfs_handle_t de)
596 if ( (de == NULL) || (de->parent == NULL) ) return;
597 -#ifdef CONFIG_DEVFS_DEBUG
598 - if (devfs_debug & DEBUG_UNREGISTER)
599 - printk ( "%s: devfs_unregister(%s): de: %p refcount: %d\n",
600 - DEVFS_NAME, de->name, de, atomic_read (&de->refcount) );
602 + DPRINTK (DEBUG_UNREGISTER, "(%s): de: %p refcount: %d\n",
603 + de->name, de, atomic_read (&de->refcount) );
604 write_lock (&de->parent->u.dir.lock);
605 - unregister (de->parent, de);
606 + _devfs_unregister (de->parent, de);
608 } /* End Function devfs_unregister */
610 @@ -1691,16 +1710,12 @@
611 if (handle != NULL) *handle = NULL;
614 - printk ("%s: devfs_do_symlink(): NULL name pointer\n", DEVFS_NAME);
615 + PRINTK ("(): NULL name pointer\n");
618 -#ifdef CONFIG_DEVFS_DEBUG
619 - if (devfs_debug & DEBUG_REGISTER)
620 - printk ("%s: devfs_do_symlink(%s)\n", DEVFS_NAME, name);
624 - printk ("%s: devfs_do_symlink(): NULL link pointer\n", DEVFS_NAME);
625 + PRINTK ("(%s): NULL link pointer\n", name);
628 linklength = strlen (link);
629 @@ -1711,8 +1726,7 @@
630 if ( ( de = _devfs_prepare_leaf (&dir, name, S_IFLNK | S_IRUGO | S_IXUGO) )
633 - printk ("%s: devfs_do_symlink(%s): could not prepare leaf\n",
635 + PRINTK ("(%s): could not prepare leaf\n", name);
639 @@ -1722,8 +1736,7 @@
640 de->u.symlink.length = linklength;
641 if ( ( err = _devfs_append_entry (dir, de, FALSE, NULL) ) != 0 )
643 - printk ("%s: devfs_do_symlink(%s): could not append to parent, err: %d\n",
644 - DEVFS_NAME, name, err);
645 + PRINTK ("(%s): could not append to parent, err: %d\n", name, err);
649 @@ -1758,6 +1771,7 @@
652 if (handle != NULL) *handle = NULL;
653 + DPRINTK (DEBUG_REGISTER, "(%s)\n", name);
654 err = devfs_do_symlink (dir, name, flags, link, &de, info);
656 if (handle != NULL) *handle = de;
657 @@ -1787,39 +1801,35 @@
661 - printk ("%s: devfs_mk_dir(): NULL name pointer\n", DEVFS_NAME);
662 + PRINTK ("(): NULL name pointer\n");
665 if ( ( de = _devfs_prepare_leaf (&dir, name, MODE_DIR) ) == NULL )
667 - printk ("%s: devfs_mk_dir(%s): could not prepare leaf\n",
669 + PRINTK ("(%s): could not prepare leaf\n", name);
673 if ( ( err = _devfs_append_entry (dir, de, FALSE, &old) ) != 0 )
675 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
677 + if ( old && S_ISDIR (old->mode) )
679 - printk("%s: devfs_mk_dir(%s): using old entry in dir: %p \"%s\"\n",
680 - DEVFS_NAME, name, dir, dir->name);
681 + PRINTK ("(%s): using old entry in dir: %p \"%s\"\n",
682 + name, dir, dir->name);
683 old->vfs_created = FALSE;
688 - printk ("%s: devfs_mk_dir(%s): could not append to dir: %p \"%s\", err: %d\n",
689 - DEVFS_NAME, name, dir, dir->name, err);
690 + PRINTK ("(%s): could not append to dir: %p \"%s\", err: %d\n",
691 + name, dir, dir->name, err);
696 -#ifdef CONFIG_DEVFS_DEBUG
697 - if (devfs_debug & DEBUG_REGISTER)
698 - printk ("%s: devfs_mk_dir(%s): de: %p dir: %p \"%s\"\n",
699 - DEVFS_NAME, name, de, dir, dir->name);
701 + DPRINTK (DEBUG_REGISTER, "(%s): de: %p dir: %p \"%s\"\n",
702 + name, de, dir, dir->name);
703 devfsd_notify (de, DEVFSD_NOTIFY_REGISTERED, 0);
706 @@ -1850,7 +1860,7 @@
707 char type, int traverse_symlinks)
709 if ( (name != NULL) && (name[0] == '\0') ) name = NULL;
710 - return find_entry (dir, name, major, minor, type, traverse_symlinks);
711 + return _devfs_find_entry (dir, name, major, minor, type,traverse_symlinks);
712 } /* End Function devfs_get_handle */
715 @@ -1881,6 +1891,7 @@
718 if (de == NULL) return -EINVAL;
720 if (de->hide) fl |= DEVFS_FL_HIDE;
721 if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) )
723 @@ -1904,11 +1915,8 @@
724 int devfs_set_flags (devfs_handle_t de, unsigned int flags)
726 if (de == NULL) return -EINVAL;
727 -#ifdef CONFIG_DEVFS_DEBUG
728 - if (devfs_debug & DEBUG_SET_FLAGS)
729 - printk ("%s: devfs_set_flags(): de->name: \"%s\"\n",
730 - DEVFS_NAME, de->name);
733 + DPRINTK (DEBUG_SET_FLAGS, "(%s): flags: %x\n", de->name, flags);
734 de->hide = (flags & DEVFS_FL_HIDE) ? TRUE : FALSE;
735 if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) )
737 @@ -1932,6 +1940,7 @@
740 if (de == NULL) return -EINVAL;
742 if ( S_ISDIR (de->mode) ) return -EISDIR;
743 if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) ) return -EINVAL;
744 if (major != NULL) *major = de->u.fcb.u.device.major;
745 @@ -1972,6 +1981,7 @@
746 #define NAMEOF(de) ( (de)->mode ? (de)->name : (de)->u.name )
748 if (de == NULL) return -EINVAL;
750 if (de->namelen >= buflen) return -ENAMETOOLONG; /* Must be first */
751 path[buflen - 1] = '\0';
752 if (de->parent == NULL) return buflen - 1; /* Don't prepend root */
753 @@ -2001,6 +2011,7 @@
754 struct module *owner;
756 if (de == NULL) return NULL;
758 if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
760 if (de->u.fcb.ops == NULL) return NULL;
761 @@ -2031,6 +2042,7 @@
762 struct module *owner;
764 if (de == NULL) return;
766 if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
768 if (de->u.fcb.ops == NULL) return;
769 @@ -2052,6 +2064,7 @@
770 int devfs_set_file_size (devfs_handle_t de, unsigned long size)
772 if (de == NULL) return -EINVAL;
774 if ( !S_ISREG (de->mode) ) return -EINVAL;
775 if (de->u.fcb.u.file.size == size) return 0;
776 de->u.fcb.u.file.size = size;
777 @@ -2071,6 +2084,7 @@
778 void *devfs_get_info (devfs_handle_t de)
780 if (de == NULL) return NULL;
783 } /* End Function devfs_get_info */
785 @@ -2085,6 +2099,7 @@
786 int devfs_set_info (devfs_handle_t de, void *info)
788 if (de == NULL) return -EINVAL;
792 } /* End Function devfs_set_info */
793 @@ -2099,6 +2114,7 @@
794 devfs_handle_t devfs_get_parent (devfs_handle_t de)
796 if (de == NULL) return NULL;
799 } /* End Function devfs_get_parent */
801 @@ -2113,6 +2129,7 @@
802 devfs_handle_t devfs_get_first_child (devfs_handle_t de)
804 if (de == NULL) return NULL;
806 if ( !S_ISDIR (de->mode) ) return NULL;
807 return de->u.dir.first;
808 } /* End Function devfs_get_first_child */
809 @@ -2128,6 +2145,7 @@
810 devfs_handle_t devfs_get_next_sibling (devfs_handle_t de)
812 if (de == NULL) return NULL;
815 } /* End Function devfs_get_next_sibling */
817 @@ -2143,14 +2161,15 @@
818 void devfs_auto_unregister (devfs_handle_t master, devfs_handle_t slave)
820 if (master == NULL) return;
821 + VERIFY_ENTRY (master);
822 + VERIFY_ENTRY (slave);
823 if (master->slave != NULL)
825 /* Because of the dumbness of the layers above, ignore duplicates */
826 if (master->slave == slave) return;
827 - printk ("%s: devfs_auto_unregister(): only one slave allowed\n",
829 - OOPS (" master: \"%s\" old slave: \"%s\" new slave: \"%s\"\n",
830 - master->name, master->slave->name, slave->name);
831 + PRINTK ("(%s): only one slave allowed\n", master->name);
832 + OOPS ("(): old slave: \"%s\" new slave: \"%s\"\n",
833 + master->slave->name, slave->name);
835 master->slave = slave;
836 } /* End Function devfs_auto_unregister */
837 @@ -2166,6 +2185,7 @@
838 devfs_handle_t devfs_get_unregister_slave (devfs_handle_t master)
840 if (master == NULL) return NULL;
841 + VERIFY_ENTRY (master);
842 return master->slave;
843 } /* End Function devfs_get_unregister_slave */
845 @@ -2181,6 +2201,7 @@
846 const char *devfs_get_name (devfs_handle_t de, unsigned int *namelen)
848 if (de == NULL) return NULL;
850 if (namelen != NULL) *namelen = de->namelen;
852 } /* End Function devfs_get_name */
853 @@ -2360,7 +2381,7 @@
854 * @buf: A working area that will be used. This must not go out of scope
855 * until devfsd is idle again.
857 - * Returns 0 on success, else a negative error code.
858 + * Returns 0 on success (event was queued), else a negative error code.
861 static int try_modload (struct devfs_entry *parent, struct fs_info *fs_info,
862 @@ -2375,10 +2396,11 @@
863 buf->parent = parent;
864 buf->namelen = namelen;
866 + WRITE_ENTRY_MAGIC (buf, MAGIC_VALUE);
867 if ( !devfsd_notify_de (buf, DEVFSD_NOTIFY_LOOKUP, 0,
868 current->euid, current->egid, fs_info, 0) )
870 - /* Possible success */
871 + /* Possible success: event has been queued */
873 } /* End Function try_modload */
875 @@ -2487,16 +2509,10 @@
876 if (retval != 0) return retval;
877 retval = inode_setattr (inode, iattr);
878 if (retval != 0) return retval;
879 -#ifdef CONFIG_DEVFS_DEBUG
880 - if (devfs_debug & DEBUG_I_CHANGE)
882 - printk ("%s: notify_change(%d): VFS inode: %p devfs_entry: %p\n",
883 - DEVFS_NAME, (int) inode->i_ino, inode, de);
884 - printk ("%s: mode: 0%o uid: %d gid: %d\n",
885 - DEVFS_NAME, (int) inode->i_mode,
886 - (int) inode->i_uid, (int) inode->i_gid);
889 + DPRINTK (DEBUG_I_CHANGE, "(%d): VFS inode: %p devfs_entry: %p\n",
890 + (int) inode->i_ino, inode, de);
891 + DPRINTK (DEBUG_I_CHANGE, "(): mode: 0%o uid: %d gid: %d\n",
892 + (int) inode->i_mode, (int) inode->i_uid, (int) inode->i_gid);
893 /* Inode is not on hash chains, thus must save permissions here rather
894 than in a write_inode() method */
895 if ( ( !S_ISREG (inode->i_mode) && !S_ISCHR (inode->i_mode) &&
896 @@ -2541,7 +2557,7 @@
900 - * get_vfs_inode - Get a VFS inode.
901 + * _devfs_get_vfs_inode - Get a VFS inode.
902 * @sb: The super block.
903 * @de: The devfs inode.
904 * @dentry: The dentry to register with the devfs inode.
905 @@ -2550,9 +2566,9 @@
906 * performed if the inode is created.
909 -static struct inode *get_vfs_inode (struct super_block *sb,
910 - struct devfs_entry *de,
911 - struct dentry *dentry)
912 +static struct inode *_devfs_get_vfs_inode (struct super_block *sb,
913 + struct devfs_entry *de,
914 + struct dentry *dentry)
918 @@ -2560,8 +2576,7 @@
919 if (de->prev == de) return NULL; /* Quick check to see if unhooked */
920 if ( ( inode = new_inode (sb) ) == NULL )
922 - printk ("%s: get_vfs_inode(%s): new_inode() failed, de: %p\n",
923 - DEVFS_NAME, de->name, de);
924 + PRINTK ("(%s): new_inode() failed, de: %p\n", de->name, de);
928 @@ -2578,11 +2593,8 @@
930 inode->u.generic_ip = devfs_get (de);
931 inode->i_ino = de->inode.ino;
932 -#ifdef CONFIG_DEVFS_DEBUG
933 - if (devfs_debug & DEBUG_I_GET)
934 - printk ("%s: get_vfs_inode(%d): VFS inode: %p devfs_entry: %p\n",
935 - DEVFS_NAME, (int) inode->i_ino, inode, de);
937 + DPRINTK (DEBUG_I_GET, "(%d): VFS inode: %p devfs_entry: %p\n",
938 + (int) inode->i_ino, inode, de);
940 inode->i_blksize = FAKE_BLOCK_SIZE;
941 inode->i_op = &devfs_iops;
942 @@ -2604,8 +2616,7 @@
943 if (!inode->i_bdev->bd_op && de->u.fcb.ops)
944 inode->i_bdev->bd_op = de->u.fcb.ops;
946 - else printk ("%s: get_vfs_inode(%d): no block device from bdget()\n",
947 - DEVFS_NAME, (int) inode->i_ino);
948 + else PRINTK ("(%d): no block device from bdget()\n",(int)inode->i_ino);
951 else if ( S_ISFIFO (de->mode) ) inode->i_fop = &def_fifo_fops;
952 @@ -2632,14 +2643,10 @@
953 inode->i_atime = de->inode.atime;
954 inode->i_mtime = de->inode.mtime;
955 inode->i_ctime = de->inode.ctime;
956 -#ifdef CONFIG_DEVFS_DEBUG
957 - if (devfs_debug & DEBUG_I_GET)
958 - printk ("%s: mode: 0%o uid: %d gid: %d\n",
959 - DEVFS_NAME, (int) inode->i_mode,
960 - (int) inode->i_uid, (int) inode->i_gid);
962 + DPRINTK (DEBUG_I_GET, "(): mode: 0%o uid: %d gid: %d\n",
963 + (int) inode->i_mode, (int) inode->i_uid, (int) inode->i_gid);
965 -} /* End Function get_vfs_inode */
966 +} /* End Function _devfs_get_vfs_inode */
969 /* File operations for device entries follow */
970 @@ -2655,11 +2662,8 @@
971 fs_info = inode->i_sb->u.generic_sbp;
972 parent = get_devfs_entry_from_vfs_inode (file->f_dentry->d_inode);
973 if ( (long) file->f_pos < 0 ) return -EINVAL;
974 -#ifdef CONFIG_DEVFS_DEBUG
975 - if (devfs_debug & DEBUG_F_READDIR)
976 - printk ("%s: readdir(): fs_info: %p pos: %ld\n", DEVFS_NAME,
977 - fs_info, (long) file->f_pos);
979 + DPRINTK (DEBUG_F_READDIR, "(%s): fs_info: %p pos: %ld\n",
980 + parent->name, fs_info, (long) file->f_pos);
981 switch ( (long) file->f_pos )
984 @@ -2779,13 +2783,7 @@
986 static void devfs_d_release (struct dentry *dentry)
988 -#ifdef CONFIG_DEVFS_DEBUG
989 - struct inode *inode = dentry->d_inode;
991 - if (devfs_debug & DEBUG_D_RELEASE)
992 - printk ("%s: d_release(): dentry: %p inode: %p\n",
993 - DEVFS_NAME, dentry, inode);
995 + DPRINTK (DEBUG_D_RELEASE, "(%p): inode: %p\n", dentry, dentry->d_inode);
996 } /* End Function devfs_d_release */
999 @@ -2799,14 +2797,11 @@
1000 struct devfs_entry *de;
1002 de = get_devfs_entry_from_vfs_inode (inode);
1003 -#ifdef CONFIG_DEVFS_DEBUG
1004 - if (devfs_debug & DEBUG_D_IPUT)
1005 - printk ("%s: d_iput(): dentry: %p inode: %p de: %p de->dentry: %p\n",
1006 - DEVFS_NAME, dentry, inode, de, de->inode.dentry);
1008 + DPRINTK (DEBUG_D_IPUT,"(%s): dentry: %p inode: %p de: %p de->dentry: %p\n",
1009 + de->name, dentry, inode, de, de->inode.dentry);
1010 if ( de->inode.dentry && (de->inode.dentry != dentry) )
1011 - OOPS ("%s: d_iput(%s): de: %p dentry: %p de->dentry: %p\n",
1012 - DEVFS_NAME, de->name, de, dentry, de->inode.dentry);
1013 + OOPS ("(%s): de: %p dentry: %p de->dentry: %p\n",
1014 + de->name, de, dentry, de->inode.dentry);
1015 de->inode.dentry = NULL;
1018 @@ -2846,20 +2841,13 @@
1019 /* Unhash dentry if negative (has no inode) */
1022 -#ifdef CONFIG_DEVFS_DEBUG
1023 - if (devfs_debug & DEBUG_D_DELETE)
1024 - printk ("%s: d_delete(): dropping negative dentry: %p\n",
1025 - DEVFS_NAME, dentry);
1027 + DPRINTK (DEBUG_D_DELETE, "(%p): dropping negative dentry\n", dentry);
1030 fs_info = inode->i_sb->u.generic_sbp;
1031 de = get_devfs_entry_from_vfs_inode (inode);
1032 -#ifdef CONFIG_DEVFS_DEBUG
1033 - if (devfs_debug & DEBUG_D_DELETE)
1034 - printk ("%s: d_delete(): dentry: %p inode: %p devfs_entry: %p\n",
1035 - DEVFS_NAME, dentry, inode, de);
1037 + DPRINTK (DEBUG_D_DELETE, "(%p): inode: %p devfs_entry: %p\n",
1038 + dentry, inode, de);
1039 if (de == NULL) return 0;
1040 if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
1042 @@ -2876,40 +2864,55 @@
1044 } /* End Function devfs_d_delete */
1046 +struct devfs_lookup_struct
1048 + devfs_handle_t de;
1049 + wait_queue_head_t wait_queue;
1052 static int devfs_d_revalidate_wait (struct dentry *dentry, int flags)
1054 struct inode *dir = dentry->d_parent->d_inode;
1055 struct fs_info *fs_info = dir->i_sb->u.generic_sbp;
1056 + devfs_handle_t parent = get_devfs_entry_from_vfs_inode (dir);
1057 + struct devfs_lookup_struct *lookup_info = dentry->d_fsdata;
1058 + DECLARE_WAITQUEUE (wait, current);
1060 if ( !dentry->d_inode && is_devfsd_or_child (fs_info) )
1062 - devfs_handle_t de;
1063 - devfs_handle_t parent = get_devfs_entry_from_vfs_inode (dir);
1064 + devfs_handle_t de = lookup_info->de;
1065 struct inode *inode;
1067 -#ifdef CONFIG_DEVFS_DEBUG
1068 - if (devfs_debug & DEBUG_I_LOOKUP)
1069 - printk ("%s: d_revalidate(%s): dentry: %p by: \"%s\"\n",
1070 - DEVFS_NAME, dentry->d_name.name, dentry, current->comm);
1072 - read_lock (&parent->u.dir.lock);
1073 - de = _devfs_search_dir (parent, dentry->d_name.name,
1074 - dentry->d_name.len);
1075 - read_unlock (&parent->u.dir.lock);
1076 - if (de == NULL) return 1;
1077 + DPRINTK (DEBUG_I_LOOKUP, "(%s): dentry: %p de: %p by: \"%s\"\n",
1078 + dentry->d_name.name, dentry, de, current->comm);
1081 + read_lock (&parent->u.dir.lock);
1082 + de = _devfs_search_dir (parent, dentry->d_name.name,
1083 + dentry->d_name.len);
1084 + read_unlock (&parent->u.dir.lock);
1085 + if (de == NULL) return 1;
1086 + lookup_info->de = de;
1088 /* Create an inode, now that the driver information is available */
1089 - inode = get_vfs_inode (dir->i_sb, de, dentry);
1091 + inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry);
1092 if (!inode) return 1;
1093 -#ifdef CONFIG_DEVFS_DEBUG
1094 - if (devfs_debug & DEBUG_I_LOOKUP)
1095 - printk ("%s: d_revalidate(): new VFS inode(%u): %p devfs_entry: %p\n",
1096 - DEVFS_NAME, de->inode.ino, inode, de);
1098 + DPRINTK (DEBUG_I_LOOKUP,
1099 + "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n",
1100 + de->name, de->inode.ino, inode, de, current->comm);
1101 d_instantiate (dentry, inode);
1104 - if ( wait_for_devfsd_finished (fs_info) ) dentry->d_op = &devfs_dops;
1105 + if (lookup_info == NULL) return 1; /* Early termination */
1106 + read_lock (&parent->u.dir.lock);
1107 + if (dentry->d_fsdata)
1109 + add_wait_queue (&lookup_info->wait_queue, &wait);
1110 + current->state = TASK_UNINTERRUPTIBLE;
1111 + read_unlock (&parent->u.dir.lock);
1114 + else read_unlock (&parent->u.dir.lock);
1116 } /* End Function devfs_d_revalidate_wait */
1118 @@ -2918,20 +2921,20 @@
1120 static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry)
1122 + struct devfs_entry tmp; /* Must stay in scope until devfsd idle again */
1123 + struct devfs_lookup_struct lookup_info;
1124 struct fs_info *fs_info = dir->i_sb->u.generic_sbp;
1125 struct devfs_entry *parent, *de;
1126 struct inode *inode;
1127 + struct dentry *retval = NULL;
1129 /* Set up the dentry operations before anything else, to ensure cleaning
1131 dentry->d_op = &devfs_dops;
1132 /* First try to get the devfs entry for this directory */
1133 parent = get_devfs_entry_from_vfs_inode (dir);
1134 -#ifdef CONFIG_DEVFS_DEBUG
1135 - if (devfs_debug & DEBUG_I_LOOKUP)
1136 - printk ("%s: lookup(%s): dentry: %p parent: %p by: \"%s\"\n",
1137 - DEVFS_NAME, dentry->d_name.name, dentry, parent,current->comm);
1139 + DPRINTK (DEBUG_I_LOOKUP, "(%s): dentry: %p parent: %p by: \"%s\"\n",
1140 + dentry->d_name.name, dentry, parent, current->comm);
1141 if (parent == NULL) return ERR_PTR (-ENOENT);
1142 read_lock (&parent->u.dir.lock);
1143 de = _devfs_search_dir (parent, dentry->d_name.name, dentry->d_name.len);
1144 @@ -2945,63 +2948,61 @@
1145 dentry->d_name.len);
1146 read_unlock (&parent->u.dir.lock);
1148 + lookup_info.de = de;
1149 + init_waitqueue_head (&lookup_info.wait_queue);
1150 + dentry->d_fsdata = &lookup_info;
1152 { /* Try with devfsd. For any kind of failure, leave a negative dentry
1153 so someone else can deal with it (in the case where the sysadmin
1154 does a mknod()). It's important to do this before hashing the
1155 dentry, so that the devfsd queue is filled before revalidates
1157 - struct devfs_entry tmp;
1159 if (try_modload (parent, fs_info,
1160 dentry->d_name.name, dentry->d_name.len, &tmp) < 0)
1162 + { /* Lookup event was not queued to devfsd */
1163 d_add (dentry, NULL);
1166 - /* devfsd claimed success */
1167 - dentry->d_op = &devfs_wait_dops;
1168 - d_add (dentry, NULL); /* Open the floodgates */
1169 - /* Unlock directory semaphore, which will release any waiters. They
1170 - will get the hashed dentry, and may be forced to wait for
1173 - devfs_d_revalidate_wait (dentry, 0); /* I might have to wait too */
1174 - down (&dir->i_sem); /* Grab it again because them's the rules */
1175 - /* If someone else has been so kind as to make the inode, we go home
1177 - if (dentry->d_inode) return NULL;
1179 + dentry->d_op = &devfs_wait_dops;
1180 + d_add (dentry, NULL); /* Open the floodgates */
1181 + /* Unlock directory semaphore, which will release any waiters. They
1182 + will get the hashed dentry, and may be forced to wait for
1185 + wait_for_devfsd_finished (fs_info); /* If I'm not devfsd, must wait */
1186 + down (&dir->i_sem); /* Grab it again because them's the rules */
1187 + de = lookup_info.de;
1188 + /* If someone else has been so kind as to make the inode, we go home
1190 + if (dentry->d_inode) goto out;
1193 read_lock (&parent->u.dir.lock);
1194 de = _devfs_search_dir (parent, dentry->d_name.name,
1195 dentry->d_name.len);
1196 read_unlock (&parent->u.dir.lock);
1197 - if (de == NULL) return NULL;
1198 + if (de == NULL) goto out;
1199 /* OK, there's an entry now, but no VFS inode yet */
1202 + /* Create an inode, now that the driver information is available */
1203 + inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry);
1206 - dentry->d_op = &devfs_wait_dops;
1207 - d_add (dentry, NULL); /* Open the floodgates */
1208 + retval = ERR_PTR (-ENOMEM);
1211 - /* Create an inode, now that the driver information is available */
1212 - inode = get_vfs_inode (dir->i_sb, de, dentry);
1214 - if (!inode) return ERR_PTR (-ENOMEM);
1215 -#ifdef CONFIG_DEVFS_DEBUG
1216 - if (devfs_debug & DEBUG_I_LOOKUP)
1217 - printk ("%s: lookup(): new VFS inode(%u): %p devfs_entry: %p\n",
1218 - DEVFS_NAME, de->inode.ino, inode, de);
1220 + DPRINTK (DEBUG_I_LOOKUP, "(%s): new VFS inode(%u): %p de: %p by: \"%s\"\n",
1221 + de->name, de->inode.ino, inode, de, current->comm);
1222 d_instantiate (dentry, inode);
1223 - if (dentry->d_op == &devfs_wait_dops)
1224 - { /* Unlock directory semaphore, which will release any waiters. They
1225 - will get the hashed dentry, and may be forced to wait for
1228 - devfs_d_revalidate_wait (dentry, 0); /* I might have to wait too */
1229 - down (&dir->i_sem); /* Grab it again because them's the rules */
1233 + dentry->d_op = &devfs_dops;
1234 + dentry->d_fsdata = NULL;
1235 + write_lock (&parent->u.dir.lock);
1236 + wake_up (&lookup_info.wait_queue);
1237 + write_unlock (&parent->u.dir.lock);
1240 } /* End Function devfs_lookup */
1242 static int devfs_unlink (struct inode *dir, struct dentry *dentry)
1243 @@ -3011,11 +3012,8 @@
1244 struct inode *inode = dentry->d_inode;
1245 struct fs_info *fs_info = dir->i_sb->u.generic_sbp;
1247 -#ifdef CONFIG_DEVFS_DEBUG
1248 - if (devfs_debug & DEBUG_I_UNLINK)
1249 - printk ("%s: unlink(%s)\n", DEVFS_NAME, dentry->d_name.name);
1251 de = get_devfs_entry_from_vfs_inode (inode);
1252 + DPRINTK (DEBUG_I_UNLINK, "(%s): de: %p\n", dentry->d_name.name, de);
1253 if (de == NULL) return -ENOENT;
1254 if (!de->vfs_created) return -EPERM;
1255 write_lock (&de->parent->u.dir.lock);
1256 @@ -3043,11 +3041,8 @@
1257 if (parent == NULL) return -ENOENT;
1258 err = devfs_do_symlink (parent, dentry->d_name.name, DEVFS_FL_NONE,
1259 symname, &de, NULL);
1260 -#ifdef CONFIG_DEVFS_DEBUG
1261 - if (devfs_debug & DEBUG_DISABLED)
1262 - printk ("%s: symlink(): errcode from <devfs_do_symlink>: %d\n",
1265 + DPRINTK (DEBUG_DISABLED, "(%s): errcode from <devfs_do_symlink>: %d\n",
1266 + dentry->d_name.name, err);
1267 if (err < 0) return err;
1268 de->vfs_created = TRUE;
1269 de->inode.uid = current->euid;
1270 @@ -3055,13 +3050,10 @@
1271 de->inode.atime = CURRENT_TIME;
1272 de->inode.mtime = CURRENT_TIME;
1273 de->inode.ctime = CURRENT_TIME;
1274 - if ( ( inode = get_vfs_inode (dir->i_sb, de, dentry) ) == NULL )
1275 + if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL )
1277 -#ifdef CONFIG_DEVFS_DEBUG
1278 - if (devfs_debug & DEBUG_DISABLED)
1279 - printk ("%s: symlink(): new VFS inode(%u): %p dentry: %p\n",
1280 - DEVFS_NAME, de->inode.ino, inode, dentry);
1282 + DPRINTK (DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n",
1283 + dentry->d_name.name, de->inode.ino, inode, dentry);
1284 d_instantiate (dentry, inode);
1285 if ( !is_devfsd_or_child (fs_info) )
1286 devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
1287 @@ -3089,13 +3081,10 @@
1288 de->inode.atime = CURRENT_TIME;
1289 de->inode.mtime = CURRENT_TIME;
1290 de->inode.ctime = CURRENT_TIME;
1291 - if ( ( inode = get_vfs_inode (dir->i_sb, de, dentry) ) == NULL )
1292 + if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL )
1294 -#ifdef CONFIG_DEVFS_DEBUG
1295 - if (devfs_debug & DEBUG_DISABLED)
1296 - printk ("%s: mkdir(): new VFS inode(%u): %p dentry: %p\n",
1297 - DEVFS_NAME, de->inode.ino, inode, dentry);
1299 + DPRINTK (DEBUG_DISABLED, "(%s): new VFS inode(%u): %p dentry: %p\n",
1300 + dentry->d_name.name, de->inode.ino, inode, dentry);
1301 d_instantiate (dentry, inode);
1302 if ( !is_devfsd_or_child (fs_info) )
1303 devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
1304 @@ -3142,11 +3131,8 @@
1305 struct devfs_entry *parent, *de;
1306 struct inode *inode;
1308 -#ifdef CONFIG_DEVFS_DEBUG
1309 - if (devfs_debug & DEBUG_I_MKNOD)
1310 - printk ("%s: mknod(%s): mode: 0%o dev: %d\n",
1311 - DEVFS_NAME, dentry->d_name.name, mode, rdev);
1313 + DPRINTK (DEBUG_I_MKNOD, "(%s): mode: 0%o dev: %d\n",
1314 + dentry->d_name.name, mode, rdev);
1315 parent = get_devfs_entry_from_vfs_inode (dir);
1316 if (parent == NULL) return -ENOENT;
1317 de = _devfs_alloc_entry (dentry->d_name.name, dentry->d_name.len, mode);
1318 @@ -3164,13 +3150,10 @@
1319 de->inode.atime = CURRENT_TIME;
1320 de->inode.mtime = CURRENT_TIME;
1321 de->inode.ctime = CURRENT_TIME;
1322 - if ( ( inode = get_vfs_inode (dir->i_sb, de, dentry) ) == NULL )
1323 + if ( ( inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry) ) == NULL )
1325 -#ifdef CONFIG_DEVFS_DEBUG
1326 - if (devfs_debug & DEBUG_I_MKNOD)
1327 - printk ("%s: new VFS inode(%u): %p dentry: %p\n",
1328 - DEVFS_NAME, de->inode.ino, inode, dentry);
1330 + DPRINTK (DEBUG_I_MKNOD, ": new VFS inode(%u): %p dentry: %p\n",
1331 + de->inode.ino, inode, dentry);
1332 d_instantiate (dentry, inode);
1333 if ( !is_devfsd_or_child (fs_info) )
1334 devfsd_notify_de (de, DEVFSD_NOTIFY_CREATE, inode->i_mode,
1335 @@ -3238,15 +3221,11 @@
1336 sb->s_blocksize_bits = 10;
1337 sb->s_magic = DEVFS_SUPER_MAGIC;
1338 sb->s_op = &devfs_sops;
1339 - if ( ( root_inode = get_vfs_inode (sb, root_entry, NULL) ) == NULL )
1340 + if ( ( root_inode = _devfs_get_vfs_inode (sb, root_entry, NULL) ) == NULL )
1342 sb->s_root = d_alloc_root (root_inode);
1343 if (!sb->s_root) goto out_no_root;
1344 -#ifdef CONFIG_DEVFS_DEBUG
1345 - if (devfs_debug & DEBUG_S_READ)
1346 - printk ("%s: read super, made devfs ptr: %p\n",
1347 - DEVFS_NAME, sb->u.generic_sbp);
1349 + DPRINTK (DEBUG_S_READ, "(): made devfs ptr: %p\n", sb->u.generic_sbp);
1353 @@ -3479,6 +3458,10 @@
1355 printk ("%s: v%s Richard Gooch (rgooch@atnf.csiro.au)\n",
1356 DEVFS_NAME, DEVFS_VERSION);
1357 + devfsd_buf_cache = kmem_cache_create ("devfsd_event",
1358 + sizeof (struct devfsd_buf_entry),
1359 + 0, 0, NULL, NULL);
1360 + if (!devfsd_buf_cache) OOPS ("(): unable to allocate event slab\n");
1361 #ifdef CONFIG_DEVFS_DEBUG
1362 devfs_debug = devfs_debug_init;
1363 printk ("%s: devfs_debug: 0x%0x\n", DEVFS_NAME, devfs_debug);
1364 @@ -3498,9 +3481,6 @@
1368 - devfsd_buf_cache = kmem_cache_create ("devfsd_event",
1369 - sizeof (struct devfsd_buf_entry),
1370 - 0, 0, NULL, NULL);
1371 if ( !(boot_options & OPTION_MOUNT) ) return;
1372 err = do_mount ("none", "/dev", "devfs", 0, "");
1373 if (err == 0) printk ("Mounted devfs on /dev\n");
1374 diff -urN linux-2.4.18-pre3/fs/super.c linux/fs/super.c
1375 --- linux-2.4.18-pre3/fs/super.c Fri Dec 21 10:42:03 2001
1376 +++ linux/fs/super.c Sun Jan 13 18:53:59 2002
1377 @@ -1056,6 +1056,7 @@
1379 if (path_start >= 0) {
1380 name = path + path_start;
1381 + devfs_unregister (devfs_find_handle(NULL, "root", 0, 0, 0, 0));
1382 devfs_mk_symlink (NULL, "root", DEVFS_FL_DEFAULT,
1383 name + 5, NULL, NULL);
1384 memcpy (name, "/dev/", 5);