[PATCH] devfs v161 available

From: Richard Gooch (rgooch@atnf.csiro.au)
Date: Sun Mar 05 2000 - 23:56:00 EST


  Hi, all. Version 161 of my devfs patch is now available from:
http://www.atnf.csiro.au/~rgooch/linux/kernel-patches.html
The devfs FAQ is also available here.
This work has been sponsored by SGI.

This is against 2.3.49. Highlights of this release:

- Remove /dev/ide when ide-mod is unloaded

- Fixed bug in drivers/block/ide-probe.c when secondary but no primary

- Added DEVFS_FL_NO_PERSISTENCE flag

- Used new DEVFS_FL_NO_PERSISTENCE flag for Unix98 pty slaves

- Removed unnecessary call to <update_devfs_inode_from_entry> in
  <devfs_readdir>

- Only set auto-ownership for /dev/pty/s*

                                Regards,

                                        Richard....
Permanent: rgooch@atnf.csiro.au
Current: rgooch@ras.ucalgary.ca
===============================================================================
diff -urN linux-2.3.49/Documentation/filesystems/devfs/ChangeLog linux/Documentation/filesystems/devfs/ChangeLog
--- linux-2.3.49/Documentation/filesystems/devfs/ChangeLog Mon Feb 21 15:23:20 2000
+++ linux/Documentation/filesystems/devfs/ChangeLog Mon Mar 6 15:09:41 2000
@@ -1463,3 +1463,20 @@
 - Fixed arch/i386/kernel/mtrr.c if procfs and devfs not enabled
 
 - Fixed drivers/char/stallion.c
+===============================================================================
+Changes for patch v161
+
+Work sponsored by SGI
+
+- Remove /dev/ide when ide-mod is unloaded
+
+- Fixed bug in drivers/block/ide-probe.c when secondary but no primary
+
+- Added DEVFS_FL_NO_PERSISTENCE flag
+
+- Used new DEVFS_FL_NO_PERSISTENCE flag for Unix98 pty slaves
+
+- Removed unnecessary call to <update_devfs_inode_from_entry> in
+ <devfs_readdir>
+
+- Only set auto-ownership for /dev/pty/s*
diff -urN linux-2.3.49/Documentation/filesystems/devfs/README linux/Documentation/filesystems/devfs/README
--- linux-2.3.49/Documentation/filesystems/devfs/README Mon Feb 21 15:23:20 2000
+++ linux/Documentation/filesystems/devfs/README Fri Mar 3 15:59:41 2000
@@ -4,7 +4,7 @@
 
                 Richard Gooch <rgooch@atnf.csiro.au>
 
- 11-NOV-1999
+ 3-MAR-2000
 
 
 Conventions used in this document <section>
@@ -22,6 +22,9 @@
 find out more about it at:
 http://www.atnf.csiro.au/~rgooch/linux/
 
+NEWFLASH: The official 2.3.46 kernel has included the devfs
+patch. Future patches will be released which build on this.
+
 
 What is it? <section>
 ===========
@@ -128,14 +131,13 @@
 There is an existing programme called scsidev which will automatically
 create device nodes for SCSI devices. It can do this by scanning files
 in /proc/scsi. Unfortunately, to extend this idea to other device
-nodes would require would require significant modifications to
-existing drivers (so they too would provide information in
-/proc). This is a non-trivial change (I should know: devfs has had to
-do something similar). Once you go to this much effort, you may as
-well use devfs itself (which also provides this information).
-Furthermore, such a system would likely be implemented in an ad-hoc
-fashion, as different drivers will provide their information in
-different ways.
+nodes would require significant modifications to existing drivers (so
+they too would provide information in /proc). This is a non-trivial
+change (I should know: devfs has had to do something similar). Once
+you go to this much effort, you may as well use devfs itself (which
+also provides this information). Furthermore, such a system would
+likely be implemented in an ad-hoc fashion, as different drivers will
+provide their information in different ways.
 Devfs is much cleaner, because it (natually) has a uniform mechanism
 to provide this information: the device nodes themselves!
 
@@ -349,8 +351,8 @@
 
 FreeBSD-current now has a devfs implementation. Solaris 2 has a
 pseudo-devfs (something akin to scsidev but for all devices, with some
-unspecified kernel support). BeOS and Plan9 also have it. SGI's IRIX
-6.4 and above also have a device filesystem.
+unspecified kernel support). BeOS, Plan9 and QNX also have it. SGI's
+IRIX 6.4 and above also have a device filesystem.
 
 While we shouldn't just automatically do something because others do
 it, we should not ignore the work of others either. FreeBSD has a lot
@@ -875,10 +877,7 @@
 
 Please note that using dynamically allocated block device numbers may
 break the NFS daemons (both user and kernel mode), which expect dev_t
-for a given device to be constant over reboots. A simple reboot, with
-no change in your hardware layout, would result in the same device
-numbers being allocated, and hence will not cause a problem for NFS
-daemons.
+for a given device to be constant over the lifetime of remote mounts.
 
 A final note on this scheme: since it doesn't increase the size of
 device numbers, there are no compatibility issues with userspace.
diff -urN linux-2.3.49/drivers/block/ide-probe.c linux/drivers/block/ide-probe.c
--- linux-2.3.49/drivers/block/ide-probe.c Sun Feb 27 15:32:13 2000
+++ linux/drivers/block/ide-probe.c Fri Mar 3 15:30:56 2000
@@ -686,6 +686,7 @@
         struct gendisk *gd, **gdp;
         unsigned int unit, units, minors;
         int *bs, *max_sect, *max_ra;
+ extern devfs_handle_t ide_devfs_handle;
 
         /* figure out maximum drive number on the interface */
         for (units = MAX_DRIVES; units > 0; --units) {
@@ -742,11 +743,11 @@
                         char name[64];
 
                         ide_add_generic_settings(hwif->drives + unit);
- sprintf (name, "ide/host%d/bus%d/target%d/lun%d",
- hwif->channel ? hwif->mate->index : hwif->index,
+ sprintf (name, "host%d/bus%d/target%d/lun%d",
+ (hwif->channel && hwif->mate) ? hwif->mate->index : hwif->index,
                                  hwif->channel, unit, 0);
                         hwif->drives[unit].de =
- devfs_mk_dir (NULL, name, 0, NULL);
+ devfs_mk_dir (ide_devfs_handle, name, 0, NULL);
                 }
         }
 }
diff -urN linux-2.3.49/drivers/block/ide.c linux/drivers/block/ide.c
--- linux-2.3.49/drivers/block/ide.c Sun Feb 27 15:32:14 2000
+++ linux/drivers/block/ide.c Fri Mar 3 15:14:55 2000
@@ -143,6 +143,7 @@
 #include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/ide.h>
+#include <linux/devfs_fs_kernel.h>
 
 #include <asm/byteorder.h>
 #include <asm/irq.h>
@@ -3456,6 +3457,8 @@
 /*
  * Probe module
  */
+devfs_handle_t ide_devfs_handle = NULL;
+
 EXPORT_SYMBOL(ide_probe);
 EXPORT_SYMBOL(drive_is_flashcard);
 EXPORT_SYMBOL(ide_timer_expiry);
@@ -3464,6 +3467,7 @@
 EXPORT_SYMBOL(ide_get_queue);
 EXPORT_SYMBOL(do_ide0_request);
 EXPORT_SYMBOL(ide_add_generic_settings);
+EXPORT_SYMBOL(ide_devfs_handle);
 #if MAX_HWIFS > 1
 EXPORT_SYMBOL(do_ide1_request);
 #endif /* MAX_HWIFS > 1 */
@@ -3545,6 +3549,7 @@
 
         if (!banner_printed) {
                 printk(KERN_INFO "Uniform Multi-Platform E-IDE driver " REVISION "\n");
+ ide_devfs_handle = devfs_mk_dir (NULL, "ide", 3, NULL);
                 banner_printed = 1;
         }
 
@@ -3602,6 +3607,7 @@
 #ifdef CONFIG_PROC_FS
         proc_ide_destroy();
 #endif
+ devfs_unregister (ide_devfs_handle);
 }
 
 #else /* !MODULE */
diff -urN linux-2.3.49/drivers/char/console.c linux/drivers/char/console.c
--- linux-2.3.49/drivers/char/console.c Mon Feb 21 15:37:09 2000
+++ linux/drivers/char/console.c Mon Mar 6 14:58:19 2000
@@ -2564,7 +2564,7 @@
         int i;
 
         for (i = 0; i < console_driver.num; i++)
- tty_register_devfs (&console_driver, 0,
+ tty_register_devfs (&console_driver, DEVFS_FL_AOPEN_NOTIFY,
                                     console_driver.minor_start + i);
 }
 
diff -urN linux-2.3.49/drivers/char/pty.c linux/drivers/char/pty.c
--- linux-2.3.49/drivers/char/pty.c Fri Feb 18 10:29:44 2000
+++ linux/drivers/char/pty.c Mon Mar 6 15:13:23 2000
@@ -329,9 +329,10 @@
         clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
         wake_up_interruptible(&pty->open_wait);
         set_bit(TTY_THROTTLED, &tty->flags);
- /* register a slave for the master */
+ /* Register a slave for the master */
         if (tty->driver.major == PTY_MASTER_MAJOR)
- tty_register_devfs(&tty->link->driver, DEVFS_FL_WAIT,
+ tty_register_devfs(&tty->link->driver,
+ DEVFS_FL_AUTO_OWNER | DEVFS_FL_WAIT,
                                    tty->link->driver.minor_start +
                                    MINOR(tty->device)-tty->driver.minor_start);
         retval = 0;
diff -urN linux-2.3.49/drivers/char/tty_io.c linux/drivers/char/tty_io.c
--- linux-2.3.49/drivers/char/tty_io.c Thu Feb 17 10:42:05 2000
+++ linux/drivers/char/tty_io.c Mon Mar 6 15:15:46 2000
@@ -1321,7 +1321,7 @@
                 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
                 minor -= driver->minor_start;
                 devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start));
- tty_register_devfs(&pts_driver[major], 0,
+ tty_register_devfs(&pts_driver[major], DEVFS_FL_NO_PERSISTENCE,
                                    pts_driver[major].minor_start + minor);
                 noctty = 1;
                 goto init_dev_done;
@@ -2003,7 +2003,6 @@
         struct tty_struct tty;
         char buf[32];
 
- flags |= DEVFS_FL_DEFAULT;
         tty.driver = *driver;
         tty.device = MKDEV (driver->major, minor);
         switch (tty.device) {
@@ -2012,28 +2011,22 @@
                         mode |= S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
                         break;
                 default:
- flags |= DEVFS_FL_AUTO_OWNER;
                         break;
         }
- if ((minor < driver->minor_start) ||
- (minor >= driver->minor_start + driver->num)) {
+ if ( (minor < driver->minor_start) ||
+ (minor >= driver->minor_start + driver->num) ) {
                 printk(KERN_ERR "Attempt to register invalid minor number "
                        "with devfs (%d:%d).\n", (int)driver->major,(int)minor);
                 return;
         }
- if (driver->type == TTY_DRIVER_TYPE_CONSOLE) {
- flags |= DEVFS_FL_AOPEN_NOTIFY;
- flags &= ~DEVFS_FL_AUTO_OWNER;
- }
 # ifdef CONFIG_UNIX98_PTYS
         if ( (driver->major >= UNIX98_PTY_SLAVE_MAJOR) &&
              (driver->major < UNIX98_PTY_SLAVE_MAJOR + UNIX98_NR_MAJORS) ) {
- flags &= ~DEVFS_FL_AUTO_OWNER;
                 uid = current->uid;
                 gid = current->gid;
         }
 # endif
- devfs_register (NULL, tty_name (&tty, buf), 0, flags,
+ devfs_register (NULL, tty_name (&tty, buf), 0,flags | DEVFS_FL_DEFAULT,
                         driver->major, minor, mode, uid, gid,
                         &tty_fops, NULL);
 #endif /* CONFIG_DEVFS_FS */
diff -urN linux-2.3.49/fs/devfs/base.c linux/fs/devfs/base.c
--- linux-2.3.49/fs/devfs/base.c Sun Feb 27 15:33:42 2000
+++ linux/fs/devfs/base.c Mon Mar 6 07:50:13 2000
@@ -426,6 +426,12 @@
                Removed <devfs_fill_file>.
                Work sponsored by SGI.
   v0.92
+ 20000306 Richard Gooch <rgooch@atnf.csiro.au>
+ Added DEVFS_FL_NO_PERSISTENCE flag.
+ Removed unnecessary call to <update_devfs_inode_from_entry> in
+ <devfs_readdir>.
+ Work sponsored by SGI.
+ v0.93
 */
 #include <linux/types.h>
 #include <linux/errno.h>
@@ -460,7 +466,7 @@
 #include <asm/bitops.h>
 #include <asm/atomic.h>
 
-#define DEVFS_VERSION "0.92 (20000203)"
+#define DEVFS_VERSION "0.93 (20000306)"
 
 #ifndef DEVFS_NAME
 # define DEVFS_NAME "devfs"
@@ -601,6 +607,7 @@
     unsigned char registered:1;
     unsigned char show_unreg:1;
     unsigned char hide:1;
+ unsigned char no_persistence:1;
     char name[1]; /* This is just a dummy: the allocated array is
                                  bigger. This is NULL-terminated */
 };
@@ -1240,6 +1247,7 @@
     de->show_unreg = ( (boot_options & OPTION_SHOW)
                         || (flags & DEVFS_FL_SHOW_UNREG) ) ? TRUE : FALSE;
     de->hide = (flags & DEVFS_FL_HIDE) ? TRUE : FALSE;
+ de->no_persistence = (flags & DEVFS_FL_NO_PERSISTENCE) ? TRUE : FALSE;
     devfsd_notify (de, DEVFSD_NOTIFY_REGISTERED, flags & DEVFS_FL_WAIT);
     return de;
 } /* End Function devfs_register */
@@ -1983,24 +1991,17 @@
     else
     {
         if (di->de->u.fcb.auto_owner)
- {
- mode_t mode = di->de->mode;
-
- di->mode = (mode & ~S_IALLUGO) | S_IRUGO | S_IWUGO;
- }
- else
- {
- di->mode = di->de->mode;
- }
+ di->mode = (di->de->mode & ~S_IALLUGO) | S_IRUGO | S_IWUGO;
+ else di->mode = di->de->mode;
         di->uid = di->de->u.fcb.default_uid;
         di->gid = di->de->u.fcb.default_gid;
     }
 } /* End Function update_devfs_inode_from_entry */
 
-static struct devfs_inode *create_devfs_inode (struct devfs_entry *entry,
+static struct devfs_inode *create_devfs_inode (struct devfs_entry *de,
                                                struct fs_info *fs_info)
 /* [SUMMARY] Create a devfs inode entry.
- <entry> The devfs entry to associate the new inode with.
+ <de> The devfs entry to associate the new inode with.
     <fs_info> The FS info.
     [RETURNS] A pointer to the devfs inode on success, else NULL.
 */
@@ -2032,12 +2033,12 @@
     di->nlink = 1;
     fs_info->table[fs_info->num_inodes] = di;
     ++fs_info->num_inodes;
- di->de = entry;
+ di->de = de;
     di->fs_info = fs_info;
- di->prev = entry->last_inode;
- if (entry->first_inode == NULL) entry->first_inode = di;
- else entry->last_inode->next = di;
- entry->last_inode = di;
+ di->prev = de->last_inode;
+ if (de->first_inode == NULL) de->first_inode = di;
+ else de->last_inode->next = di;
+ de->last_inode = di;
     update_devfs_inode_from_entry (di);
 #ifdef CONFIG_DEVFS_DEBUG
     if (devfs_debug & DEBUG_I_CREATE)
@@ -2438,11 +2439,10 @@
             if (di == NULL)
             {
                 if (fs_info->require_explicit) continue;
- /* Have to create the inode right now */
+ /* Have to create the inode right now to get the inum */
                 di = create_devfs_inode (de, fs_info);
                 if (di == NULL) return -ENOMEM;
             }
- else if (di->ctime == 0) update_devfs_inode_from_entry (di);
             err = (*filldir) (dirent, de->name, de->namelen,
                               file->f_pos, di->ino);
             if (err == -EINVAL) break;
@@ -2659,6 +2659,7 @@
             /* Create an inode, now that the driver information is available
              */
             if (di == NULL) di = create_devfs_inode (de, fs_info);
+ else if (de->no_persistence) update_devfs_inode_from_entry (di);
             else if (di->ctime == 0) update_devfs_inode_from_entry (di);
             else di->mode = (de->mode & ~S_IALLUGO) | (di->mode & S_IALLUGO);
             if (di == NULL) return 1;
@@ -2784,6 +2785,7 @@
     }
     /* Create an inode, now that the driver information is available */
     if (di == NULL) di = create_devfs_inode (de, fs_info);
+ else if (de->no_persistence) update_devfs_inode_from_entry (di);
     else if (di->ctime == 0) update_devfs_inode_from_entry (di);
     else di->mode = (de->mode & ~S_IALLUGO) | (di->mode & S_IALLUGO);
     if (di == NULL) return ERR_PTR (-ENOMEM);
@@ -3126,16 +3128,16 @@
 
 static struct inode_operations devfs_iops =
 {
- lookup: devfs_lookup,
- link: devfs_link,
- unlink: devfs_unlink,
- symlink: devfs_symlink,
- mkdir: devfs_mkdir,
- rmdir: devfs_rmdir,
- mknod: devfs_mknod,
- readlink: devfs_readlink,
- follow_link: devfs_follow_link,
- setattr: devfs_notify_change,
+ lookup: devfs_lookup,
+ link: devfs_link,
+ unlink: devfs_unlink,
+ symlink: devfs_symlink,
+ mkdir: devfs_mkdir,
+ rmdir: devfs_rmdir,
+ mknod: devfs_mknod,
+ readlink: devfs_readlink,
+ follow_link: devfs_follow_link,
+ setattr: devfs_notify_change,
 };
 
 static struct super_block *devfs_read_super (struct super_block *sb,
diff -urN linux-2.3.49/include/linux/devfs_fs_kernel.h linux/include/linux/devfs_fs_kernel.h
--- linux-2.3.49/include/linux/devfs_fs_kernel.h Fri Mar 3 09:01:31 2000
+++ linux/include/linux/devfs_fs_kernel.h Mon Mar 6 07:07:50 2000
@@ -16,22 +16,26 @@
       ) ? m : MINOR((inode)->r_dev); })
 
 
-#define DEVFS_FL_NONE 0x000 /* This helps making code more readable */
-#define DEVFS_FL_AUTO_OWNER 0x001 /* When a closed inode is opened the
- ownerships are set to the opening
- process and the protection is set to
- that given in <<mode>>. When the inode
- is closed, ownership reverts back to
- <<uid>> and <<gid>> and the protection
- is set to read-write for all */
-#define DEVFS_FL_SHOW_UNREG 0x002 /* Show unregistered entries in
- directory listings */
-#define DEVFS_FL_HIDE 0x004 /* Do not show entry in directory list */
-#define DEVFS_FL_AUTO_DEVNUM 0x008 /* Automatically generate device number */
-#define DEVFS_FL_AOPEN_NOTIFY 0x010 /* Asynchronously notify devfsd on open */
-#define DEVFS_FL_REMOVABLE 0x020 /* This is a removable media device */
-#define DEVFS_FL_WAIT 0x040 /* Wait for devfsd to finish */
-#define DEVFS_FL_DEFAULT DEVFS_FL_NONE
+#define DEVFS_FL_NONE 0x000 /* This helps to make code more readable
+ */
+#define DEVFS_FL_AUTO_OWNER 0x001 /* When a closed inode is opened the
+ ownerships are set to the opening
+ process and the protection is set to
+ that given in <<mode>>. When the inode
+ is closed, ownership reverts back to
+ <<uid>> and <<gid>> and the protection
+ is set to read-write for all */
+#define DEVFS_FL_SHOW_UNREG 0x002 /* Show unregistered entries in
+ directory listings */
+#define DEVFS_FL_HIDE 0x004 /* Do not show entry in directory list */
+#define DEVFS_FL_AUTO_DEVNUM 0x008 /* Automatically generate device number
+ */
+#define DEVFS_FL_AOPEN_NOTIFY 0x010 /* Asynchronously notify devfsd on open
+ */
+#define DEVFS_FL_REMOVABLE 0x020 /* This is a removable media device */
+#define DEVFS_FL_WAIT 0x040 /* Wait for devfsd to finish */
+#define DEVFS_FL_NO_PERSISTENCE 0x080 /* Forget changes after unregister */
+#define DEVFS_FL_DEFAULT DEVFS_FL_NONE
 
 
 #define DEVFS_SPECIAL_CHR 0

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Mar 07 2000 - 21:00:19 EST