Release 4.11 fs/hfsplus/options.c
/*
* linux/fs/hfsplus/options.c
*
* Copyright (C) 2001
* Brad Boyer (flar@allandria.com)
* (C) 2003 Ardis Technologies <roman@ardistech.com>
*
* Option parsing
*/
#include <linux/string.h>
#include <linux/kernel.h>
#include <linux/sched.h>
#include <linux/parser.h>
#include <linux/nls.h>
#include <linux/mount.h>
#include <linux/seq_file.h>
#include <linux/slab.h>
#include "hfsplus_fs.h"
enum {
opt_creator, opt_type,
opt_umask, opt_uid, opt_gid,
opt_part, opt_session, opt_nls,
opt_nodecompose, opt_decompose,
opt_barrier, opt_nobarrier,
opt_force, opt_err
};
static const match_table_t tokens = {
{ opt_creator, "creator=%s" },
{ opt_type, "type=%s" },
{ opt_umask, "umask=%o" },
{ opt_uid, "uid=%u" },
{ opt_gid, "gid=%u" },
{ opt_part, "part=%u" },
{ opt_session, "session=%u" },
{ opt_nls, "nls=%s" },
{ opt_decompose, "decompose" },
{ opt_nodecompose, "nodecompose" },
{ opt_barrier, "barrier" },
{ opt_nobarrier, "nobarrier" },
{ opt_force, "force" },
{ opt_err, NULL }
};
/* Initialize an options object to reasonable defaults */
void hfsplus_fill_defaults(struct hfsplus_sb_info *opts)
{
if (!opts)
return;
opts->creator = HFSPLUS_DEF_CR_TYPE;
opts->type = HFSPLUS_DEF_CR_TYPE;
opts->umask = current_umask();
opts->uid = current_uid();
opts->gid = current_gid();
opts->part = -1;
opts->session = -1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 56 | 88.89% | 1 | 25.00% |
David Howells | 4 | 6.35% | 1 | 25.00% |
Al Viro | 2 | 3.17% | 1 | 25.00% |
Roman Zippel | 1 | 1.59% | 1 | 25.00% |
Total | 63 | 100.00% | 4 | 100.00% |
/* convert a "four byte character" to a 32 bit int with error checks */
static inline int match_fourchar(substring_t *arg, u32 *result)
{
if (arg->to - arg->from != 4)
return -EINVAL;
memcpy(result, arg->from, 4);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Andrew Morton | 25 | 55.56% | 1 | 50.00% |
Roman Zippel | 20 | 44.44% | 1 | 50.00% |
Total | 45 | 100.00% | 2 | 100.00% |
int hfsplus_parse_options_remount(char *input, int *force)
{
char *p;
substring_t args[MAX_OPT_ARGS];
int token;
if (!input)
return 1;
while ((p = strsep(&input, ",")) != NULL) {
if (!*p)
continue;
token = match_token(p, tokens, args);
switch (token) {
case opt_force:
*force = 1;
break;
default:
break;
}
}
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Christoph Hellwig | 89 | 98.89% | 1 | 50.00% |
Vyacheslav Dubeyko | 1 | 1.11% | 1 | 50.00% |
Total | 90 | 100.00% | 2 | 100.00% |
/* Parse options from mount. Returns 0 on failure */
/* input is the options passed to mount() as a string */
int hfsplus_parse_options(char *input, struct hfsplus_sb_info *sbi)
{
char *p;
substring_t args[MAX_OPT_ARGS];
int tmp, token;
if (!input)
goto done;
while ((p = strsep(&input, ",")) != NULL) {
if (!*p)
continue;
token = match_token(p, tokens, args);
switch (token) {
case opt_creator:
if (match_fourchar(&args[0], &sbi->creator)) {
pr_err("creator requires a 4 character value\n");
return 0;
}
break;
case opt_type:
if (match_fourchar(&args[0], &sbi->type)) {
pr_err("type requires a 4 character value\n");
return 0;
}
break;
case opt_umask:
if (match_octal(&args[0], &tmp)) {
pr_err("umask requires a value\n");
return 0;
}
sbi->umask = (umode_t)tmp;
break;
case opt_uid:
if (match_int(&args[0], &tmp)) {
pr_err("uid requires an argument\n");
return 0;
}
sbi->uid = make_kuid(current_user_ns(), (uid_t)tmp);
if (!uid_valid(sbi->uid)) {
pr_err("invalid uid specified\n");
return 0;
}
break;
case opt_gid:
if (match_int(&args[0], &tmp)) {
pr_err("gid requires an argument\n");
return 0;
}
sbi->gid = make_kgid(current_user_ns(), (gid_t)tmp);
if (!gid_valid(sbi->gid)) {
pr_err("invalid gid specified\n");
return 0;
}
break;
case opt_part:
if (match_int(&args[0], &sbi->part)) {
pr_err("part requires an argument\n");
return 0;
}
break;
case opt_session:
if (match_int(&args[0], &sbi->session)) {
pr_err("session requires an argument\n");
return 0;
}
break;
case opt_nls:
if (sbi->nls) {
pr_err("unable to change nls mapping\n");
return 0;
}
p = match_strdup(&args[0]);
if (p)
sbi->nls = load_nls(p);
if (!sbi->nls) {
pr_err("unable to load nls mapping \"%s\"\n",
p);
kfree(p);
return 0;
}
kfree(p);
break;
case opt_decompose:
clear_bit(HFSPLUS_SB_NODECOMPOSE, &sbi->flags);
break;
case opt_nodecompose:
set_bit(HFSPLUS_SB_NODECOMPOSE, &sbi->flags);
break;
case opt_barrier:
clear_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags);
break;
case opt_nobarrier:
set_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags);
break;
case opt_force:
set_bit(HFSPLUS_SB_FORCE, &sbi->flags);
break;
default:
return 0;
}
}
done:
if (!sbi->nls) {
/* try utf8 first, as this is the old default behaviour */
sbi->nls = load_nls("utf8");
if (!sbi->nls)
sbi->nls = load_nls_default();
if (!sbi->nls)
return 0;
}
return 1;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Roman Zippel | 237 | 42.55% | 5 | 41.67% |
Andrew Morton | 200 | 35.91% | 1 | 8.33% |
Eric W. Biedermann | 48 | 8.62% | 1 | 8.33% |
Christoph Hellwig | 46 | 8.26% | 2 | 16.67% |
Joe Perches | 21 | 3.77% | 1 | 8.33% |
Jim Meyering | 4 | 0.72% | 1 | 8.33% |
Fabian Frederick | 1 | 0.18% | 1 | 8.33% |
Total | 557 | 100.00% | 12 | 100.00% |
int hfsplus_show_options(struct seq_file *seq, struct dentry *root)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(root->d_sb);
if (sbi->creator != HFSPLUS_DEF_CR_TYPE)
seq_show_option_n(seq, "creator", (char *)&sbi->creator, 4);
if (sbi->type != HFSPLUS_DEF_CR_TYPE)
seq_show_option_n(seq, "type", (char *)&sbi->type, 4);
seq_printf(seq, ",umask=%o,uid=%u,gid=%u", sbi->umask,
from_kuid_munged(&init_user_ns, sbi->uid),
from_kgid_munged(&init_user_ns, 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 (test_bit(HFSPLUS_SB_NODECOMPOSE, &sbi->flags))
seq_puts(seq, ",nodecompose");
if (test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags))
seq_puts(seq, ",nobarrier");
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Roman Zippel | 158 | 75.96% | 1 | 14.29% |
Christoph Hellwig | 24 | 11.54% | 2 | 28.57% |
Eric W. Biedermann | 12 | 5.77% | 1 | 14.29% |
Kees Cook | 8 | 3.85% | 1 | 14.29% |
Al Viro | 4 | 1.92% | 1 | 14.29% |
Fabian Frederick | 2 | 0.96% | 1 | 14.29% |
Total | 208 | 100.00% | 7 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Roman Zippel | 533 | 47.72% | 5 | 25.00% |
Andrew Morton | 298 | 26.68% | 1 | 5.00% |
Christoph Hellwig | 175 | 15.67% | 3 | 15.00% |
Eric W. Biedermann | 60 | 5.37% | 1 | 5.00% |
Joe Perches | 21 | 1.88% | 1 | 5.00% |
Kees Cook | 8 | 0.72% | 1 | 5.00% |
Al Viro | 6 | 0.54% | 2 | 10.00% |
Jim Meyering | 4 | 0.36% | 1 | 5.00% |
David Howells | 4 | 0.36% | 1 | 5.00% |
Fabian Frederick | 3 | 0.27% | 1 | 5.00% |
Tejun Heo | 3 | 0.27% | 1 | 5.00% |
Vyacheslav Dubeyko | 1 | 0.09% | 1 | 5.00% |
Steven Whitehouse | 1 | 0.09% | 1 | 5.00% |
Total | 1117 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.