[PATCH 3/4] reiserfs: private inode abstracted to static inline

2005-03-07 Thread Jeffrey Mahoney
Sorry for the (again) updated diff. This past week doesn't seem to have been
my best for quality control; somewhere the xattr disabled case for
reiserfs_mark_inode_private was dropped. Here's the updated patch.

-Jeff

This patch moves the assignment of i_priv_object to a static inline. This
is in preparation for selinux support in reiserfs.

Changes:
- Added missing macro for xattr disabled case

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/inode.c 
linux-2.6.9.base/fs/reiserfs/inode.c
--- linux-2.6.9/fs/reiserfs/inode.c 2004-11-19 14:40:53.0 -0500
+++ linux-2.6.9.base/fs/reiserfs/inode.c2004-11-30 16:03:42.0 
-0500
@@ -1804,6 +1804,8 @@ int reiserfs_new_inode (struct reiserfs_
 } else if (inode->i_sb->s_flags & MS_POSIXACL) {
reiserfs_warning (inode->i_sb, "ACLs aren't enabled in the fs, "
  "but vfs thinks they are!");
+} else if (is_reiserfs_priv_object (dir)) {
+   reiserfs_mark_inode_private (inode);
 }
 
 insert_inode_hash (inode);
diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/namei.c 
linux-2.6.9.base/fs/reiserfs/namei.c
--- linux-2.6.9/fs/reiserfs/namei.c 2004-08-14 01:37:14.0 -0400
+++ linux-2.6.9.base/fs/reiserfs/namei.c2004-11-30 16:03:42.0 
-0500
@@ -352,7 +352,7 @@ static struct dentry * reiserfs_lookup (
 
/* Propogate the priv_object flag so we know we're in the priv tree */
if (is_reiserfs_priv_object (dir))
-   REISERFS_I(inode)->i_flags |= i_priv_object;
+   reiserfs_mark_inode_private (inode);
 }
 reiserfs_write_unlock(dir->i_sb);
 if ( retval == IO_ERROR ) {
diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/xattr_acl.c 
linux-2.6.9.base/fs/reiserfs/xattr_acl.c
--- linux-2.6.9/fs/reiserfs/xattr_acl.c 2004-11-19 14:40:53.0 -0500
+++ linux-2.6.9.base/fs/reiserfs/xattr_acl.c2004-11-30 16:03:42.0 
-0500
@@ -337,7 +337,7 @@ reiserfs_inherit_default_acl (struct ino
  * would be useless since permissions are ignored, and a pain because
  * it introduces locking cycles */
 if (is_reiserfs_priv_object (dir)) {
-REISERFS_I(inode)->i_flags |= i_priv_object;
+reiserfs_mark_inode_private (inode);
 goto apply_umask;
 }
 
diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/xattr.c 
linux-2.6.9.base/fs/reiserfs/xattr.c
--- linux-2.6.9/fs/reiserfs/xattr.c 2004-11-19 14:40:53.0 -0500
+++ linux-2.6.9.base/fs/reiserfs/xattr.c2004-12-07 13:54:17.336459088 
-0500
@@ -181,8 +181,6 @@ open_xa_dir (const struct inode *inode, 
 dput (xadir);
 return ERR_PTR (-ENODATA);
 }
-/* Newly created object.. Need to mark it private */
-REISERFS_I(xadir->d_inode)->i_flags |= i_priv_object;
 }
 
 dput (xaroot);
@@ -230,8 +228,6 @@ get_xa_file_dentry (const struct inode *
 dput (xafile);
 goto out;
 }
-/* Newly created object.. Need to mark it private */
-REISERFS_I(xafile->d_inode)->i_flags |= i_priv_object;
 }
 
 out:
@@ -1316,7 +1312,7 @@ reiserfs_xattr_init (struct super_block 
 
   if (!err && dentry) {
   s->s_root->d_op = &xattr_lookup_poison_ops;
-  REISERFS_I(dentry->d_inode)->i_flags |= i_priv_object;
+  reiserfs_mark_inode_private (dentry->d_inode);
   REISERFS_SB(s)->priv_root = dentry;
   } else if (!(mount_flags & MS_RDONLY)) { /* xattrs are unavailable */
   /* If we're read-only it just means that the dir hasn't been
diff -ruNpX dontdiff linux-2.6.9/include/linux/reiserfs_xattr.h 
linux-2.6.9.base/include/linux/reiserfs_xattr.h
--- linux-2.6.9/include/linux/reiserfs_xattr.h  2004-08-14 01:38:11.0 
-0400
+++ linux-2.6.9.base/include/linux/reiserfs_xattr.h 2004-11-30 
16:03:42.0 -0500
@@ -103,9 +103,16 @@ reiserfs_read_unlock_xattr_i(struct inod
 up_read (&REISERFS_I(inode)->xattr_sem);
 }
 
+static inline void
+reiserfs_mark_inode_private(struct inode *inode)
+{
+REISERFS_I(inode)->i_flags |= i_priv_object;
+}
+
 #else
 
 #define is_reiserfs_priv_object(inode) 0
+#define reiserfs_mark_inode_private(inode)
 #define reiserfs_getxattr NULL
 #define reiserfs_setxattr NULL
 #define reiserfs_listxattr NULL

-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] blockdev: fixes race between mount/umount

2005-03-04 Thread Jeffrey Mahoney
This patch fixes a race between mount and umount in set_blocksize. The results
can vary between buffer errors and infinite loops in __getblk_slow, and
possibly others.

The patch makes set_blocksize run under the bdev_lock if it is the sole holder
of the block device.

Changes:
- Added missing sync_blockdev in kill_block_super, lost in the shuffle.

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.11-rc4.orig/fs/block_dev.c 
linux-2.6.11-rc4/fs/block_dev.c
--- linux-2.6.11-rc4.orig/fs/block_dev.c2005-02-28 14:06:59.0 
-0500
+++ linux-2.6.11-rc4/fs/block_dev.c 2005-02-28 14:49:52.0 -0500
@@ -62,7 +62,7 @@ static void kill_bdev(struct block_devic
truncate_inode_pages(bdev->bd_inode->i_mapping, 0);
 }  
 
-int set_blocksize(struct block_device *bdev, int size)
+int __set_blocksize(struct block_device *bdev, int size, int sync)
 {
/* Size must be a power of two, and between 512 and PAGE_SIZE */
if (size > PAGE_SIZE || size < 512 || (size & (size-1)))
@@ -74,7 +74,8 @@ int set_blocksize(struct block_device *b
 
/* Don't change the size if it is same as current */
if (bdev->bd_block_size != size) {
-   sync_blockdev(bdev);
+   if (sync)
+   sync_blockdev(bdev);
bdev->bd_block_size = size;
bdev->bd_inode->i_blkbits = blksize_bits(size);
kill_bdev(bdev);
@@ -82,7 +83,7 @@ int set_blocksize(struct block_device *b
return 0;
 }
 
-EXPORT_SYMBOL(set_blocksize);
+EXPORT_SYMBOL(__set_blocksize);
 
 int sb_set_blocksize(struct super_block *sb, int size)
 {
@@ -480,17 +481,19 @@ int bd_claim(struct block_device *bdev, 
 
 EXPORT_SYMBOL(bd_claim);
 
-void bd_release(struct block_device *bdev)
+void __bd_release(struct block_device *bdev, int size)
 {
spin_lock(&bdev_lock);
if (!--bdev->bd_contains->bd_holders)
bdev->bd_contains->bd_holder = NULL;
-   if (!--bdev->bd_holders)
+   if (!--bdev->bd_holders) {
bdev->bd_holder = NULL;
+   set_blocksize_nosync (bdev, size);
+   }
spin_unlock(&bdev_lock);
 }
 
-EXPORT_SYMBOL(bd_release);
+EXPORT_SYMBOL(__bd_release);
 
 /*
  * Tries to open block device by device number.  Use it ONLY if you
@@ -914,10 +917,10 @@ EXPORT_SYMBOL(open_bdev_excl);
  *
  * This is the counterpart to open_bdev_excl().
  */
-void close_bdev_excl(struct block_device *bdev)
+void __close_bdev_excl(struct block_device *bdev, int size)
 {
-   bd_release(bdev);
+   __bd_release(bdev, size);
blkdev_put(bdev);
 }
 
-EXPORT_SYMBOL(close_bdev_excl);
+EXPORT_SYMBOL(__close_bdev_excl);
diff -ruNpX dontdiff linux-2.6.11-rc4.orig/fs/super.c 
linux-2.6.11-rc4/fs/super.c
--- linux-2.6.11-rc4.orig/fs/super.c2005-02-28 14:07:01.0 -0500
+++ linux-2.6.11-rc4/fs/super.c 2005-02-28 14:42:49.0 -0500
@@ -732,8 +732,8 @@ void kill_block_super(struct super_block
 
bdev_uevent(bdev, KOBJ_UMOUNT);
generic_shutdown_super(sb);
-   set_blocksize(bdev, sb->s_old_blocksize);
-   close_bdev_excl(bdev);
+   sync_blockdev(bdev);
+   __close_bdev_excl(bdev, sb->s_old_blocksize);
 }
 
 EXPORT_SYMBOL(kill_block_super);
diff -ruNpX dontdiff linux-2.6.11-rc4.orig/include/linux/fs.h 
linux-2.6.11-rc4/include/linux/fs.h
--- linux-2.6.11-rc4.orig/include/linux/fs.h2005-02-28 14:07:42.0 
-0500
+++ linux-2.6.11-rc4/include/linux/fs.h 2005-02-28 14:50:53.0 -0500
@@ -1294,7 +1294,10 @@ extern long compat_blkdev_ioctl(struct f
 extern int blkdev_get(struct block_device *, mode_t, unsigned);
 extern int blkdev_put(struct block_device *);
 extern int bd_claim(struct block_device *, void *);
-extern void bd_release(struct block_device *);
+extern void __bd_release(struct block_device *, int);
+static inline void bd_release(struct block_device *bdev) {
+   __bd_release (bdev, bdev->bd_block_size);
+}
 
 /* fs/char_dev.c */
 extern int alloc_chrdev_region(dev_t *, unsigned, unsigned, const char *);
@@ -1311,7 +1314,10 @@ extern const char *__bdevname(dev_t, cha
 extern const char *bdevname(struct block_device *bdev, char *buffer);
 extern struct block_device *lookup_bdev(const char *);
 extern struct block_device *open_bdev_excl(const char *, int, void *);
-extern void close_bdev_excl(struct block_device *);
+extern void __close_bdev_excl(struct block_device *, int);
+static inline void close_bdev_excl(struct block_device *bdev) {
+   __close_bdev_excl(bdev, bdev->bd_block_size);
+}
 
 extern void init_special_inode(struct inode *, umode_t, dev_t);
 
@@ -1447,7 +1453,14 @@ extern void file_kill(struct file *f);
 struct bio;
 extern void submit_bio(int, struct bio *);
 extern int bdev_read_only(struct block_device *);
-extern int set_blocksize(struct block_device *, int);
+extern int __set_blocksize(struct block_device *, int, int);
+static inline int set_blocksize(struct block_devi

[PATCH 1/4] vfs: adds the S_PRIVATE flag and adds use to security

2005-03-04 Thread Jeffrey Mahoney
This patch adds an S_PRIVATE flag to inode->i_flags to mark an inode as
filesystem-internal. As such, it should be excepted from the security
infrastructure to allow the filesystem to perform its own access control.

Changes:
- Post-operations for calls that generally instantiate the dentry but
  aren't obligated to now allow for a NULL dentry->d_inode

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.11.orig/include/linux/fs.h 
linux-2.6.11.devel/include/linux/fs.h
--- linux-2.6.11.orig/include/linux/fs.h2005-03-02 02:37:50.0 
-0500
+++ linux-2.6.11.devel/include/linux/fs.h   2005-03-04 09:58:45.0 
-0500
@@ -129,6 +129,7 @@ extern int dir_notify_enable;
 #define S_DIRSYNC  64  /* Directory modifications are synchronous */
 #define S_NOCMTIME 128 /* Do not update file c/mtime */
 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
+#define S_PRIVATE  512 /* Inode is fs-internal */
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
@@ -162,6 +163,7 @@ extern int dir_notify_enable;
 #define IS_DEADDIR(inode)  ((inode)->i_flags & S_DEAD)
 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
+#define IS_PRIVATE(inode)  ((inode)->i_flags & S_PRIVATE)
 
 /* the read-only stuff doesn't really belong here, but any other place is
probably as bad and I don't want to create yet another include file. */
diff -ruNpX dontdiff linux-2.6.11.orig/include/linux/security.h 
linux-2.6.11.devel/include/linux/security.h
--- linux-2.6.11.orig/include/linux/security.h  2005-03-02 02:38:17.0 
-0500
+++ linux-2.6.11.devel/include/linux/security.h 2005-03-04 10:02:40.0 
-0500
@@ -1426,11 +1426,15 @@ static inline void security_sb_post_pivo
 
 static inline int security_inode_alloc (struct inode *inode)
 {
+   if (unlikely (IS_PRIVATE (inode)))
+   return 0;
return security_ops->inode_alloc_security (inode);
 }
 
 static inline void security_inode_free (struct inode *inode)
 {
+   if (unlikely (IS_PRIVATE (inode)))
+   return;
security_ops->inode_free_security (inode);
 }

@@ -1438,6 +1442,8 @@ static inline int security_inode_create 
 struct dentry *dentry,
 int mode)
 {
+   if (unlikely (IS_PRIVATE (dir)))
+   return 0;
return security_ops->inode_create (dir, dentry, mode);
 }
 
@@ -1445,6 +1451,8 @@ static inline void security_inode_post_c
   struct dentry *dentry,
   int mode)
 {
+   if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
+   return;
security_ops->inode_post_create (dir, dentry, mode);
 }
 
@@ -1452,6 +1460,8 @@ static inline int security_inode_link (s
   struct inode *dir,
   struct dentry *new_dentry)
 {
+   if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
+   return 0;
return security_ops->inode_link (old_dentry, dir, new_dentry);
 }
 
@@ -1459,12 +1469,16 @@ static inline void security_inode_post_l
 struct inode *dir,
 struct dentry *new_dentry)
 {
+   if (new_dentry->d_inode && unlikely (IS_PRIVATE (new_dentry->d_inode)))
+   return;
security_ops->inode_post_link (old_dentry, dir, new_dentry);
 }
 
 static inline int security_inode_unlink (struct inode *dir,
 struct dentry *dentry)
 {
+   if (unlikely (IS_PRIVATE (dentry->d_inode)))
+   return 0;
return security_ops->inode_unlink (dir, dentry);
 }
 
@@ -1472,6 +1486,8 @@ static inline int security_inode_symlink
  struct dentry *dentry,
  const char *old_name)
 {
+   if (unlikely (IS_PRIVATE (dir)))
+   return 0;
return security_ops->inode_symlink (dir, dentry, old_name);
 }
 
@@ -1479,6 +1495,8 @@ static inline void security_inode_post_s
struct dentry *dentry,
const char *old_name)
 {
+   if (dentry->d_inode && unlikely (IS_PRIVATE (dentry->d_inode)))
+   return;
security_ops->inode_post_symlink (dir, dentry, old_name);
 }
 
@@ -1486,6 +1504,8 @@ static inline int security_inode_mkdir (
struct dentry *dentry,
int mode)
 {
+   if (unlikely (IS_PRIVATE (dir)))
+   return 0;
return security_ops->inode_mkdir (dir, dentry, mode);
 }
 
@@ -1493,12 +1513,16 @@

[PATCH 3/3] openfirmware: implements hotplug for macio devices

2005-03-01 Thread Jeffrey Mahoney
This patch adds the hotplug routine for generating hotplug events when
devices are seen on the macio bus. It uses the attributed created by the
sysfs nodes to generate the hotplug environment vars for userspace.

In order for hotplug to work with macio devices, patches to module-init-tools
and hotplug must be applied. Those patches are available at:

ftp://ftp.suse.com/pub/people/jeffm/linux/macio-hotplug/

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -rupN -X dontdiff linux-2.6.8/drivers/macintosh/macio_asic.c 
linux-2.6.8.devel/drivers/macintosh/macio_asic.c
--- linux-2.6.8/drivers/macintosh/macio_asic.c  2004-08-14 01:36:45.0 
-0400
+++ linux-2.6.8.devel/drivers/macintosh/macio_asic.c2004-09-16 
17:12:37.242920008 -0400
@@ -126,11 +126,77 @@ static int macio_device_resume(struct de
return 0;
 }
 
+static int macio_hotplug (struct device *dev, char **envp, int num_envp,
+  char *buffer, int buffer_size)
+{
+   struct macio_dev * macio_dev;
+   struct of_device * of;
+   char *scratch, *compat;
+   int i = 0;
+   int length = 0;
+   int cplen, seen = 0;
+
+   if (!dev)
+   return -ENODEV;
+
+   macio_dev = to_macio_device(dev);
+   if (!macio_dev)
+   return -ENODEV;
+
+   of = &macio_dev->ofdev;
+   scratch = buffer;
+
+   /* stuff we want to pass to /sbin/hotplug */
+   envp[i++] = scratch;
+   length += scnprintf (scratch, buffer_size - length, "OF_NAME=%s",
+of->node->name);
+   if ((buffer_size - length <= 0) || (i >= num_envp))
+   return -ENOMEM;
+   ++length;
+   scratch += length;
+
+   envp[i++] = scratch;
+   length += scnprintf (scratch, buffer_size - length, "OF_TYPE=%s",
+of->node->type);
+   if ((buffer_size - length <= 0) || (i >= num_envp))
+   return -ENOMEM;
+   ++length;
+   scratch += length;
+
+   envp[i++] = scratch;
+   length += scnprintf (scratch, buffer_size - length,
+"OF_COMPATIBLE=");
+   if ((buffer_size - length <= 0) || (i >= num_envp))
+   return -ENOMEM;
+   ++length;
+   scratch += length;
+
+   compat = (char *) get_property(of->node, "compatible", &cplen);
+   while (compat && cplen > 0) {
+   int l;
+   length += scnprintf (scratch, buffer_size - length,
+"%s%s", seen ? "," : "", compat);
+   if ((buffer_size - length <= 0) || (i >= num_envp))
+   return -ENOMEM;
+   length++;
+   scratch += length;
+   l = strlen (compat) + 1;
+   compat += l;
+   cplen -= l;
+   seen++;
+   }
+
+   envp[i] = NULL;
+
+   return 0;
+
+}
 extern struct device_attribute macio_dev_attrs[];
 
 struct bus_type macio_bus_type = {
.name   = "macio",
.match  = macio_bus_match,
+   .hotplug = macio_hotplug,
.suspend= macio_device_suspend,
.resume = macio_device_resume,
.dev_attrs = macio_dev_attrs,
 };
 
 static int __init macio_bus_driver_init(void)
-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/3] openfirmware: generate device table for userspace

2005-03-01 Thread Jeffrey Mahoney
This patch converts the usage of struct of_match to struct of_device_id,
similar to pci_device_id. This allows a device table to be generated, which 
can be parsed by depmod(8) to generate a map file for module loading.

In order for hotplug to work with macio devices, patches to module-init-tools
and hotplug must be applied. Those patches are available at:

ftp://ftp.suse.com/pub/people/jeffm/linux/macio-hotplug/

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -rupN -X dontdiff linux-2.6.8/arch/ppc/syslib/of_device.c 
linux-2.6.8.devel/arch/ppc/syslib/of_device.c
--- linux-2.6.8/arch/ppc/syslib/of_device.c 2004-08-14 01:38:10.0 
-0400
+++ linux-2.6.8.devel/arch/ppc/syslib/of_device.c   2004-09-16 
17:12:37.212924568 -0400
@@ -3,6 +3,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -15,20 +16,20 @@
  * Used by a driver to check whether an of_device present in the
  * system is in its list of supported devices.
  */
-const struct of_match * of_match_device(const struct of_match *matches,
+const struct of_device_id * of_match_device(const struct of_device_id *matches,
const struct of_device *dev)
 {
if (!dev->node)
return NULL;
-   while (matches->name || matches->type || matches->compatible) {
+   while (matches->name[0] || matches->type[0] || matches->compatible[0]) {
int match = 1;
-   if (matches->name && matches->name != OF_ANY_MATCH)
+   if (matches->name[0])
match &= dev->node->name
&& !strcmp(matches->name, dev->node->name);
-   if (matches->type && matches->type != OF_ANY_MATCH)
+   if (matches->type[0])
match &= dev->node->type
&& !strcmp(matches->type, dev->node->type);
-   if (matches->compatible && matches->compatible != OF_ANY_MATCH)
+   if (matches->compatible[0])
match &= device_is_compatible(dev->node,
matches->compatible);
if (match)
@@ -42,7 +43,7 @@ static int of_platform_bus_match(struct 
 {
struct of_device * of_dev = to_of_device(dev);
struct of_platform_driver * of_drv = to_of_platform_driver(drv);
-   const struct of_match * matches = of_drv->match_table;
+   const struct of_device_id * matches = of_drv->match_table;
 
if (!matches)
return 0;
@@ -75,7 +76,7 @@ static int of_device_probe(struct device
int error = -ENODEV;
struct of_platform_driver *drv;
struct of_device *of_dev;
-   const struct of_match *match;
+   const struct of_device_id *match;
 
drv = to_of_platform_driver(dev->driver);
of_dev = to_of_device(dev);
diff -rupN -X dontdiff linux-2.6.8/drivers/i2c/busses/i2c-keywest.c 
linux-2.6.8.devel/drivers/i2c/busses/i2c-keywest.c
--- linux-2.6.8/drivers/i2c/busses/i2c-keywest.c2004-09-16 
17:10:39.329845520 -0400
+++ linux-2.6.8.devel/drivers/i2c/busses/i2c-keywest.c  2004-09-16 
17:12:37.215924112 -0400
@@ -694,7 +694,7 @@ dispose_iface(struct device *dev)
 }
 
 static int
-create_iface_macio(struct macio_dev* dev, const struct of_match *match)
+create_iface_macio(struct macio_dev* dev, const struct of_device_id *match)
 {
return create_iface(dev->ofdev.node, &dev->ofdev.dev);
 }
@@ -706,7 +706,7 @@ dispose_iface_macio(struct macio_dev* de
 }
 
 static int
-create_iface_of_platform(struct of_device* dev, const struct of_match *match)
+create_iface_of_platform(struct of_device* dev, const struct of_device_id 
*match)
 {
return create_iface(dev->node, &dev->dev);
 }
@@ -717,10 +717,9 @@ dispose_iface_of_platform(struct of_devi
return dispose_iface(&dev->dev);
 }
 
-static struct of_match i2c_keywest_match[] = 
+static struct of_device_id i2c_keywest_match[] = 
 {
{
-   .name   = OF_ANY_MATCH,
.type   = "i2c",
.compatible = "keywest"
},
diff -rupN -X dontdiff linux-2.6.8/drivers/ide/ppc/pmac.c 
linux-2.6.8.devel/drivers/ide/ppc/pmac.c
--- linux-2.6.8/drivers/ide/ppc/pmac.c  2004-09-16 17:11:14.056566256 -0400
+++ linux-2.6.8.devel/drivers/ide/ppc/pmac.c2004-09-16 17:12:37.221923200 
-0400
@@ -1279,7 +1279,7 @@ pmac_ide_setup_device(pmac_ide_hwif_t *p
  * Attach to a macio probed interface
  */
 static int __devinit
-pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_match *match)
+pmac_ide_macio_attach(struct macio_dev *mdev, const struct of_device_id *match)
 {
unsigned long base, regbase;
int irq;
@@ -1500,27 +1500,19 @@ pmac_ide_pci_resume(struct pci_dev *pdev
return rc;
 }
 
-static struct of_match pmac_ide_macio_match[] = 
+static struct of_device_id pmac_ide_macio_match[] = 
 {
{
.name   = "IDE",
-   .type   = OF_ANY_MATCH,
-   

[PATCH 2/3] openfirmware: adds sysfs nodes for openfirmware devices

2005-03-01 Thread Jeffrey Mahoney
This patch adds sysfs nodes that the hotplug userspace can use to load the
appropriate modules.

In order for hotplug to work with macio devices, patches to module-init-tools
and hotplug must be applied. Those patches are available at:

ftp://ftp.suse.com/pub/people/jeffm/linux/macio-hotplug/

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -rupN -X dontdiff linux-2.6.8/drivers/macintosh/macio_sysfs.c 
linux-2.6.8.devel/drivers/macintosh/macio_sysfs.c
--- linux-2.6.8/drivers/macintosh/macio_sysfs.c 1969-12-31 19:00:00.0 
-0500
+++ linux-2.6.8.devel/drivers/macintosh/macio_sysfs.c   2004-09-16 
17:12:37.244919704 -0400
@@ -0,0 +1,49 @@
+#include 
+#include 
+#include 
+#include 
+
+
+#define macio_config_of_attr(field, format_string)  \
+static ssize_t  \
+field##_show (struct device *dev, char *buf)\
+{   \
+struct macio_dev *mdev = to_macio_device (dev); \
+return sprintf (buf, format_string, mdev->ofdev.node->field); \
+}
+
+static ssize_t
+compatible_show (struct device *dev, char *buf)
+{
+struct of_device *of;
+char *compat;
+int cplen;
+int length = 0;
+
+of = &to_macio_device (dev)->ofdev;
+   compat = (char *) get_property(of->node, "compatible", &cplen);
+   if (!compat) {
+   *buf = '\0';
+   return 0;
+   }
+   while (cplen > 0) {
+   int l;
+   length += sprintf (buf, "%s%s", length ? "," : "", compat);
+   buf += length;
+   l = strlen (compat) + 1;
+   compat += l;
+   cplen -= l;
+   }
+
+   return length;
+}
+
+macio_config_of_attr (name, "%s");
+macio_config_of_attr (type, "%s");
+
+struct device_attribute macio_dev_attrs[] = {
+   __ATTR_RO(name),
+   __ATTR_RO(type),
+   __ATTR_RO(compatible),
+   __ATTR_NULL
+};
diff -rupN -X dontdiff linux-2.6.8/drivers/macintosh/Makefile 
linux-2.6.8.devel/drivers/macintosh/Makefile
--- linux-2.6.8/drivers/macintosh/Makefile  2004-08-14 01:37:40.0 
-0400
+++ linux-2.6.8.devel/drivers/macintosh/Makefile2004-09-16 
17:12:37.252918488 -0400
@@ -4,7 +4,7 @@
 
 # Each configuration option enables a list of files.
 
-obj-$(CONFIG_PPC_PMAC) += macio_asic.o
+obj-$(CONFIG_PPC_PMAC) += macio_asic.o macio_sysfs.o
 
 obj-$(CONFIG_PMAC_PBOOK)   += mediabay.o
 obj-$(CONFIG_MAC_SERIAL)   += macserial.o

diff -rupN -X dontdiff linux-2.6.8/drivers/macintosh/macio_asic.c 
linux-2.6.8.devel/drivers/macintosh/macio_asic.c
--- linux-2.6.8/drivers/macintosh/macio_asic.c  2004-08-14 01:36:45.0 
-0400
+++ linux-2.6.8.devel/drivers/macintosh/macio_asic.c2004-09-16 
17:12:37.242920008 -0400
@@ -126,10 +126,13 @@ static int macio_device_resume(struct de
return 0;
 }
 
+extern struct device_attribute macio_dev_attrs[];
+
 struct bus_type macio_bus_type = {
.name   = "macio",
.match  = macio_bus_match,
.suspend= macio_device_suspend,
.resume = macio_device_resume,
+   .dev_attrs = macio_dev_attrs,
 };
 
 static int __init macio_bus_driver_init(void)
-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/3] openfirmware/macio: implements hotplug for macio devices

2005-03-01 Thread Jeffrey Mahoney

Hello all -

I posted these patches a while ago, and let them fall by the wayside.

The following 3 patches, combined with the userspace patches referenced below,
implement hotplug events for open firmware/macio devices such as apple airport
wireless ethernet cards.

* 01-openfirmware-device-table.diff
  - Converts struct of_match to a MODULE_DEVICE_TABLE-compatible
struct of_device_id
  - Uses the information to generate a device table parsable by
depmod(8)

* 02-openfirmware-sysfs.diff
  - Exports openfirmware variables via sysfs so that coldplug can read and
take appropriate action

* 03-openfirmware-hotplug.diff
  - Adds the hotplug routine for generating hotplug events. Uses the
information published to provide the hotplug environment variables to
userspace.

In addition to the kernel patches, userspace patches for hotplug and
module-init-tools are also required. These patches, including the kernel
patches, are available here:

ftp://ftp.suse.com/pub/people/jeffm/linux/macio-hotplug/

I'd appreciate any comments.

-Jeff

-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 0/4] Allow reiserfs to work with selinux

2005-03-01 Thread Jeffrey Mahoney

Hello all -

I sent out these patches in December, but they were dropped somewhere along the
way. There was only a simple reject from the switch from dentry to inode in
get/set/listsecurity which has been fixed.

I'm posting the following patches against 2.6.11-rc5:
* 01-vfs-private-flag.diff
  - vfs: adds the S_PRIVATE flag and adds use to security
* 02-vfs-private-selinux.diff
  - selinux: internal inode loop needs IS_PRIVATE test
* 03-reiserfs-priv-abstract.diff
  - reiserfs: private inode abstracted to static inline
* 04-vfs-private-reiserfs.diff
  - reiserfs: change reiserfs to use S_PRIVATE

Please apply.

-Jeff

-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 4/4] reiserfs: change reiserfs to use S_PRIVATE

2005-03-01 Thread Jeffrey Mahoney
This patch changes reiserfs to use the VFS level private inode flags, and
eliminates the old reiserfs private inode flag.

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.9.base/include/linux/reiserfs_xattr.h 
linux-2.6.9.private/include/linux/reiserfs_xattr.h
--- linux-2.6.9.base/include/linux/reiserfs_xattr.h 2004-11-30 
16:03:42.0 -0500
+++ linux-2.6.9.private/include/linux/reiserfs_xattr.h  2004-12-07 
14:23:43.266996840 -0500
@@ -31,7 +31,7 @@ struct reiserfs_xattr_handler {
 
 
 #ifdef CONFIG_REISERFS_FS_XATTR
-#define is_reiserfs_priv_object(inode) (REISERFS_I(inode)->i_flags & 
i_priv_object)
+#define is_reiserfs_priv_object(inode) IS_PRIVATE(inode)
 #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
 ssize_t reiserfs_getxattr (struct dentry *dentry, const char *name,
   void *buffer, size_t size);
@@ -106,7 +106,7 @@ reiserfs_read_unlock_xattr_i(struct inod
 static inline void
 reiserfs_mark_inode_private(struct inode *inode)
 {
-REISERFS_I(inode)->i_flags |= i_priv_object;
+inode->i_flags |= S_PRIVATE;
 }
 
 #else

diff -ruNpX dontdiff linux-2.6.9.base/include/linux/reiserfs_fs_i.h 
linux-2.6.9.private/include/linux/reiserfs_fs_i.h
--- linux-2.6.9.base/include/linux/reiserfs_fs_i.h  2004-11-19 
14:40:57.0 -0500
+++ linux-2.6.9.private/include/linux/reiserfs_fs_i.h   2004-12-07 
14:25:40.259211320 -0500
@@ -23,9 +23,8 @@ typedef enum {
   space on crash with some files open, but unlinked. */
 i_link_saved_unlink_mask   =  0x0010,
 i_link_saved_truncate_mask =  0x0020,
-i_priv_object  =  0x0080,
-i_has_xattr_dir=  0x0100,
-i_data_log=  0x0200,
+i_has_xattr_dir=  0x0040,
+i_data_log=  0x0080,
 } reiserfs_inode_flags;
 
 
-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/4] reiserfs: private inode abstracted to static inline

2005-03-01 Thread Jeffrey Mahoney
This patch moves the assignment of i_priv_object to a static inline. This
is in preparation for selinux support in reiserfs.

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/inode.c 
linux-2.6.9.base/fs/reiserfs/inode.c
--- linux-2.6.9/fs/reiserfs/inode.c 2004-11-19 14:40:53.0 -0500
+++ linux-2.6.9.base/fs/reiserfs/inode.c2004-11-30 16:03:42.0 
-0500
@@ -1804,6 +1804,8 @@ int reiserfs_new_inode (struct reiserfs_
 } else if (inode->i_sb->s_flags & MS_POSIXACL) {
reiserfs_warning (inode->i_sb, "ACLs aren't enabled in the fs, "
  "but vfs thinks they are!");
+} else if (is_reiserfs_priv_object (dir)) {
+   reiserfs_mark_inode_private (inode);
 }
 
 insert_inode_hash (inode);
diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/namei.c 
linux-2.6.9.base/fs/reiserfs/namei.c
--- linux-2.6.9/fs/reiserfs/namei.c 2004-08-14 01:37:14.0 -0400
+++ linux-2.6.9.base/fs/reiserfs/namei.c2004-11-30 16:03:42.0 
-0500
@@ -352,7 +352,7 @@ static struct dentry * reiserfs_lookup (
 
/* Propogate the priv_object flag so we know we're in the priv tree */
if (is_reiserfs_priv_object (dir))
-   REISERFS_I(inode)->i_flags |= i_priv_object;
+   reiserfs_mark_inode_private (inode);
 }
 reiserfs_write_unlock(dir->i_sb);
 if ( retval == IO_ERROR ) {
diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/xattr_acl.c 
linux-2.6.9.base/fs/reiserfs/xattr_acl.c
--- linux-2.6.9/fs/reiserfs/xattr_acl.c 2004-11-19 14:40:53.0 -0500
+++ linux-2.6.9.base/fs/reiserfs/xattr_acl.c2004-11-30 16:03:42.0 
-0500
@@ -337,7 +337,7 @@ reiserfs_inherit_default_acl (struct ino
  * would be useless since permissions are ignored, and a pain because
  * it introduces locking cycles */
 if (is_reiserfs_priv_object (dir)) {
-REISERFS_I(inode)->i_flags |= i_priv_object;
+reiserfs_mark_inode_private (inode);
 goto apply_umask;
 }
 
diff -ruNpX dontdiff linux-2.6.9/fs/reiserfs/xattr.c 
linux-2.6.9.base/fs/reiserfs/xattr.c
--- linux-2.6.9/fs/reiserfs/xattr.c 2004-11-19 14:40:53.0 -0500
+++ linux-2.6.9.base/fs/reiserfs/xattr.c2004-12-07 13:54:17.336459088 
-0500
@@ -181,8 +181,6 @@ open_xa_dir (const struct inode *inode, 
 dput (xadir);
 return ERR_PTR (-ENODATA);
 }
-/* Newly created object.. Need to mark it private */
-REISERFS_I(xadir->d_inode)->i_flags |= i_priv_object;
 }
 
 dput (xaroot);
@@ -230,8 +228,6 @@ get_xa_file_dentry (const struct inode *
 dput (xafile);
 goto out;
 }
-/* Newly created object.. Need to mark it private */
-REISERFS_I(xafile->d_inode)->i_flags |= i_priv_object;
 }
 
 out:
@@ -1316,7 +1312,7 @@ reiserfs_xattr_init (struct super_block 
 
   if (!err && dentry) {
   s->s_root->d_op = &xattr_lookup_poison_ops;
-  REISERFS_I(dentry->d_inode)->i_flags |= i_priv_object;
+  reiserfs_mark_inode_private (dentry->d_inode);
   REISERFS_SB(s)->priv_root = dentry;
   } else if (!(mount_flags & MS_RDONLY)) { /* xattrs are unavailable */
   /* If we're read-only it just means that the dir hasn't been
diff -ruNpX dontdiff linux-2.6.9/include/linux/reiserfs_xattr.h 
linux-2.6.9.base/include/linux/reiserfs_xattr.h
--- linux-2.6.9/include/linux/reiserfs_xattr.h  2004-08-14 01:38:11.0 
-0400
+++ linux-2.6.9.base/include/linux/reiserfs_xattr.h 2004-11-30 
16:03:42.0 -0500
@@ -103,6 +103,12 @@ reiserfs_read_unlock_xattr_i(struct inod
 up_read (&REISERFS_I(inode)->xattr_sem);
 }
 
+static inline void
+reiserfs_mark_inode_private(struct inode *inode)
+{
+REISERFS_I(inode)->i_flags |= i_priv_object;
+}
+
 #else
 
 #define is_reiserfs_priv_object(inode) 0
-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 2/4] selinux: internal inode loop needs IS_PRIVATE test

2005-03-01 Thread Jeffrey Mahoney
This patch applies the IS_PRIVATE test to the selinux internal inode loop.

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.9.base/security/selinux/hooks.c 
linux-2.6.9.private/security/selinux/hooks.c
--- linux-2.6.9.base/security/selinux/hooks.c   2004-11-19 14:40:58.0 
-0500
+++ linux-2.6.9.private/security/selinux/hooks.c2004-12-01 
14:38:50.0 -0500
@@ -595,7 +595,8 @@ next_inode:
spin_unlock(&sbsec->isec_lock);
inode = igrab(inode);
if (inode) {
-   inode_doinit(inode);
+   if (!IS_PRIVATE (inode))
+   inode_doinit(inode);
iput(inode);
}
spin_lock(&sbsec->isec_lock);
-- 
Jeff Mahoney
SuSE Labs
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 1/4] vfs: adds the S_PRIVATE flag and adds use to security

2005-03-01 Thread Jeffrey Mahoney
This patch adds an S_PRIVATE flag to inode->i_flags to mark an inode as
filesystem-internal. As such, it should be excepted from the security
infrastructure to allow the filesystem to perform its own access control.

Signed-off-by: Jeff Mahoney <[EMAIL PROTECTED]>

diff -ruNpX dontdiff linux-2.6.11-rc5.orig/include/linux/fs.h 
linux-2.6.11-rc5/include/linux/fs.h
--- linux-2.6.11-rc5.orig/include/linux/fs.h2005-03-01 10:31:13.0 
-0500
+++ linux-2.6.11-rc5/include/linux/fs.h 2005-03-01 10:32:13.0 -0500
@@ -129,6 +129,7 @@ extern int dir_notify_enable;
 #define S_DIRSYNC  64  /* Directory modifications are synchronous */
 #define S_NOCMTIME 128 /* Do not update file c/mtime */
 #define S_SWAPFILE 256 /* Do not truncate: swapon got its bmaps */
+#define S_PRIVATE  512 /* Inode is fs-internal */
 
 /*
  * Note that nosuid etc flags are inode-specific: setting some file-system
@@ -162,6 +163,7 @@ extern int dir_notify_enable;
 #define IS_DEADDIR(inode)  ((inode)->i_flags & S_DEAD)
 #define IS_NOCMTIME(inode) ((inode)->i_flags & S_NOCMTIME)
 #define IS_SWAPFILE(inode) ((inode)->i_flags & S_SWAPFILE)
+#define IS_PRIVATE(inode)  ((inode)->i_flags & S_PRIVATE)
 
 /* the read-only stuff doesn't really belong here, but any other place is
probably as bad and I don't want to create yet another include file. */
diff -ruNpX dontdiff linux-2.6.11-rc5.orig/include/linux/security.h 
linux-2.6.11-rc5/include/linux/security.h
--- linux-2.6.11-rc5.orig/include/linux/security.h  2005-03-01 
10:31:14.0 -0500
+++ linux-2.6.11-rc5/include/linux/security.h   2005-03-01 10:35:26.0 
-0500
@@ -1426,11 +1426,15 @@ static inline void security_sb_post_pivo
 
 static inline int security_inode_alloc (struct inode *inode)
 {
+   if (unlikely (IS_PRIVATE (inode)))
+   return 0;
return security_ops->inode_alloc_security (inode);
 }
 
 static inline void security_inode_free (struct inode *inode)
 {
+   if (unlikely (IS_PRIVATE (inode)))
+   return;
security_ops->inode_free_security (inode);
 }

@@ -1438,6 +1442,8 @@ static inline int security_inode_create 
 struct dentry *dentry,
 int mode)
 {
+   if (unlikely (IS_PRIVATE (dir)))
+   return 0;
return security_ops->inode_create (dir, dentry, mode);
 }
 
@@ -1445,6 +1451,8 @@ static inline void security_inode_post_c
   struct dentry *dentry,
   int mode)
 {
+   if (unlikely (IS_PRIVATE (dentry->d_inode)))
+   return;
security_ops->inode_post_create (dir, dentry, mode);
 }
 
@@ -1452,6 +1460,8 @@ static inline int security_inode_link (s
   struct inode *dir,
   struct dentry *new_dentry)
 {
+   if (unlikely (IS_PRIVATE (old_dentry->d_inode)))
+   return 0;
return security_ops->inode_link (old_dentry, dir, new_dentry);
 }
 
@@ -1459,12 +1469,16 @@ static inline void security_inode_post_l
 struct inode *dir,
 struct dentry *new_dentry)
 {
+   if (unlikely (IS_PRIVATE (new_dentry->d_inode)))
+   return;
security_ops->inode_post_link (old_dentry, dir, new_dentry);
 }
 
 static inline int security_inode_unlink (struct inode *dir,
 struct dentry *dentry)
 {
+   if (unlikely (IS_PRIVATE (dentry->d_inode)))
+   return 0;
return security_ops->inode_unlink (dir, dentry);
 }
 
@@ -1472,6 +1486,8 @@ static inline int security_inode_symlink
  struct dentry *dentry,
  const char *old_name)
 {
+   if (unlikely (IS_PRIVATE (dir)))
+   return 0;
return security_ops->inode_symlink (dir, dentry, old_name);
 }
 
@@ -1479,6 +1495,8 @@ static inline void security_inode_post_s
struct dentry *dentry,
const char *old_name)
 {
+   if (unlikely (IS_PRIVATE (dentry->d_inode)))
+   return;
security_ops->inode_post_symlink (dir, dentry, old_name);
 }
 
@@ -1486,6 +1504,8 @@ static inline int security_inode_mkdir (
struct dentry *dentry,
int mode)
 {
+   if (unlikely (IS_PRIVATE (dir)))
+   return 0;
return security_ops->inode_mkdir (dir, dentry, mode);
 }
 
@@ -1493,12 +1513,16 @@ static inline void security_inode_post_m
  struct dentry *dentry,
  int mode)
 {
+   if (unlikely (IS_PRIVATE (d