Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 84784
b: refs/heads/master
c: b3b304a
h: refs/heads/master
v: v3
  • Loading branch information
Miklos Szeredi authored and Linus Torvalds committed Feb 8, 2008
1 parent 110e2f0 commit 66caf47
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f84e3f521e1449300e0fdc314b7b43b418a66dc3
refs/heads/master: b3b304a23a8f7ae4c40c7b512ee45afae0010a70
49 changes: 44 additions & 5 deletions trunk/fs/namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,50 @@ void mnt_unpin(struct vfsmount *mnt)

EXPORT_SYMBOL(mnt_unpin);

static inline void mangle(struct seq_file *m, const char *s)
{
seq_escape(m, s, " \t\n\\");
}

/*
* Simple .show_options callback for filesystems which don't want to
* implement more complex mount option showing.
*
* See also save_mount_options().
*/
int generic_show_options(struct seq_file *m, struct vfsmount *mnt)
{
const char *options = mnt->mnt_sb->s_options;

if (options != NULL && options[0]) {
seq_putc(m, ',');
mangle(m, options);
}

return 0;
}
EXPORT_SYMBOL(generic_show_options);

/*
* If filesystem uses generic_show_options(), this function should be
* called from the fill_super() callback.
*
* The .remount_fs callback usually needs to be handled in a special
* way, to make sure, that previous options are not overwritten if the
* remount fails.
*
* Also note, that if the filesystem's .remount_fs function doesn't
* reset all options to their default value, but changes only newly
* given options, then the displayed options will not reflect reality
* any more.
*/
void save_mount_options(struct super_block *sb, char *options)
{
kfree(sb->s_options);
sb->s_options = kstrdup(options, GFP_KERNEL);
}
EXPORT_SYMBOL(save_mount_options);

/* iterator */
static void *m_start(struct seq_file *m, loff_t *pos)
{
Expand All @@ -341,11 +385,6 @@ static void m_stop(struct seq_file *m, void *v)
up_read(&namespace_sem);
}

static inline void mangle(struct seq_file *m, const char *s)
{
seq_escape(m, s, " \t\n\\");
}

static int show_vfsmnt(struct seq_file *m, void *v)
{
struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list);
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ static inline void destroy_super(struct super_block *s)
{
security_sb_free(s);
kfree(s->s_subtype);
kfree(s->s_options);
kfree(s);
}

Expand Down
9 changes: 9 additions & 0 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1038,6 +1038,12 @@ struct super_block {
* in /proc/mounts will be "type.subtype"
*/
char *s_subtype;

/*
* Saved mount options for lazy filesystems using
* generic_show_options()
*/
char *s_options;
};

extern struct timespec current_fs_time(struct super_block *sb);
Expand Down Expand Up @@ -1970,6 +1976,9 @@ extern int __must_check inode_setattr(struct inode *, struct iattr *);

extern void file_update_time(struct file *file);

extern int generic_show_options(struct seq_file *m, struct vfsmount *mnt);
extern void save_mount_options(struct super_block *sb, char *options);

static inline ino_t parent_ino(struct dentry *dentry)
{
ino_t res;
Expand Down

0 comments on commit 66caf47

Please sign in to comment.