[PATCH 02/27] allow hard links to directories, opt-in for any filesystem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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)
-
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/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux