ANDROID: mnt: Add filesystem private data to mount points
This starts to add private data associated directly to mount points. The intent is to give filesystems a sense of where they have come from, as a means of letting a filesystem take different actions based on this information. Change-Id: Ie769d7b3bb2f5972afe05c1bf16cf88c91647ab2 Signed-off-by: Daniel Rosenberg <drosen@google.com>
This commit is contained in:
parent
f32ddec923
commit
6b42d02561
5 changed files with 46 additions and 1 deletions
|
@ -577,6 +577,7 @@ int sb_prepare_remount_readonly(struct super_block *sb)
|
||||||
|
|
||||||
static void free_vfsmnt(struct mount *mnt)
|
static void free_vfsmnt(struct mount *mnt)
|
||||||
{
|
{
|
||||||
|
kfree(mnt->mnt.data);
|
||||||
kfree_const(mnt->mnt_devname);
|
kfree_const(mnt->mnt_devname);
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
free_percpu(mnt->mnt_pcp);
|
free_percpu(mnt->mnt_pcp);
|
||||||
|
@ -942,11 +943,21 @@ vfs_kern_mount(struct file_system_type *type, int flags, const char *name, void
|
||||||
if (!mnt)
|
if (!mnt)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
mnt->mnt.data = NULL;
|
||||||
|
if (type->alloc_mnt_data) {
|
||||||
|
mnt->mnt.data = type->alloc_mnt_data();
|
||||||
|
if (!mnt->mnt.data) {
|
||||||
|
mnt_free_id(mnt);
|
||||||
|
free_vfsmnt(mnt);
|
||||||
|
return ERR_PTR(-ENOMEM);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (flags & MS_KERNMOUNT)
|
if (flags & MS_KERNMOUNT)
|
||||||
mnt->mnt.mnt_flags = MNT_INTERNAL;
|
mnt->mnt.mnt_flags = MNT_INTERNAL;
|
||||||
|
|
||||||
root = mount_fs(type, flags, name, data);
|
root = mount_fs(type, flags, name, data);
|
||||||
if (IS_ERR(root)) {
|
if (IS_ERR(root)) {
|
||||||
|
kfree(mnt->mnt.data);
|
||||||
mnt_free_id(mnt);
|
mnt_free_id(mnt);
|
||||||
free_vfsmnt(mnt);
|
free_vfsmnt(mnt);
|
||||||
return ERR_CAST(root);
|
return ERR_CAST(root);
|
||||||
|
@ -974,6 +985,14 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
|
||||||
if (!mnt)
|
if (!mnt)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
|
if (sb->s_op->clone_mnt_data) {
|
||||||
|
mnt->mnt.data = sb->s_op->clone_mnt_data(old->mnt.data);
|
||||||
|
if (!mnt->mnt.data) {
|
||||||
|
err = -ENOMEM;
|
||||||
|
goto out_free;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE))
|
if (flag & (CL_SLAVE | CL_PRIVATE | CL_SHARED_TO_SLAVE))
|
||||||
mnt->mnt_group_id = 0; /* not a peer of original */
|
mnt->mnt_group_id = 0; /* not a peer of original */
|
||||||
else
|
else
|
||||||
|
@ -1042,6 +1061,7 @@ static struct mount *clone_mnt(struct mount *old, struct dentry *root,
|
||||||
return mnt;
|
return mnt;
|
||||||
|
|
||||||
out_free:
|
out_free:
|
||||||
|
kfree(mnt->mnt.data);
|
||||||
mnt_free_id(mnt);
|
mnt_free_id(mnt);
|
||||||
free_vfsmnt(mnt);
|
free_vfsmnt(mnt);
|
||||||
return ERR_PTR(err);
|
return ERR_PTR(err);
|
||||||
|
@ -2207,8 +2227,14 @@ static int do_remount(struct path *path, int flags, int mnt_flags,
|
||||||
err = change_mount_flags(path->mnt, flags);
|
err = change_mount_flags(path->mnt, flags);
|
||||||
else if (!capable(CAP_SYS_ADMIN))
|
else if (!capable(CAP_SYS_ADMIN))
|
||||||
err = -EPERM;
|
err = -EPERM;
|
||||||
else
|
else {
|
||||||
err = do_remount_sb(sb, flags, data, 0);
|
err = do_remount_sb(sb, flags, data, 0);
|
||||||
|
namespace_lock();
|
||||||
|
lock_mount_hash();
|
||||||
|
propagate_remount(mnt);
|
||||||
|
unlock_mount_hash();
|
||||||
|
namespace_unlock();
|
||||||
|
}
|
||||||
if (!err) {
|
if (!err) {
|
||||||
lock_mount_hash();
|
lock_mount_hash();
|
||||||
mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK;
|
mnt_flags |= mnt->mnt.mnt_flags & ~MNT_USER_SETTABLE_MASK;
|
||||||
|
|
14
fs/pnode.c
14
fs/pnode.c
|
@ -450,3 +450,17 @@ int propagate_umount(struct list_head *list)
|
||||||
__propagate_umount(mnt);
|
__propagate_umount(mnt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int propagate_remount(struct mount *mnt) {
|
||||||
|
struct mount *m;
|
||||||
|
struct super_block *sb = mnt->mnt.mnt_sb;
|
||||||
|
int ret = 0;
|
||||||
|
|
||||||
|
if (sb->s_op->copy_mnt_data) {
|
||||||
|
for (m = first_slave(mnt); m->mnt_slave.next != &mnt->mnt_slave_list; m = next_slave(m)) {
|
||||||
|
sb->s_op->copy_mnt_data(m->mnt.data, mnt->mnt.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
|
@ -44,6 +44,7 @@ int propagate_mnt(struct mount *, struct mountpoint *, struct mount *,
|
||||||
int propagate_umount(struct list_head *);
|
int propagate_umount(struct list_head *);
|
||||||
int propagate_mount_busy(struct mount *, int);
|
int propagate_mount_busy(struct mount *, int);
|
||||||
void propagate_mount_unlock(struct mount *);
|
void propagate_mount_unlock(struct mount *);
|
||||||
|
int propagate_remount(struct mount *);
|
||||||
void mnt_release_group_id(struct mount *);
|
void mnt_release_group_id(struct mount *);
|
||||||
int get_dominating_id(struct mount *mnt, const struct path *root);
|
int get_dominating_id(struct mount *mnt, const struct path *root);
|
||||||
unsigned int mnt_get_count(struct mount *mnt);
|
unsigned int mnt_get_count(struct mount *mnt);
|
||||||
|
|
|
@ -1697,6 +1697,8 @@ struct super_operations {
|
||||||
int (*unfreeze_fs) (struct super_block *);
|
int (*unfreeze_fs) (struct super_block *);
|
||||||
int (*statfs) (struct dentry *, struct kstatfs *);
|
int (*statfs) (struct dentry *, struct kstatfs *);
|
||||||
int (*remount_fs) (struct super_block *, int *, char *);
|
int (*remount_fs) (struct super_block *, int *, char *);
|
||||||
|
void *(*clone_mnt_data) (void *);
|
||||||
|
void (*copy_mnt_data) (void *, void *);
|
||||||
void (*umount_begin) (struct super_block *);
|
void (*umount_begin) (struct super_block *);
|
||||||
|
|
||||||
int (*show_options)(struct seq_file *, struct dentry *);
|
int (*show_options)(struct seq_file *, struct dentry *);
|
||||||
|
@ -1931,6 +1933,7 @@ struct file_system_type {
|
||||||
#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
|
#define FS_RENAME_DOES_D_MOVE 32768 /* FS will handle d_move() during rename() internally. */
|
||||||
struct dentry *(*mount) (struct file_system_type *, int,
|
struct dentry *(*mount) (struct file_system_type *, int,
|
||||||
const char *, void *);
|
const char *, void *);
|
||||||
|
void *(*alloc_mnt_data) (void);
|
||||||
void (*kill_sb) (struct super_block *);
|
void (*kill_sb) (struct super_block *);
|
||||||
struct module *owner;
|
struct module *owner;
|
||||||
struct file_system_type * next;
|
struct file_system_type * next;
|
||||||
|
|
|
@ -67,6 +67,7 @@ struct vfsmount {
|
||||||
struct dentry *mnt_root; /* root of the mounted tree */
|
struct dentry *mnt_root; /* root of the mounted tree */
|
||||||
struct super_block *mnt_sb; /* pointer to superblock */
|
struct super_block *mnt_sb; /* pointer to superblock */
|
||||||
int mnt_flags;
|
int mnt_flags;
|
||||||
|
void *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct file; /* forward dec */
|
struct file; /* forward dec */
|
||||||
|
|
Loading…
Add table
Reference in a new issue