}
}
-void
-get_fs(char *opts, char *buf, int buflen){
+int
+get_opt(char *opts, const char *optname, char *buf, int buflen){
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 - 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
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;
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_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;