public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 02/27] allow hard links to directories, opt-in for any filesystem
@ 2006-02-28  6:04 Joshua Hudson
  2006-02-28 11:52 ` Nick Piggin
  0 siblings, 1 reply; 6+ messages in thread
From: Joshua Hudson @ 2006-02-28  6:04 UTC (permalink / raw)
  To: linux-kernel

Patch seems to work, might want more testing.
It probably should not be applied without a discussion, especially
as no filesystem in kernel tree wants this. I am working on a fs that does.

---
--- include/linux/fs.orig.h     2006-02-27 21:45:26.000000000 -0800
+++ include/linux/fs.h  2006-02-27 21:48:17.000000000 -0800
@@ -83,6 +83,8 @@
 /* public flags for file_system_type */
 #define FS_REQUIRES_DEV 1
 #define FS_BINARY_MOUNTDATA 2
+#define FS_ALLOW_HLINK_DIR 4     /* FS will accept hard links to directories */
+#define FS_ALLOW_USER_HLINK_DIR 8 /* And it makes sense for regular users */
 #define FS_REVAL_DOT   16384   /* Check the paths ".", ".." for staleness */
 #define FS_ODD_RENAME  32768   /* Temporary stuff; will go away as soon
                                  * as nfs_rename() will be cleaned up
--- fs/namei.c.orig     2006-02-27 21:55:26.000000000 -0800
+++ fs/namei.c  2006-02-27 22:08:27.000000000 -0800
@@ -2107,7 +2107,14 @@
        if (!dir->i_op || !dir->i_op->link)
                return -EPERM;
        if (S_ISDIR(old_dentry->d_inode->i_mode))
-               return -EPERM;
+       {
+               if (!(old_dentry->d_sb->s_type->fs_flags & FS_ALLOW_HLINK_DIR))
+                       return -EPERM;
+               if (!(old_dentry->d_sb->s_type->fs_flags
+                               & FS_ALLOW_USER_HLINK_DIR)
+                               && !capable(CAP_SYS_ADMIN))
+                       return -EPERM;
+       }

        error = security_inode_link(old_dentry, dir, new_dentry);
        if (error)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-02 21:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-28  6:04 [PATCH 02/27] allow hard links to directories, opt-in for any filesystem Joshua Hudson
2006-02-28 11:52 ` Nick Piggin
2006-02-28 16:57   ` Horst von Brand
2006-03-01  2:12     ` Nick Piggin
2006-03-02 21:10       ` Jan Engelhardt
2006-02-28 20:09   ` Sam Vilain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox