git://git.jankratochvil.net
/
lufs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c6cbba4
)
+'mntent.mnt_fsname' and 'mntent.mnt_type' mntent overriding options.
author
short
<>
Fri, 29 Aug 2003 11:06:18 +0000
(11:06 +0000)
committer
short
<>
Fri, 29 Aug 2003 11:06:18 +0000
(11:06 +0000)
util/lufsmnt.c
patch
|
blob
|
history
diff --git
a/util/lufsmnt.c
b/util/lufsmnt.c
index
6167827
..
b0b112b
100644
(file)
--- a/
util/lufsmnt.c
+++ b/
util/lufsmnt.c
@@
-74,16
+74,17
@@
hide_pass(char *opts){
}
}
}
}
-void
-get_
fs(char *opts
, char *buf, int buflen){
+int
+get_
opt(char *opts, const char *optname
, char *buf, int buflen){
char *begin, *end;
char *begin, *end;
- buf[0] = 0;
- buf[buflen - 1] = 0;
+ for(begin = opts; (begin = strstr(begin, optname)); begin++){
+ if (begin > opts && begin[-1] != ',')
+ continue;
+ if (begin[strlen(optname)] != '=')
+ continue;
+ begin += strlen(optname) + 1;
- if((begin = strstr(opts, "fs="))){
- begin += 3;
-
if(!(end = strchr(begin, ','))){
end = begin + strlen(begin);
}
if(!(end = strchr(begin, ','))){
end = begin + strlen(begin);
}
@@
-91,8
+92,11
@@
get_fs(char *opts, char *buf, int buflen){
if( end - begin >= buflen)
end = begin + buflen - 1;
if( end - begin >= buflen)
end = begin + buflen - 1;
- strncpy(buf, begin, end - begin);
+ memcpy(buf, begin, end - begin);
+ buf[end - begin] = 0;
+ return 1;
}
}
+ return 0;
}
int
}
int
@@
-101,6
+105,7
@@
main(int argc, char **argv){
static char fpath[PATH_MAX];
static char mfs[PATH_MAX];
static char mopts[PATH_MAX];
static char fpath[PATH_MAX];
static char mfs[PATH_MAX];
static char mopts[PATH_MAX];
+ static char mntent_mnt_type[PATH_MAX];
struct mntent ment;
int fd;
FILE *mtab;
struct mntent ment;
int fd;
FILE *mtab;
@@
-138,11
+143,15
@@
main(int argc, char **argv){
hide_pass(opts);
if(strlen(mopts) + strlen(opts) < PATH_MAX)
strcat(mopts, opts);
hide_pass(opts);
if(strlen(mopts) + strlen(opts) < PATH_MAX)
strcat(mopts, opts);
- get_fs(opts, mfs, PATH_MAX);
+ mfs[0] = 0;
+ get_opt(opts, "fs", mfs, PATH_MAX);
+ get_opt(opts, "mntent.mnt_fsname", mfs, PATH_MAX);
ment.mnt_fsname = mfs;
ment.mnt_dir = fpath;
ment.mnt_fsname = mfs;
ment.mnt_dir = fpath;
- ment.mnt_type = "lufs";
+ strcpy(mntent_mnt_type, "lufs");
+ get_opt(opts, "mntent.mnt_type", mntent_mnt_type, sizeof(mntent_mnt_type));
+ ment.mnt_type = mntent_mnt_type;
ment.mnt_opts = mopts;
ment.mnt_freq = 0;
ment.mnt_passno = 0;
ment.mnt_opts = mopts;
ment.mnt_freq = 0;
ment.mnt_passno = 0;