initial commit support and test loopback block device as a branch Signed-off-by: J. R. Okajima <hooanon05@xxxxxxxxxxx> --- fs/aufs/loop.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ fs/aufs/loop.h | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 0 deletions(-) create mode 100644 fs/aufs/loop.c create mode 100644 fs/aufs/loop.h diff --git a/fs/aufs/loop.c b/fs/aufs/loop.c new file mode 100644 index 0000000..84a940f --- /dev/null +++ b/fs/aufs/loop.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2005-2009 Junjiro R. Okajima + * + * This program, aufs is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +/* + * support for loopback block device as a branch + */ + +#include <linux/loop.h> +#include "aufs.h" + +/* + * test if two lower dentries have overlapping branches. + */ +int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1, + struct dentry *h_d2) +{ + struct inode *h_inode; + struct loop_device *l; + + h_inode = h_d1->d_inode; + if (MAJOR(h_inode->i_sb->s_dev) != LOOP_MAJOR) + return 0; + + l = h_inode->i_sb->s_bdev->bd_disk->private_data; + h_d1 = l->lo_backing_file->f_dentry; + /* h_d1 can be local NFS. in this case aufs cannot detect the loop */ + if (unlikely(h_d1->d_sb == sb)) + return 1; + return !!au_test_subdir(h_d1, h_d2); +} + +/* true if a kernel thread named 'loop[0-9].*' accesses a file */ +int au_test_loopback_kthread(void) +{ + const char c = current->comm[4]; + + return current->mm == NULL + && '0' <= c && c <= '9' + && strncmp(current->comm, "loop", 4) == 0; +} diff --git a/fs/aufs/loop.h b/fs/aufs/loop.h new file mode 100644 index 0000000..1c0ee40 --- /dev/null +++ b/fs/aufs/loop.h @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2005-2009 Junjiro R. Okajima + * + * This program, aufs is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +/* + * support for loopback mount as a branch + */ + +#ifndef __AUFS_LOOP_H__ +#define __AUFS_LOOP_H__ + +#ifdef __KERNEL__ + +#include <linux/fs.h> + +#ifdef CONFIG_AUFS_BDEV_LOOP +/* loop.c */ +int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1, + struct dentry *h_d2); +int au_test_loopback_kthread(void); +#else +static inline +int au_test_loopback_overlap(struct super_block *sb, struct dentry *h_d1, + struct dentry *h_d2) +{ + return 0; +} + +static inline int au_test_loopback_kthread(void) +{ + return 0; +} +#endif /* BLK_DEV_LOOP */ + +#endif /* __KERNEL__ */ +#endif /* __AUFS_LOOP_H__ */ -- 1.6.1.284.g5dc13 -- To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html