Commit 717dd80e authored by Roman Zippel's avatar Roman Zippel Committed by Linus Torvalds

[PATCH] hfs: show_options support

This adds support for show_options.  It also fixes some namespace polution in
the hfsplus driver.
Signed-off-by: default avatarRoman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent a5e3985f
...@@ -15,8 +15,10 @@ ...@@ -15,8 +15,10 @@
#include <linux/config.h> #include <linux/config.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/blkdev.h> #include <linux/blkdev.h>
#include <linux/mount.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/parser.h> #include <linux/parser.h>
#include <linux/seq_file.h>
#include <linux/vfs.h> #include <linux/vfs.h>
#include "hfs_fs.h" #include "hfs_fs.h"
...@@ -111,6 +113,28 @@ static int hfs_remount(struct super_block *sb, int *flags, char *data) ...@@ -111,6 +113,28 @@ static int hfs_remount(struct super_block *sb, int *flags, char *data)
return 0; return 0;
} }
static int hfs_show_options(struct seq_file *seq, struct vfsmount *mnt)
{
struct hfs_sb_info *sbi = HFS_SB(mnt->mnt_sb);
if (sbi->s_creator != cpu_to_be32(0x3f3f3f3f))
seq_printf(seq, ",creator=%.4s", (char *)&sbi->s_creator);
if (sbi->s_type != cpu_to_be32(0x3f3f3f3f))
seq_printf(seq, ",type=%.4s", (char *)&sbi->s_type);
seq_printf(seq, ",uid=%u,gid=%u", sbi->s_uid, sbi->s_gid);
if (sbi->s_file_umask != 0133)
seq_printf(seq, ",file_umask=%o", sbi->s_file_umask);
if (sbi->s_dir_umask != 0022)
seq_printf(seq, ",dir_umask=%o", sbi->s_dir_umask);
if (sbi->part >= 0)
seq_printf(seq, ",part=%u", sbi->part);
if (sbi->session >= 0)
seq_printf(seq, ",session=%u", sbi->session);
if (sbi->s_quiet)
seq_printf(seq, ",quiet");
return 0;
}
static struct inode *hfs_alloc_inode(struct super_block *sb) static struct inode *hfs_alloc_inode(struct super_block *sb)
{ {
struct hfs_inode_info *i; struct hfs_inode_info *i;
...@@ -133,6 +157,7 @@ static struct super_operations hfs_super_operations = { ...@@ -133,6 +157,7 @@ static struct super_operations hfs_super_operations = {
.write_super = hfs_write_super, .write_super = hfs_write_super,
.statfs = hfs_statfs, .statfs = hfs_statfs,
.remount_fs = hfs_remount, .remount_fs = hfs_remount,
.show_options = hfs_show_options,
}; };
enum { enum {
......
...@@ -343,8 +343,9 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name, ...@@ -343,8 +343,9 @@ ssize_t hfsplus_getxattr(struct dentry *dentry, const char *name,
ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size); ssize_t hfsplus_listxattr(struct dentry *dentry, char *buffer, size_t size);
/* options.c */ /* options.c */
int parse_options(char *, struct hfsplus_sb_info *); int hfsplus_parse_options(char *, struct hfsplus_sb_info *);
void fill_defaults(struct hfsplus_sb_info *); void hfsplus_fill_defaults(struct hfsplus_sb_info *);
int hfsplus_show_options(struct seq_file *, struct vfsmount *);
/* tables.c */ /* tables.c */
extern u16 hfsplus_case_fold_table[]; extern u16 hfsplus_case_fold_table[];
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/parser.h> #include <linux/parser.h>
#include <linux/nls.h> #include <linux/nls.h>
#include <linux/mount.h>
#include <linux/seq_file.h>
#include "hfsplus_fs.h" #include "hfsplus_fs.h"
enum { enum {
...@@ -38,7 +40,7 @@ static match_table_t tokens = { ...@@ -38,7 +40,7 @@ static match_table_t tokens = {
}; };
/* Initialize an options object to reasonable defaults */ /* Initialize an options object to reasonable defaults */
void fill_defaults(struct hfsplus_sb_info *opts) void hfsplus_fill_defaults(struct hfsplus_sb_info *opts)
{ {
if (!opts) if (!opts)
return; return;
...@@ -63,7 +65,7 @@ static inline int match_fourchar(substring_t *arg, u32 *result) ...@@ -63,7 +65,7 @@ static inline int match_fourchar(substring_t *arg, u32 *result)
/* Parse options from mount. Returns 0 on failure */ /* Parse options from mount. Returns 0 on failure */
/* input is the options passed to mount() as a string */ /* input is the options passed to mount() as a string */
int parse_options(char *input, struct hfsplus_sb_info *sbi) int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
{ {
char *p; char *p;
substring_t args[MAX_OPT_ARGS]; substring_t args[MAX_OPT_ARGS];
...@@ -160,3 +162,23 @@ int parse_options(char *input, struct hfsplus_sb_info *sbi) ...@@ -160,3 +162,23 @@ int parse_options(char *input, struct hfsplus_sb_info *sbi)
return 1; return 1;
} }
int hfsplus_show_options(struct seq_file *seq, struct vfsmount *mnt)
{
struct hfsplus_sb_info *sbi = &HFSPLUS_SB(mnt->mnt_sb);
if (sbi->creator != HFSPLUS_DEF_CR_TYPE)
seq_printf(seq, ",creator=%.4s", (char *)&sbi->creator);
if (sbi->type != HFSPLUS_DEF_CR_TYPE)
seq_printf(seq, ",type=%.4s", (char *)&sbi->type);
seq_printf(seq, ",umask=%o,uid=%u,gid=%u", sbi->umask, sbi->uid, sbi->gid);
if (sbi->part >= 0)
seq_printf(seq, ",part=%u", sbi->part);
if (sbi->session >= 0)
seq_printf(seq, ",session=%u", sbi->session);
if (sbi->nls)
seq_printf(seq, ",nls=%s", sbi->nls->charset);
if (sbi->flags & HFSPLUS_SB_NODECOMPOSE)
seq_printf(seq, ",nodecompose");
return 0;
}
...@@ -277,6 +277,7 @@ static struct super_operations hfsplus_sops = { ...@@ -277,6 +277,7 @@ static struct super_operations hfsplus_sops = {
.write_super = hfsplus_write_super, .write_super = hfsplus_write_super,
.statfs = hfsplus_statfs, .statfs = hfsplus_statfs,
.remount_fs = hfsplus_remount, .remount_fs = hfsplus_remount,
.show_options = hfsplus_show_options,
}; };
static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
...@@ -297,8 +298,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent) ...@@ -297,8 +298,8 @@ static int hfsplus_fill_super(struct super_block *sb, void *data, int silent)
memset(sbi, 0, sizeof(HFSPLUS_SB(sb))); memset(sbi, 0, sizeof(HFSPLUS_SB(sb)));
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
INIT_HLIST_HEAD(&sbi->rsrc_inodes); INIT_HLIST_HEAD(&sbi->rsrc_inodes);
fill_defaults(sbi); hfsplus_fill_defaults(sbi);
if (!parse_options(data, sbi)) { if (!hfsplus_parse_options(data, sbi)) {
if (!silent) if (!silent)
printk("HFS+-fs: unable to parse mount options\n"); printk("HFS+-fs: unable to parse mount options\n");
err = -EINVAL; err = -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment