]> git.pld-linux.org Git - packages/kernel.git/blob - linux-2.4.17-devfs-v199.7.patch
- obsolete
[packages/kernel.git] / linux-2.4.17-devfs-v199.7.patch
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
4 @@ -1845,3 +1845,28 @@
5  - Improved debugging messages
6  
7  - Fixed unregister bugs in drivers/md/lvm-fs.c
8 +===============================================================================
9 +Changes for patch v199.6
10 +
11 +- Corrected (made useful) debugging message in <unregister>
12 +
13 +- Moved <kmem_cache_create> in <mount_devfs_fs> to <init_devfs_fs>
14 +
15 +- Fixed drivers/md/lvm-fs.c to create "lvm" entry
16 +
17 +- Added magic number to guard against scribbling drivers
18 +
19 +- Only return old entry in <devfs_mk_dir> if a directory
20 +
21 +- Defined macros for error and debug messages
22 +
23 +- Updated README from master HTML file
24 +===============================================================================
25 +Changes for patch v199.7
26 +
27 +- Unregister /dev/root symlink prior to creating second one (for
28 +  initrd)
29 +
30 +- Added support for multiple Compaq cpqarray controllers
31 +
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
36 @@ -3,7 +3,7 @@
37  
38  Linux Devfs (Device File System) FAQ
39  Richard Gooch
40 -13-DEC-2001
41 +21-DEC-2001
42  
43  -----------------------------------------------------------------------------
44  
45 @@ -68,6 +68,7 @@
46  Alternatives to devfs
47  What I don't like about devfs
48  How to report bugs
49 +Strange kernel messages
50  
51  
52  Other resources
53 @@ -1475,6 +1476,7 @@
54  Alternatives to devfs
55  What I don't like about devfs
56  How to report bugs
57 +Strange kernel messages
58  
59  
60  
61 @@ -1789,6 +1791,42 @@
62  a bug to report, you should also read
63  
64  http://www.chiark.greenend.org.uk/~sgtatham/bugs.html.
65 +
66 +
67 +Strange kernel messages
68 +
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
71 +anything).
72 +
73 +
74 +
75 +devfs_register(fred): could not append to parent, err: -17
76 +
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.
87 +
88 +
89 +devfs_mk_dir(bill): using old entry in dir: c1808724 ""
90 +
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.
98 +
99 +
100 +
101  
102  -----------------------------------------------------------------------------
103  
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
107 @@ -32,6 +32,7 @@
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>
115 @@ -70,6 +71,7 @@
116  
117  static int nr_ctlr;
118  static ctlr_info_t *hba[MAX_CTLR];
119 +static devfs_handle_t de_arr[MAX_CTLR][NWD];
120  
121  static int eisa[8];
122  
123 @@ -338,6 +340,7 @@
124  
125                 del_gendisk(&ida_gendisk[i]);
126         }
127 +       devfs_unregister(devfs_find_handle(NULL, "ida", 0, 0, 0, 0));
128         remove_proc_entry("cpqarray", proc_root_driver);
129         kfree(ida);
130         kfree(ida_sizes);
131 @@ -540,6 +543,8 @@
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; 
137         
138                 /* Get on the disk list */
139                 add_gendisk(&ida_gendisk[i]);
140 @@ -1881,6 +1886,14 @@
141                                         kfree(id_ldrive);
142                                         return;
143  
144 +                               }
145 +                               if (!de_arr[ctlr][log_unit]) {
146 +                                       char txt[16];
147 +
148 +                                       sprintf(txt, "ida/c%dd%d", ctlr,
149 +                                               log_unit);
150 +                                       de_arr[ctlr][log_unit] =
151 +                                               devfs_mk_dir(NULL, txt, NULL);
152                                 }
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
158 @@ -65,9 +65,7 @@
159  
160  static void _show_uuid(const char *src, char *b, char *e);
161  
162 -#if 0
163  static devfs_handle_t lvm_devfs_handle;
164 -#endif
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];
168 @@ -81,13 +79,11 @@
169  void __init lvm_init_fs() {
170         struct proc_dir_entry *pde;
171  
172 -/* User-space has already registered this */
173 -#if 0
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);
179 -#endif
180         lvm_proc_dir = create_proc_entry(LVM_DIR, S_IFDIR, &proc_root);
181         if (lvm_proc_dir) {
182                 lvm_proc_vg_subdir = create+proc_entry(LVM_VG_SUBDIR, S_IFDIR   
183 @@ -99,9 +95,7 @@
184  }
185  
186  void lvm_fin_fs() {
187 -#if 0
188         devfs_unregister (lvm_devfs_handle);
189 -#endif
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
196 @@ -592,6 +592,18 @@
197                Added poisoning to <devfs_put>.
198                Improved debugging messages.
199    v1.7
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.
208 +  v1.8
209 +    20020113   Richard Gooch <rgooch@atnf.csiro.au>
210 +              Fixed (rare, old) race in <devfs_lookup>.
211 +  v1.9
212  */
213  #include <linux/types.h>
214  #include <linux/errno.h>
215 @@ -624,7 +636,7 @@
216  #include <asm/bitops.h>
217  #include <asm/atomic.h>
218  
219 -#define DEVFS_VERSION            "1.7 (20011216)"
220 +#define DEVFS_VERSION            "1.9 (20020113)"
221  
222  #define DEVFS_NAME "devfs"
223  
224 @@ -633,6 +645,7 @@
225  #define STRING_LENGTH 256
226  #define FAKE_BLOCK_SIZE 1024
227  #define POISON_PTR ( *(void **) poison_array )
228 +#define MAGIC_VALUE 0x327db823
229  
230  #ifndef TRUE
231  #  define TRUE 1
232 @@ -669,9 +682,28 @@
233  #define OPTION_MOUNT            0x01
234  #define OPTION_ONLY             0x02
235  
236 -#define OOPS(format, args...) {printk (format, ## args); \
237 -                               printk ("Forcing Oops\n"); \
238 -                               BUG();}
239 +#define PRINTK(format, args...) \
240 +   {printk (KERN_ERR "%s" format, __FUNCTION__ , ## args);}
241 +
242 +#define OOPS(format, args...) \
243 +   {printk (KERN_CRIT "%s" format, __FUNCTION__ , ## args); \
244 +    printk ("Forcing Oops\n"); \
245 +    BUG();}
246 +
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);}
255 +#else
256 +#  define VERIFY_ENTRY(de)
257 +#  define WRITE_ENTRY_MAGIC(de,magic)
258 +#  define DPRINTK(flag, format, args...)
259 +#endif
260 +
261  
262  struct directory_type
263  {
264 @@ -728,6 +760,9 @@
265  
266  struct devfs_entry
267  {
268 +#ifdef CONFIG_DEVFS_DEBUG
269 +    unsigned int magic_number;
270 +#endif
271      void *info;
272      atomic_t refcount;           /*  When this drops to zero, it's unused    */
273      union 
274 @@ -837,6 +872,7 @@
275  
276  static struct devfs_entry *devfs_get (struct devfs_entry *de)
277  {
278 +    VERIFY_ENTRY (de);
279      if (de) atomic_inc (&de->refcount);
280      return de;
281  }   /*  End Function devfs_get  */
282 @@ -849,17 +885,13 @@
283  void devfs_put (devfs_handle_t de)
284  {
285      if (!de) return;
286 -    if (de->info == POISON_PTR)
287 -       OOPS ("%s: devfs_put(%p): poisoned pointer\n", DEVFS_NAME, de);
288 +    VERIFY_ENTRY (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");
298 -#endif
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 )
305      {
306 @@ -868,6 +900,7 @@
307                                MKDEV (de->u.fcb.u.device.major,
308                                       de->u.fcb.u.device.minor) );
309      }
310 +    WRITE_ENTRY_MAGIC (de, 0);
311  #ifdef CONFIG_DEVFS_DEBUG
312      spin_lock (&stat_lock);
313      --stat_num_entries;
314 @@ -898,7 +931,7 @@
315  
316      if ( !S_ISDIR (dir->mode) )
317      {
318 -       printk ("%s: search_dir(%s): not a directory\n", DEVFS_NAME,dir->name);
319 +       PRINTK ("(%s): not a directory\n", dir->name);
320         return NULL;
321      }
322      for (curr = dir->u.dir.first; curr != NULL; curr = curr->next)
323 @@ -940,6 +973,7 @@
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);
330      ++stat_num_entries;
331 @@ -972,8 +1006,7 @@
332      if (old_de) *old_de = NULL;
333      if ( !S_ISDIR (dir->mode) )
334      {
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);
338         devfs_put (de);
339         return -ENOTDIR;
340      }
341 @@ -1143,15 +1176,13 @@
342      if ( ( *dir = _devfs_make_parent_for_leaf (*dir, name, namelen,
343                                                &leaf_pos) ) == NULL )
344      {
345 -       printk ("%s: prepare_leaf(%s): could not create parent path\n",
346 -               DEVFS_NAME, name);
347 +       PRINTK ("(%s): could not create parent path\n", name);
348         return NULL;
349      }
350      if ( ( de = _devfs_alloc_entry (name + leaf_pos, namelen - leaf_pos,mode) )
351          == NULL )
352      {
353 -       printk ("%s: prepare_leaf(%s): could not allocate entry\n",
354 -               DEVFS_NAME, name);
355 +       PRINTK ("(%s): could not allocate entry\n", name);
356         devfs_put (*dir);
357         return NULL;
358      }
359 @@ -1198,7 +1229,7 @@
360  
361  
362  /**
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.
370   */
371  
372 -static struct devfs_entry *find_by_dev (struct devfs_entry *dir,
373 -                                       unsigned int major, unsigned int minor,
374 -                                       char type)
375 +static struct devfs_entry *_devfs_find_by_dev (struct devfs_entry *dir,
376 +                                              unsigned int major,
377 +                                              unsigned int minor, char type)
378  {
379      struct devfs_entry *entry, *de;
380  
381 @@ -1219,7 +1250,7 @@
382      if (dir == NULL) return NULL;
383      if ( !S_ISDIR (dir->mode) )
384      {
385 -       printk ("%s: find_by_dev(): not a directory\n", DEVFS_NAME);
386 +       PRINTK ("(%p): not a directory\n", dir);
387         devfs_put (dir);
388         return NULL;
389      }
390 @@ -1244,7 +1275,7 @@
391      for (entry = dir->u.dir.first; entry != NULL; entry = entry->next)
392      {
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);
396         if (de)
397         {
398             read_unlock (&dir->u.dir.lock);
399 @@ -1255,11 +1286,11 @@
400      read_unlock (&dir->u.dir.lock);
401      devfs_put (dir);
402      return NULL;
403 -}   /*  End Function find_by_dev  */
404 +}   /*  End Function _devfs_find_by_dev  */
405  
406  
407  /**
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.
415   */
416  
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,
421 +                                             const char *name,
422 +                                             unsigned int major,
423 +                                             unsigned int minor,
424 +                                             char type, int traverse_symlink)
425  {
426      struct devfs_entry *entry;
427  
428 @@ -1290,14 +1323,14 @@
429             /*  Skip leading pathname component  */
430             if (namelen < 2)
431             {
432 -               printk ("%s: find_entry(%s): too short\n", DEVFS_NAME, name);
433 +               PRINTK ("(%s): too short\n", name);
434                 return NULL;
435             }
436             for (++name, --namelen; (*name != '/') && (namelen > 0);
437                  ++name, --namelen);
438             if (namelen < 2)
439             {
440 -               printk ("%s: find_entry(%s): too short\n", DEVFS_NAME, name);
441 +               PRINTK ("(%s): too short\n", name);
442                 return NULL;
443             }
444             ++name;
445 @@ -1308,12 +1341,13 @@
446      }
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  */
453  
454  static struct devfs_entry *get_devfs_entry_from_vfs_inode (struct inode *inode)
455  {
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  */
460  
461 @@ -1495,7 +1529,7 @@
462  
463      if (name == NULL)
464      {
465 -       printk ("%s: devfs_register(): NULL name pointer\n", DEVFS_NAME);
466 +       PRINTK ("(): NULL name pointer\n");
467         return NULL;
468      }
469      if (ops == NULL)
470 @@ -1503,23 +1537,19 @@
471         if ( S_ISBLK (mode) ) ops = (void *) get_blkfops (major);
472         if (ops == NULL)
473         {
474 -           printk ("%s: devfs_register(%s): NULL ops pointer\n",
475 -                   DEVFS_NAME, name);
476 +           PRINTK ("(%s): NULL ops pointer\n", name);
477             return NULL;
478         }
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);
482      }
483      if ( S_ISDIR (mode) )
484      {
485 -       printk("%s: devfs_register(%s): creating directories is not allowed\n",
486 -              DEVFS_NAME, name);
487 +       PRINTK ("(%s): creating directories is not allowed\n", name);
488         return NULL;
489      }
490      if ( S_ISLNK (mode) )
491      {
492 -       printk ("%s: devfs_register(%s): creating symlinks is not allowed\n",
493 -               DEVFS_NAME, name);
494 +       PRINTK ("(%s): creating symlinks is not allowed\n", name);
495         return NULL;
496      }
497      if ( ( S_ISCHR (mode) || S_ISBLK (mode) ) &&
498 @@ -1527,8 +1557,8 @@
499      {
500         if ( ( devnum = devfs_alloc_devnum (devtype) ) == NODEV )
501         {
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");
506             return NULL;
507         }
508         major = MAJOR (devnum);
509 @@ -1536,8 +1566,7 @@
510      }
511      if ( ( de = _devfs_prepare_leaf (&dir, name, mode) ) == NULL )
512      {
513 -       printk ("%s: devfs_register(%s): could not prepare leaf\n",
514 -               DEVFS_NAME, name);
515 +       PRINTK ("(%s): could not prepare leaf\n", name);
516         if (devnum != NODEV) devfs_dealloc_devnum (devtype, devnum);
517         return NULL;
518      }
519 @@ -1549,8 +1578,7 @@
520      }
521      else if ( !S_ISREG (mode) )
522      {
523 -       printk ("%s: devfs_register(%s): illegal mode: %x\n",
524 -               DEVFS_NAME, name, mode);
525 +       PRINTK ("(%s): illegal mode: %x\n", name, mode);
526         devfs_put (de);
527         devfs_put (dir);
528         return (NULL);
529 @@ -1574,17 +1602,13 @@
530      if ( ( err = _devfs_append_entry (dir, de, de->u.fcb.removable, NULL) )
531          != 0 )
532      {
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);
536         devfs_put (dir);
537         if (devnum != NODEV) devfs_dealloc_devnum (devtype, devnum);
538         return NULL;
539      }
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);
544 -#endif
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);
548      devfs_put (dir);
549      return de;
550 @@ -1620,7 +1644,7 @@
551  
552  
553  /**
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.
558   *
559 @@ -1628,7 +1652,7 @@
560   *     unlocked by this function.
561   */
562  
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)
565  {
566      int unhooked = _devfs_unhook (de);
567  
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);
575         if (!child) break;
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) );
581 -#endif
582 +       DPRINTK (DEBUG_UNREGISTER, "(%s): child: %p  refcount: %d\n",
583 +                child->name, child, atomic_read (&child->refcount) );
584         devfs_put (child);
585      }
586 -}   /*  End Function unregister  */
587 +}   /*  End Function _devfs_unregister  */
588  
589  
590  /**
591 @@ -1668,14 +1689,12 @@
592  
593  void devfs_unregister (devfs_handle_t de)
594  {
595 +    VERIFY_ENTRY (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) );
601 -#endif
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);
607      devfs_put (de);
608  }   /*  End Function devfs_unregister  */
609  
610 @@ -1691,16 +1710,12 @@
611      if (handle != NULL) *handle = NULL;
612      if (name == NULL)
613      {
614 -       printk ("%s: devfs_do_symlink(): NULL name pointer\n", DEVFS_NAME);
615 +       PRINTK ("(): NULL name pointer\n");
616         return -EINVAL;
617      }
618 -#ifdef CONFIG_DEVFS_DEBUG
619 -    if (devfs_debug & DEBUG_REGISTER)
620 -       printk ("%s: devfs_do_symlink(%s)\n", DEVFS_NAME, name);
621 -#endif
622      if (link == NULL)
623      {
624 -       printk ("%s: devfs_do_symlink(): NULL link pointer\n", DEVFS_NAME);
625 +       PRINTK ("(%s): NULL link pointer\n", name);
626         return -EINVAL;
627      }
628      linklength = strlen (link);
629 @@ -1711,8 +1726,7 @@
630      if ( ( de = _devfs_prepare_leaf (&dir, name, S_IFLNK | S_IRUGO | S_IXUGO) )
631          == NULL )
632      {
633 -       printk ("%s: devfs_do_symlink(%s): could not prepare leaf\n",
634 -               DEVFS_NAME, name);
635 +       PRINTK ("(%s): could not prepare leaf\n", name);
636         kfree (newlink);
637         return -ENOTDIR;
638      }
639 @@ -1722,8 +1736,7 @@
640      de->u.symlink.length = linklength;
641      if ( ( err = _devfs_append_entry (dir, de, FALSE, NULL) ) != 0 )
642      {
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);
646         devfs_put (dir);
647         return err;
648      }
649 @@ -1758,6 +1771,7 @@
650      devfs_handle_t de;
651  
652      if (handle != NULL) *handle = NULL;
653 +    DPRINTK (DEBUG_REGISTER, "(%s)\n", name);
654      err = devfs_do_symlink (dir, name, flags, link, &de, info);
655      if (err) return err;
656      if (handle != NULL) *handle = de;
657 @@ -1787,39 +1801,35 @@
658  
659      if (name == NULL)
660      {
661 -       printk ("%s: devfs_mk_dir(): NULL name pointer\n", DEVFS_NAME);
662 +       PRINTK ("(): NULL name pointer\n");
663         return NULL;
664      }
665      if ( ( de = _devfs_prepare_leaf (&dir, name, MODE_DIR) ) == NULL )
666      {
667 -       printk ("%s: devfs_mk_dir(%s): could not prepare leaf\n",
668 -               DEVFS_NAME, name);
669 +       PRINTK ("(%s): could not prepare leaf\n", name);
670         return NULL;
671      }
672      de->info = info;
673      if ( ( err = _devfs_append_entry (dir, de, FALSE, &old) ) != 0 )
674      {
675  #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,1)
676 -       if (old)
677 +       if ( old && S_ISDIR (old->mode) )
678         {
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;
684             devfs_put (dir);
685             return old;
686         }
687  #endif
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);
692         devfs_put (old);
693         devfs_put (dir);
694         return NULL;
695      }
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);
700 -#endif
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);
704      devfs_put (dir);
705      return de;
706 @@ -1850,7 +1860,7 @@
707                                  char type, int traverse_symlinks)
708  {
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  */
713  
714  
715 @@ -1881,6 +1891,7 @@
716      unsigned int fl = 0;
717  
718      if (de == NULL) return -EINVAL;
719 +    VERIFY_ENTRY (de);
720      if (de->hide) fl |= DEVFS_FL_HIDE;
721      if ( S_ISCHR (de->mode) || S_ISBLK (de->mode) || S_ISREG (de->mode) )
722      {
723 @@ -1904,11 +1915,8 @@
724  int devfs_set_flags (devfs_handle_t de, unsigned int flags)
725  {
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);
731 -#endif
732 +    VERIFY_ENTRY (de);
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) )
736      {
737 @@ -1932,6 +1940,7 @@
738                        unsigned int *minor)
739  {
740      if (de == NULL) return -EINVAL;
741 +    VERIFY_ENTRY (de);
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 )
747  
748      if (de == NULL) return -EINVAL;
749 +    VERIFY_ENTRY (de);
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;
755  
756      if (de == NULL) return NULL;
757 +    VERIFY_ENTRY (de);
758      if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
759         return NULL;
760      if (de->u.fcb.ops == NULL) return NULL;
761 @@ -2031,6 +2042,7 @@
762      struct module *owner;
763  
764      if (de == NULL) return;
765 +    VERIFY_ENTRY (de);
766      if ( !S_ISCHR (de->mode) && !S_ISBLK (de->mode) && !S_ISREG (de->mode) )
767         return;
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)
771  {
772      if (de == NULL) return -EINVAL;
773 +    VERIFY_ENTRY (de);
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)
779  {
780      if (de == NULL) return NULL;
781 +    VERIFY_ENTRY (de);
782      return de->info;
783  }   /*  End Function devfs_get_info  */
784  
785 @@ -2085,6 +2099,7 @@
786  int devfs_set_info (devfs_handle_t de, void *info)
787  {
788      if (de == NULL) return -EINVAL;
789 +    VERIFY_ENTRY (de);
790      de->info = info;
791      return 0;
792  }   /*  End Function devfs_set_info  */
793 @@ -2099,6 +2114,7 @@
794  devfs_handle_t devfs_get_parent (devfs_handle_t de)
795  {
796      if (de == NULL) return NULL;
797 +    VERIFY_ENTRY (de);
798      return de->parent;
799  }   /*  End Function devfs_get_parent  */
800  
801 @@ -2113,6 +2129,7 @@
802  devfs_handle_t devfs_get_first_child (devfs_handle_t de)
803  {
804      if (de == NULL) return NULL;
805 +    VERIFY_ENTRY (de);
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)
811  {
812      if (de == NULL) return NULL;
813 +    VERIFY_ENTRY (de);
814      return de->next;
815  }   /*  End Function devfs_get_next_sibling  */
816  
817 @@ -2143,14 +2161,15 @@
818  void devfs_auto_unregister (devfs_handle_t master, devfs_handle_t slave)
819  {
820      if (master == NULL) return;
821 +    VERIFY_ENTRY (master);
822 +    VERIFY_ENTRY (slave);
823      if (master->slave != NULL)
824      {
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",
828 -               DEVFS_NAME);
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);
834      }
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)
839  {
840      if (master == NULL) return NULL;
841 +    VERIFY_ENTRY (master);
842      return master->slave;
843  }   /*  End Function devfs_get_unregister_slave  */
844  
845 @@ -2181,6 +2201,7 @@
846  const char *devfs_get_name (devfs_handle_t de, unsigned int *namelen)
847  {
848      if (de == NULL) return NULL;
849 +    VERIFY_ENTRY (de);
850      if (namelen != NULL) *namelen = de->namelen;
851      return de->name;
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.
856   *
857 - *     Returns 0 on success, else a negative error code.
858 + *     Returns 0 on success (event was queued), else a negative error code.
859   */
860  
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;
865      buf->u.name = name;
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) )
869         return -ENOENT;
870 -    /*  Possible success  */
871 +    /*  Possible success: event has been queued  */
872      return 0;
873  }   /*  End Function try_modload  */
874  
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)
881 -    {
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);
887 -    }
888 -#endif
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 @@
897  
898  
899  /**
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.
907   */
908  
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)
915  {
916      int is_fcb = FALSE;
917      struct inode *inode;
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 )
921      {
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);
925         return NULL;
926      }
927      if (de->parent)
928 @@ -2578,11 +2593,8 @@
929      }
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);
936 -#endif
937 +    DPRINTK (DEBUG_I_GET, "(%d): VFS inode: %p  devfs_entry: %p\n",
938 +            (int) inode->i_ino, inode, de);
939      inode->i_blocks = 0;
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;
945         }
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);
949         is_fcb = TRUE;
950      }
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);
961 -#endif
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);
964      return inode;
965 -}   /*  End Function get_vfs_inode  */
966 +}   /*  End Function _devfs_get_vfs_inode  */
967  
968  
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);
978 -#endif
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 )
982      {
983        case 0:
984 @@ -2779,13 +2783,7 @@
985  
986  static void devfs_d_release (struct dentry *dentry)
987  {
988 -#ifdef CONFIG_DEVFS_DEBUG
989 -    struct inode *inode = dentry->d_inode;
990 -
991 -    if (devfs_debug & DEBUG_D_RELEASE)
992 -       printk ("%s: d_release(): dentry: %p inode: %p\n",
993 -               DEVFS_NAME, dentry, inode);
994 -#endif
995 +    DPRINTK (DEBUG_D_RELEASE, "(%p): inode: %p\n", dentry, dentry->d_inode);
996  }   /*  End Function devfs_d_release  */
997  
998  /**
999 @@ -2799,14 +2797,11 @@
1000      struct devfs_entry *de;
1001  
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);
1007 -#endif
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;
1016      iput (inode);
1017      devfs_put (de);
1018 @@ -2846,20 +2841,13 @@
1019      /*  Unhash dentry if negative (has no inode)  */
1020      if (inode == NULL)
1021      {
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);
1026 -#endif
1027 +       DPRINTK (DEBUG_D_DELETE, "(%p): dropping negative dentry\n", dentry);
1028         return 1;
1029      }
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);
1036 -#endif
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) )
1041         return 0;
1042 @@ -2876,40 +2864,55 @@
1043      return 0;
1044  }   /*  End Function devfs_d_delete  */
1045  
1046 +struct devfs_lookup_struct
1047 +{
1048 +    devfs_handle_t de;
1049 +    wait_queue_head_t wait_queue;
1050 +};
1051 +
1052  static int devfs_d_revalidate_wait (struct dentry *dentry, int flags)
1053  {
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);
1059  
1060      if ( !dentry->d_inode && is_devfsd_or_child (fs_info) )
1061      {
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;
1066  
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);
1071 -#endif
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);
1079 +       if (de == NULL)
1080 +       {
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;
1087 +       }
1088         /*  Create an inode, now that the driver information is available  */
1089 -       inode = get_vfs_inode (dir->i_sb, de, dentry);
1090 -       devfs_put (de);
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);
1097 -#endif
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);
1102         return 1;
1103      }
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)
1108 +    {
1109 +       add_wait_queue (&lookup_info->wait_queue, &wait);
1110 +       current->state = TASK_UNINTERRUPTIBLE;
1111 +       read_unlock (&parent->u.dir.lock);
1112 +       schedule ();
1113 +    }
1114 +    else read_unlock (&parent->u.dir.lock);
1115      return 1;
1116  }   /*  End Function devfs_d_revalidate_wait  */
1117  
1118 @@ -2918,20 +2921,20 @@
1119  
1120  static struct dentry *devfs_lookup (struct inode *dir, struct dentry *dentry)
1121  {
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;
1128  
1129      /*  Set up the dentry operations before anything else, to ensure cleaning
1130         up on any error  */
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);
1138 -#endif
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);
1147      }
1148 +    lookup_info.de = de;
1149 +    init_waitqueue_head (&lookup_info.wait_queue);
1150 +    dentry->d_fsdata = &lookup_info;
1151      if (de == NULL)
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
1156             can start  */
1157 -       struct devfs_entry tmp;
1158 -
1159         if (try_modload (parent, fs_info,
1160                          dentry->d_name.name, dentry->d_name.len, &tmp) < 0)
1161 -       {
1162 +       {   /*  Lookup event was not queued to devfsd  */
1163             d_add (dentry, NULL);
1164             return NULL;
1165         }
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
1171 -           revalidation  */
1172 -       up (&dir->i_sem);
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
1176 -           early  */
1177 -       if (dentry->d_inode) return NULL;
1178 +    }
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
1183 +       revalidation  */
1184 +    up (&dir->i_sem);
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
1189 +       early  */
1190 +    if (dentry->d_inode) goto out;
1191 +    if (de == NULL)
1192 +    {
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  */
1200      }
1201 -    else
1202 +    /*  Create an inode, now that the driver information is available  */
1203 +    inode = _devfs_get_vfs_inode (dir->i_sb, de, dentry);
1204 +    if (!inode)
1205      {
1206 -       dentry->d_op = &devfs_wait_dops;
1207 -       d_add (dentry, NULL);  /*  Open the floodgates  */
1208 +       retval = ERR_PTR (-ENOMEM);
1209 +       goto out;
1210      }
1211 -    /*  Create an inode, now that the driver information is available  */
1212 -    inode = get_vfs_inode (dir->i_sb, de, dentry);
1213 -    devfs_put (de);
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);
1219 -#endif
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
1226 -           revalidation  */
1227 -       up (&dir->i_sem);
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  */
1230 -    }
1231 -    return NULL;
1232 +out:
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);
1238 +    devfs_put (de);
1239 +    return retval;
1240  }   /*  End Function devfs_lookup  */
1241  
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;
1246  
1247 -#ifdef CONFIG_DEVFS_DEBUG
1248 -    if (devfs_debug & DEBUG_I_UNLINK)
1249 -       printk ("%s: unlink(%s)\n", DEVFS_NAME, dentry->d_name.name);
1250 -#endif
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",
1263 -               DEVFS_NAME, err);
1264 -#endif
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 )
1276         return -ENOMEM;
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);
1281 -#endif
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 )
1293         return -ENOMEM;
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);
1298 -#endif
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;
1307  
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);
1312 -#endif
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 )
1324         return -ENOMEM;
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);
1329 -#endif
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 )
1341         goto out_no_root;
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);
1348 -#endif
1349 +    DPRINTK (DEBUG_S_READ, "(): made devfs ptr: %p\n", sb->u.generic_sbp);
1350      return sb;
1351  
1352  out_no_root:
1353 @@ -3479,6 +3458,10 @@
1354  
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 @@
1365  {
1366      int err;
1367  
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 @@
1378         putname(fs_names);
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);
This page took 0.119294 seconds and 3 git commands to generate.