From 36b475f258863580347e355e15668739afdf7fb8 Mon Sep 17 00:00:00 2001 From: Erez Zadok Date: Sun, 24 Nov 2013 00:55:55 -0500 Subject: [PATCH] Uniofs: port to 3.4 Signed-off-by: Erez Zadok --- fs/unionfs/commonfops.c | 52 +++++++++++++++++++++++++++++++++++++++-- fs/unionfs/main.c | 2 +- fs/unionfs/union.h | 2 -- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/fs/unionfs/commonfops.c b/fs/unionfs/commonfops.c index 71cacfe9f92..970b252b7d8 100644 --- a/fs/unionfs/commonfops.c +++ b/fs/unionfs/commonfops.c @@ -18,6 +18,54 @@ #include "union.h" +#define __NFDBITS (8 * sizeof(unsigned long)) +#define __FDSET_LONGS (__FD_SETSIZE/__NFDBITS) +static inline void __FD_SET(unsigned long __fd, __kernel_fd_set *__fdsetp) +{ + unsigned long __tmp = __fd / __NFDBITS; + unsigned long __rem = __fd % __NFDBITS; + __fdsetp->fds_bits[__tmp] |= (1UL<<__rem); +} +static inline void __FD_ZERO(__kernel_fd_set *__p) +{ + unsigned long *__tmp = __p->fds_bits; + int __i; + + if (__builtin_constant_p(__FDSET_LONGS)) { + switch (__FDSET_LONGS) { + case 16: + __tmp[ 0] = 0; __tmp[ 1] = 0; + __tmp[ 2] = 0; __tmp[ 3] = 0; + __tmp[ 4] = 0; __tmp[ 5] = 0; + __tmp[ 6] = 0; __tmp[ 7] = 0; + __tmp[ 8] = 0; __tmp[ 9] = 0; + __tmp[10] = 0; __tmp[11] = 0; + __tmp[12] = 0; __tmp[13] = 0; + __tmp[14] = 0; __tmp[15] = 0; + return; + + case 8: + __tmp[ 0] = 0; __tmp[ 1] = 0; + __tmp[ 2] = 0; __tmp[ 3] = 0; + __tmp[ 4] = 0; __tmp[ 5] = 0; + __tmp[ 6] = 0; __tmp[ 7] = 0; + return; + + case 4: + __tmp[ 0] = 0; __tmp[ 1] = 0; + __tmp[ 2] = 0; __tmp[ 3] = 0; + return; + } + } + __i = __FDSET_LONGS; + while (__i) { + __i--; + *__tmp = 0; + __tmp++; + } +} + + /* * 1) Copyup the file * 2) Rename the file to '.unionfs' - obviously @@ -781,14 +829,14 @@ static int unionfs_ioctl_queryfile(struct file *file, struct dentry *parent, bstart = dbstart(dentry); bend = dbend(dentry); - FD_ZERO(&branchlist); + __FD_ZERO(&branchlist); for (bindex = bstart; bindex <= bend; bindex++) { lower_dentry = unionfs_lower_dentry_idx(dentry, bindex); if (!lower_dentry) continue; if (likely(lower_dentry->d_inode)) - FD_SET(bindex, &branchlist); + __FD_SET(bindex, &branchlist); /* purge any lower objects after partial_lookup */ if (bindex < orig_bstart || bindex > orig_bend) { dput(lower_dentry); diff --git a/fs/unionfs/main.c b/fs/unionfs/main.c index ee78f1d90c9..bf7b72bc8e2 100644 --- a/fs/unionfs/main.c +++ b/fs/unionfs/main.c @@ -599,7 +599,7 @@ static int unionfs_read_super(struct super_block *sb, void *raw_data, err = PTR_ERR(inode); goto out_dput; } - sb->s_root = d_alloc_root(inode); + sb->s_root = d_make_root(inode); if (unlikely(!sb->s_root)) { err = -ENOMEM; goto out_iput; diff --git a/fs/unionfs/union.h b/fs/unionfs/union.h index 8e7fcfba7b5..f074970581b 100644 --- a/fs/unionfs/union.h +++ b/fs/unionfs/union.h @@ -48,8 +48,6 @@ #include #include -#include - #include /* the file system name */ -- 2.34.1