SOURCES: kernel-desktop-supermount-ng.patch (NEW) - a hal-like rem...
czarny
czarny at pld-linux.org
Fri Aug 3 01:07:37 CEST 2007
Author: czarny Date: Thu Aug 2 23:07:37 2007 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- a hal-like removable devices solution; http://supermount-ng.sourceforge.net/ (up2date patches are on the sf d/l page)
- init PLD
---- Files affected:
SOURCES:
kernel-desktop-supermount-ng.patch (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: SOURCES/kernel-desktop-supermount-ng.patch
diff -u /dev/null SOURCES/kernel-desktop-supermount-ng.patch:1.1
--- /dev/null Fri Aug 3 01:07:37 2007
+++ SOURCES/kernel-desktop-supermount-ng.patch Fri Aug 3 01:07:32 2007
@@ -0,0 +1,6507 @@
+diff -Naur linux-2.6.22.1/Documentation/filesystems/00-INDEX linux-2.6.22.1.sm/Documentation/filesystems/00-INDEX
+--- linux-2.6.22.1/Documentation/filesystems/00-INDEX 2007-07-10 13:56:30.000000000 -0500
++++ linux-2.6.22.1.sm/Documentation/filesystems/00-INDEX 2007-07-30 23:39:12.000000000 -0500
+@@ -70,6 +70,8 @@
+ - description of the ROMFS filesystem.
+ smbfs.txt
+ - info on using filesystems with the SMB protocol (Win 3.11 and NT).
++supermount.txt
++ - info on using supermount for removable media.
+ spufs.txt
+ - info and mount options for the SPU filesystem used on Cell.
+ sysfs-pci.txt
+diff -Naur linux-2.6.22.1/Documentation/filesystems/supermount.txt linux-2.6.22.1.sm/Documentation/filesystems/supermount.txt
+--- linux-2.6.22.1/Documentation/filesystems/supermount.txt 1969-12-31 18:00:00.000000000 -0600
++++ linux-2.6.22.1.sm/Documentation/filesystems/supermount.txt 2007-07-30 23:39:12.000000000 -0500
+@@ -0,0 +1,258 @@
++Supermount README
++=================
++
++Running supermount
++------------------
++
++To run supermount, compile and install a kernel with the supermount
++patches and select "Y" to the question
++
++ Supermount removable media support (CONFIG_SUPERMOUNT) [Y/n/?]
++
++when you run "make config". You mount a supermount filesystem with
++the normal mount command, using the syntax
++
++ mount -t supermount -o <superfs-options>,--,<subfs-options> none <mpt>
++
++or by adding correpsonding line to /etc/fstab
++
++ none <mpt> supermount <superfs-options>,--,<subfs-options> 0 0
++
++where
++
++ <superfs-options> are the options you want to pass to supermount
++ itself. These are described below.
++
++ <subfs-options> are the options you want supermount to pass to the
++ dismountable filesystem underneath.
++
++ <mpt> is the mount point where you want your removable media to be
++ mounted.
++
++WARNING: If you get errors with GCC 3.4.X or avobe with inline on subfs.c
++replace all instances of "inline" by "" (nothing) and go ahead.
++[updated for kernel 2.6.X by madgus at gmail.com]
++Many thanks to:
++Robert Sombrutzki <sombrutz at informatik.hu-berlin.de>
++Alexandre Teixeira <alexandre at insignesoftware.com>
++Keith Smith <keith at ksmith.com>
++English
++[http://www.compunauta.com/forums/linux/instalarlinux/supermount_en.html]
++Español
++[http://www.compunauta.com/forums/linux/instalarlinux/supermount_es.html]
++
++WARNING: in the above description `none' is literal word. While device
++is ignored by supermount itself, using real files in this place (real
++device name or mount point directory name) is known to cause problems.
++Some programs - fuser is one of them - will try to descend into filesystem
++if dev can be statted, thus making supermount to attempt to access media.
++This is annoying at best - in the worst case it can take very long time
++during startup or shutdown.
++
++Notice that you do not directly specify the block device you are going
++to mount on the mount command line. This is because the supermount
++filesystem is NOT connected to a block device; rather, supermount is
++responsible for connecting a separate filesystem to the block device.
++You specify the sub-filesystem and block device name by providing the
++<superfs-options> field, where the following options are currently
++recognised:
++
++
++* fs=<filesystem-type> [default is "auto"]
++
++ Specify the subfilesystem type. Not every filesystem type has
++been tested. If you use `auto', it will try the following filesystems
++in order:
++ "udf"
++ "iso9660"
++ "ext2"
++ "vfat"
++ "msdos"
++
++It is also possible to give list of types separated by `:', like
++
++ fs=ext2:vfat
++ - or -
++ fs=udf:iso9660
++
++
++* dev=<block-device> [no default, mandatory]
++
++ Specify the block device on which the subfs is to be mounted.
++
++
++* tray_lock={always,onwrite,never} [default is "onwrite"]
++
++ Specify when supermount is to prevent media removal. `always' means
++on every access (it was default in earlier versions), `onwrite' means only
++for write access and `never' means never :) `onwrite' and `never' are the
++same for ro media like CD-ROM. It is not clear when `never' is actually useful,
++it is presented for completeness only.
++
++* debug[=<bitmap>] [default is no debug]
++
++ Enable debugging code in the supermount filesystem, if
++the debug option was enabled at compile time. By default, debugging
++code is compiled into the kernel but is disabled until a debug mount
++option is seen. <bitmap> is the combination of debug flags, following
++flags are possible:
++
++ 0x001 - "generic" debug (used by supermount_debug) - default
++ 0x002 - trace dentry.c
++ 0x004 - trace file.c
++ 0x008 - trace filemap.c
++ 0x010 - trace mediactl.c
++ 0x020 - trace namei.c
++ 0x040 - trace subfs.c
++ 0x080 - trace super.c
++
++Trace flags turn on tracing of functions in correpsonding files.
++"Generic" debug flag is tested in supermount_debug; for compatibility,
++if no flags are specified, this flag is set.
++
++
++* '--'
++
++ All options after the option string '--' will be passed
++directly to the subfilesystem when it gets mounted.
++
++Errors
++------
++
++In addition to "normal" errors during file operations supermount may
++return following error codes:
++
++* No medium found
++
++ You attempt to access supermounted filesystem when there is no
++medium inserted
++
++* Wrong medium type
++
++ (Not really generated by supermount) You attempt to mount CD
++without data tracks
++
++* Stale NFS file handle
++
++ You attempt to use file handle after medium has been changed.
++
++* No such device or address
++
++ (Not really generated by supermount) device specified in
++dev=<device> option does not exist. Also some drivers return this
++error instead of "No medium found", one example being floppy driver.
++
++* Device or resource busy
++
++ (Not really generated by supermount) device is already mounted.
++Supermount prevents double mount even if kernel otherwise would make it
++possible.
++
++* No such file or directory
++
++ (Not really generated by supermount) file name specified by
++dev=<device> option does not exist
++
++* Operation not permitted
++
++ You attempt to access subfs that is currently disabled
++
++/proc support
++-------------
++
++If kernel has been compiled with procfs support, supermount will provide
++/proc interface to read subfs status and to control some aspects of subfs.
++The following files are created under /proc/fs/supermount:
++
++* version (ro)
++ Shows supermount version.
++
++* subfs (rw)
++
++ Reading this file returns list of all subfs status. One line for
++every subfs is returned; the format is
++
++ <devname> disabled
++ - or -
++ <devname> unmounted
++ - or -
++ <devname> mounted readcount writecount
++
++where <devname> is the string passed in `dev=' parameter during mount.
++`readcount' is number of current subfs "users" needing ro access; `writecount'
++is the number of "users" needing rw mode. It is mostly the number of open
++files, but inode operations also add to these counts. Those operations
++are normally short-lived to be seen.
++
++ Writing this file changes subfs status; the following commands are
++suported:
++
++ <devname> [disable|enable] [release [force]]
++
++`disable' will disable subfs (i.e. any futher attempt to mount is rejected).
++Subfs must be unmounted; use `disable release' or `disable release force' to
++unmount and disable at the same time.
++
++`enable' will enable disabled subfs, it has no effect if subfs is already
++enabled.
++
++`release' will unmount subfs unless it is busy (opencount > 0). To unmount
++busy subfs add `force'; the effect is very much as if media change has been
++detected (with the difference that subfs will be cleanly unmounted).
++
++Some basic sanity checks are performed, i.e. it is impossible to specify
++both `enable' and `disable' or `force' without `release'.
++
++Internals/Locking
++-----------------
++
++THIS SECTION IS PROBABLY INCOMPLETE. CORRECTIONS ARE WELCOME.
++
++Supermount itself is using two locks and relies on two more locking rules
++as implemented by kernel.
++
++* supermount_proc_sem
++
++ Global mutex used to protect list of sbi during access to
++/proc/fs/supermount/subfs
++
++* sbi->sem
++
++ Per-filesystem mutex that protects subfs state (mounted/unmounted).
++Any changes to subfs state (mounting, unmouting, adding or removing file,
++dentry or inode) happen under this mutex.
++
++* inode->i_sem (see Documentation/filesystem/Locking)
++
++ Per-inode mutex used by VFS to serialize inode unlink operation.
++Supermount relies on the fact that link/unlink for an inode are mutually
++locked and thus inode->i_nlink is atomic inside of fs method.
++
++* BKL
++
++ Used to protect device usage count. It is changed in open/release
++and referenced in ioctl all of which run under BKL. Supermount adds mediactl
++and internally wraps it in BKL as well.
++
++Caveats/BUGS
++------------
++
++Inode times are believed to be correctly updated; still it is possible that
++I missed some point.
++
++If subfs is not yet mounted, find /mnt/cdrom fails with "find: /mnt/cdrom
++changed during execution of find". It is unlikely it can be fixed in
++supermount; much more simple is to provide wrapper that will check if subfs
++is mounted and do simple "touch /mnt/cdrom" if not to make sure it is.
++
++Supermount attempts to check for changed media at every operation and
++invalidate and umount old subfs to avoid new media corruption in rw case.
++Still it is possible that kernel will write out stale information and
++it is outside of supermount control.
++
++By default cdrom driver does not check media type i.e. supermount will
++try all configured fs types in turn that may be quite time consuming.
++Use sysctl -w dev.cdrom.check_media=1 to enable it. Comments in cdrom.c
++indicate that some (non conforming) software may have problems with this
++settings. YMMV
++
+diff -Naur linux-2.6.22.1/drivers/cdrom/cdrom.c linux-2.6.22.1.sm/drivers/cdrom/cdrom.c
+--- linux-2.6.22.1/drivers/cdrom/cdrom.c 2007-07-10 13:56:30.000000000 -0500
++++ linux-2.6.22.1.sm/drivers/cdrom/cdrom.c 2007-07-30 23:39:12.000000000 -0500
+@@ -280,6 +280,7 @@
+ #include <linux/fcntl.h>
+ #include <linux/blkdev.h>
+ #include <linux/times.h>
++#include <linux/supermount_media.h>
+
+ #include <asm/uaccess.h>
+
+@@ -344,7 +345,7 @@
+ #define CDROM_DEF_TIMEOUT (7 * HZ)
+
+ /* Not-exported routines. */
+-static int open_for_data(struct cdrom_device_info * cdi);
++static int open_for_data(struct cdrom_device_info * cdi, struct block_device *bdev);
+ static int check_for_audio_disc(struct cdrom_device_info * cdi,
+ struct cdrom_device_ops * cdo);
+ static void sanitize_format(union cdrom_addr *addr,
+@@ -1007,7 +1008,7 @@
+ if ((fp->f_flags & O_NONBLOCK) && (cdi->options & CDO_USE_FFLAGS)) {
+ ret = cdi->ops->open(cdi, 1);
+ } else {
+- ret = open_for_data(cdi);
++ ret = open_for_data(cdi, ip->i_bdev);
+ if (ret)
+ goto err;
+ cdrom_mmc3_profile(cdi);
+@@ -1039,7 +1040,7 @@
+ }
+
+ static
+-int open_for_data(struct cdrom_device_info * cdi)
++int open_for_data(struct cdrom_device_info * cdi, struct block_device *bdev)
+ {
+ int ret;
+ struct cdrom_device_ops *cdo = cdi->ops;
+@@ -1124,7 +1125,8 @@
+ cdinfo(CD_OPEN, "open device failed.\n");
+ goto clean_up_and_return;
+ }
+- if (CDROM_CAN(CDC_LOCK) && (cdi->options & CDO_LOCK)) {
++ if (CDROM_CAN(CDC_LOCK) && (cdi->options & CDO_LOCK) &&
++ supermount_usage_count(bdev, cdi->use_count) > 0) {
+ cdo->lock_door(cdi, 1);
+ cdinfo(CD_OPEN, "door locked.\n");
+ }
+@@ -1216,7 +1218,7 @@
+ cdinfo(CD_CLOSE, "Use count for \"/dev/%s\" now zero\n", cdi->name);
+ if (cdi->use_count == 0)
+ cdrom_dvd_rw_close_write(cdi);
+- if (cdi->use_count == 0 &&
++ if (!supermount_usage_count(fp ? fp->f_dentry->d_inode->i_bdev : 0, cdi->use_count) &&
+ (cdo->capability & CDC_LOCK) && !keeplocked) {
+ cdinfo(CD_CLOSE, "Unlocking door!\n");
+ cdo->lock_door(cdi, 0);
+@@ -1489,6 +1491,38 @@
+ tracks->cdi, tracks->xa);
+ }
+
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++/*
++ * MEDIA_LOCK, MEDIA_UNLOCK
++ * optarg == 0 - do not adjust usage count (compatibility)
++ * optarg == 1 - adjust usage count
++ */
++int cdrom_mediactl(struct cdrom_device_info *cdi, struct block_device *bdev, int op, int optarg)
++{
++ struct cdrom_device_ops *cdo = cdi->ops;
++
++ switch (op) {
++ case MEDIA_LOCK:
++ case MEDIA_UNLOCK:
++ if (op == MEDIA_UNLOCK && optarg) {
++ cdi->use_count--;
++ if (cdi->use_count < 0)
++ cdi->use_count = 0;
++ }
++ if (cdo->capability & ~cdi->mask & CDC_LOCK &&
++ cdi->options & CDO_LOCK &&
++ supermount_usage_count(bdev, cdi->use_count) == 0)
++ cdo->lock_door(cdi, (op == MEDIA_LOCK));
++ if (op == MEDIA_LOCK && optarg)
++ cdi->use_count++;
++ break;
++ default:
++ return -EINVAL;
++ }
++ return 0;
++}
++#endif
++
+ /* Requests to the low-level drivers will /always/ be done in the
+ following format convention:
+
+@@ -2232,14 +2266,18 @@
+ return 0;
+ }
+
+-static int cdrom_ioctl_eject(struct cdrom_device_info *cdi)
++static int cdrom_ioctl_eject(struct cdrom_device_info *cdi, struct inode *ip)
+ {
+ cdinfo(CD_DO_IOCTL, "entering CDROMEJECT\n");
+
+ if (!CDROM_CAN(CDC_OPEN_TRAY))
+ return -ENOSYS;
+- if (cdi->use_count != 1 || keeplocked)
+- return -EBUSY;
++// if (cdi->use_count != 1 || keeplocked)
++// return -EBUSY;
++ if (keeplocked ||
++ (supermount_usage_count(ip->i_bdev,cdi->use_count) != 1))
++ return -EBUSY;
++
+ if (CDROM_CAN(CDC_LOCK)) {
+ int ret = cdi->ops->lock_door(cdi, 0);
+ if (ret)
+@@ -2707,7 +2745,7 @@
+ case CDROMMULTISESSION:
+ return cdrom_ioctl_multisession(cdi, argp);
+ case CDROMEJECT:
+- return cdrom_ioctl_eject(cdi);
++ return cdrom_ioctl_eject(cdi,ip);
+ case CDROMCLOSETRAY:
+ return cdrom_ioctl_closetray(cdi);
+ case CDROMEJECT_SW:
+@@ -3270,6 +3308,9 @@
+ EXPORT_SYMBOL(cdrom_release);
+ EXPORT_SYMBOL(cdrom_ioctl);
+ EXPORT_SYMBOL(cdrom_media_changed);
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++EXPORT_SYMBOL(cdrom_mediactl);
++#endif
+ EXPORT_SYMBOL(cdrom_number_of_slots);
+ EXPORT_SYMBOL(cdrom_mode_select);
+ EXPORT_SYMBOL(cdrom_mode_sense);
+diff -Naur linux-2.6.22.1/drivers/cdrom/cdu31a.c linux-2.6.22.1.sm/drivers/cdrom/cdu31a.c
+--- linux-2.6.22.1/drivers/cdrom/cdu31a.c 2007-07-10 13:56:30.000000000 -0500
++++ linux-2.6.22.1.sm/drivers/cdrom/cdu31a.c 2007-07-30 23:39:12.000000000 -0500
+@@ -2916,6 +2916,25 @@
+
+ static int scd_block_release(struct inode *inode, struct file *file)
+ {
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ /*
++ * This is the same sort of clockload as use in blkdev_get.
++ * We need information whether device is supermounted inside
++ * of cdrom_release to decide if tray must be unlocked.
++ * This information so far is available only by looking
++ * up superblock but it needs struct *bdev and it is not
++ * available in cdrom_release anymore
++ */
++ struct dentry t_dentry;
++ struct file t_file;
++
++ if (!file) {
++ t_file.f_dentry = &t_dentry;
++ t_dentry.d_inode = inode;
++ file = &t_file;
++ }
++#endif
++
+ return cdrom_release(&scd_info, file);
+ }
+
+@@ -2950,6 +2969,13 @@
+ return cdrom_media_changed(&scd_info);
+ }
+
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++static int scd_block_mediactl(struct block_device *bdev, int op, int arg)
++{
++ return cdrom_mediactl(&scd_info, bdev, op, arg);
++}
++#endif
++
+ static struct block_device_operations scd_bdops =
+ {
+ .owner = THIS_MODULE,
+@@ -2957,6 +2983,9 @@
+ .release = scd_block_release,
+ .ioctl = scd_block_ioctl,
+ .media_changed = scd_block_media_changed,
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ .mediactl = scd_block_mediactl,
++#endif
+ };
+
+ static struct gendisk *scd_gendisk;
+diff -Naur linux-2.6.22.1/drivers/cdrom/cm206.c linux-2.6.22.1.sm/drivers/cdrom/cm206.c
+--- linux-2.6.22.1/drivers/cdrom/cm206.c 2007-07-10 13:56:30.000000000 -0500
++++ linux-2.6.22.1.sm/drivers/cdrom/cm206.c 2007-07-30 23:39:12.000000000 -0500
+@@ -1315,6 +1315,25 @@
+
+ static int cm206_block_release(struct inode *inode, struct file *file)
+ {
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ /*
++ * This is the same sort of clockload as use in blkdev_get.
++ * We need information whether device is supermounted inside
++ * of cdrom_release to decide if tray must be unlocked.
++ * This information so far is available only by looking
++ * up superblock but it needs struct *bdev and it is not
++ * available in cdrom_release anymore
++ */
++ struct dentry t_dentry;
++ struct file t_file;
++
++ if (!file) {
++ t_file.f_dentry = &t_dentry;
++ t_dentry.d_inode = inode;
++ file = &t_file;
++ }
++#endif
++
+ return cdrom_release(&cm206_info, file);
+ }
+
+@@ -1344,6 +1363,13 @@
+ return cdrom_media_changed(&cm206_info);
+ }
+
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++static int cm206_block_mediactl(struct block_device *bdev, int op, int arg)
++{
++ return cdrom_mediactl(&cm206_info, bdev, op, arg);
++}
++#endif
++
+ static struct block_device_operations cm206_bdops =
+ {
+ .owner = THIS_MODULE,
+@@ -1351,6 +1377,9 @@
+ .release = cm206_block_release,
+ .ioctl = cm206_block_ioctl,
+ .media_changed = cm206_block_media_changed,
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ .mediactl = cm206_block_mediactl,
++#endif
+ };
+
+ static struct gendisk *cm206_gendisk;
+diff -Naur linux-2.6.22.1/drivers/cdrom/mcdx.c linux-2.6.22.1.sm/drivers/cdrom/mcdx.c
+--- linux-2.6.22.1/drivers/cdrom/mcdx.c 2007-07-10 13:56:30.000000000 -0500
++++ linux-2.6.22.1.sm/drivers/cdrom/mcdx.c 2007-07-30 23:39:12.000000000 -0500
+@@ -220,6 +220,25 @@
+ static int mcdx_block_release(struct inode *inode, struct file *file)
+ {
+ struct s_drive_stuff *p = inode->i_bdev->bd_disk->private_data;
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ /*
++ * This is the same sort of clockload as use in blkdev_get.
++ * We need information whether device is supermounted inside
++ * of cdrom_release to decide if tray must be unlocked.
++ * This information so far is available only by looking
++ * up superblock but it needs struct *bdev and it is not
++ * available in cdrom_release anymore
++ */
++ struct dentry t_dentry;
++ struct file t_file;
++
++ if (!file) {
++ t_file.f_dentry = &t_dentry;
++ t_dentry.d_inode = inode;
++ file = &t_file;
++ }
++#endif
++
+ return cdrom_release(&p->info, file);
+ }
+
+@@ -236,6 +255,14 @@
+ return cdrom_media_changed(&p->info);
+ }
+
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++static int mcdx_block_mediactl(struct block_device *bdev, int op, int arg)
++{
++ struct s_drive_stuff *p = bdev->bd_disk->private_data;
++ return cdrom_mediactl(&p->info, bdev, op, arg);
++}
++#endif
++
+ static struct block_device_operations mcdx_bdops =
+ {
+ .owner = THIS_MODULE,
+@@ -243,6 +270,9 @@
+ .release = mcdx_block_release,
+ .ioctl = mcdx_block_ioctl,
+ .media_changed = mcdx_block_media_changed,
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ .mediactl = mcdx_block_mediactl,
++#endif
+ };
+
+
+diff -Naur linux-2.6.22.1/drivers/cdrom/sbpcd.c linux-2.6.22.1.sm/drivers/cdrom/sbpcd.c
+--- linux-2.6.22.1/drivers/cdrom/sbpcd.c 2007-07-10 13:56:30.000000000 -0500
++++ linux-2.6.22.1.sm/drivers/cdrom/sbpcd.c 2007-07-30 23:39:12.000000000 -0500
+@@ -5040,6 +5040,25 @@
+ static int sbpcd_block_release(struct inode *inode, struct file *file)
+ {
+ struct sbpcd_drive *p = inode->i_bdev->bd_disk->private_data;
++#if defined(CONFIG_SUPERMOUNT) || defined(CONFIG_SUPERMOUNT_MODULE)
++ /*
++ * This is the same sort of clockload as use in blkdev_get.
++ * We need information whether device is supermounted inside
++ * of cdrom_release to decide if tray must be unlocked.
++ * This information so far is available only by looking
++ * up superblock but it needs struct *bdev and it is not
++ * available in cdrom_release anymore
++ */
++ struct dentry t_dentry;
++ struct file t_file;
++
++ if (!file) {
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list