OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [linux/] [linux-2.4/] [fs/] [hfsplus/] [options.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1275 phoenix
/*
2
 *  linux/fs/hfsplus/options.c
3
 *
4
 * Copyright (C) 2001
5
 * Brad Boyer (flar@allandria.com)
6
 * (C) 2003 Ardis Technologies <roman@ardistech.com>
7
 *
8
 * Option parsing
9
 */
10
 
11
#include <linux/string.h>
12
#include <linux/kernel.h>
13
#include <linux/sched.h>
14
#include "hfsplus_fs.h"
15
 
16
/* Initialize an options object to reasonable defaults */
17
void fill_defaults(struct hfsplus_sb_info *opts)
18
{
19
        if (!opts)
20
                return;
21
 
22
        opts->creator = HFSPLUS_DEF_CR_TYPE;
23
        opts->type = HFSPLUS_DEF_CR_TYPE;
24
        opts->charcase = HFSPLUS_CASE_ASIS;
25
        opts->fork = HFSPLUS_FORK_RAW;
26
        opts->namemap = HFSPLUS_NAMES_TRIVIAL;
27
        opts->umask = current->fs->umask;
28
        opts->uid = current->uid;
29
        opts->gid = current->gid;
30
}
31
 
32
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
33
/* Copy settings from one hfsplus_sb_info object to another */
34
void fill_current(struct hfsplus_sb_info *curopts,
35
                  struct hfsplus_sb_info *opts)
36
{
37
        if (!curopts || !opts)
38
                return;
39
 
40
        opts->creator = curopts->creator;
41
        opts->type = curopts->type;
42
        opts->charcase = curopts->charcase;
43
        opts->fork = curopts->fork;
44
        opts->namemap = curopts->namemap;
45
        opts->umask = curopts->umask;
46
        opts->uid = curopts->uid;
47
        opts->gid = curopts->gid;
48
}
49
#endif
50
 
51
/* convert a "four byte character" to a 32 bit int with error checks */
52
static int fill_fourchar(u32 *result, char *input)
53
{
54
        u32 out;
55
        int i;
56
 
57
        if (!result || !input || !*input || (strlen(input) != 4))
58
                return 0;
59
 
60
        for (out = 0, i = 0; i < 4; i++) {
61
                out <<= 8;
62
                out |= ((int)(input[i])) & 0xFF;
63
        }
64
        *result = out;
65
        return 1;
66
}
67
 
68
/* convert a string to int with error checks */
69
static int fill_int(int *result, char *input, int base)
70
{
71
        char *tmp = input;
72
        int intval;
73
 
74
        if (!result || !input || !*input)
75
                return 0;
76
 
77
        intval = simple_strtoul(tmp, &tmp, base);
78
        if (*tmp)
79
                return 0;
80
 
81
        *result = intval;
82
        return 1;
83
}
84
 
85
/* Parse options from mount. Returns 0 on failure */
86
/* input is the options passed to mount() as a string */
87
int parse_options(char *input, struct hfsplus_sb_info *results)
88
{
89
        char *curropt, *value;
90
        int tmp;
91
 
92
        if (!input)
93
                return 1;
94
 
95
        while ((curropt = strsep(&input,",")) != NULL) {
96
                if (!*curropt)
97
                        continue;
98
 
99
                if ((value = strchr(curropt, '=')) != NULL)
100
                        *value++ = '\0';
101
 
102
                if (!strcmp(curropt, "creator")) {
103
                        if (!fill_fourchar(&(results->creator), value)) {
104
                                printk("HFS+-fs: creator requires a 4 character value\n");
105
                                return 0;
106
                        }
107
                } else if (!strcmp(curropt, "type")) {
108
                        if (!fill_fourchar(&(results->type), value)) {
109
                                printk("HFS+-fs: type requires a 4 character value\n");
110
                                return 0;
111
                        }
112
                } else if (!strcmp(curropt, "case")) {
113
                } else if (!strcmp(curropt, "fork")) {
114
                } else if (!strcmp(curropt, "names")) {
115
                } else if (!strcmp(curropt, "umask")) {
116
                        if (!fill_int(&tmp, value, 8)) {
117
                                printk("HFS+-fs: umask requires a value\n");
118
                                return 0;
119
                        }
120
                        results->umask = (umode_t)tmp;
121
                } else if (!strcmp(curropt, "uid")) {
122
                        if (!fill_int(&tmp, value, 0)) {
123
                                printk("HFS+-fs: uid requires an argument\n");
124
                                return 0;
125
                        }
126
                        results->uid = (uid_t)tmp;
127
                } else if (!strcmp(curropt, "gid")) {
128
                        if (!fill_int(&tmp, value, 0)) {
129
                                printk("HFS+-fs: gid requires an argument\n");
130
                                return 0;
131
                        }
132
                        results->gid = (gid_t)tmp;
133
                } else {
134
                        printk("HFS+-fs: unknown option %s\n", curropt);
135
                        return 0;
136
                }
137
        }
138
 
139
        return 1;
140
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.