Mirror of git://git.busybox.net/busybox with our patches on top
Source
/* vi: set sw=4 ts=4: */
/*
* mountopts.c --- convert between default mount options and strings
*
* Copyright (C) 2002 Theodore Ts'o <tytso@mit.edu>
*
* This file can be redistributed under the terms of the GNU Library General
* Public License
*
*/
struct mntopt {
unsigned int mask;
const char *string;
};
static const struct mntopt mntopt_list[] = {
{ EXT2_DEFM_DEBUG, "debug" },
{ EXT2_DEFM_BSDGROUPS, "bsdgroups" },
{ EXT2_DEFM_XATTR_USER, "user_xattr" },
{ EXT2_DEFM_ACL, "acl" },
{ EXT2_DEFM_UID16, "uid16" },
{ EXT3_DEFM_JMODE_DATA, "journal_data" },
{ EXT3_DEFM_JMODE_ORDERED, "journal_data_ordered" },
{ EXT3_DEFM_JMODE_WBACK, "journal_data_writeback" },
{ 0, 0 },
};
const char *e2p_mntopt2string(unsigned int mask)
{
const struct mntopt *f;
static char buf[20];
int fnum;
for (f = mntopt_list; f->string; f++) {
if (mask == f->mask)
return f->string;
}
for (fnum = 0; mask >>= 1; fnum++);
sprintf(buf, "MNTOPT_%d", fnum);
return buf;
}
int e2p_string2mntopt(char *string, unsigned int *mask)
{
const struct mntopt *f;
char *eptr;
int num;
for (f = mntopt_list; f->string; f++) {
if (!strcasecmp(string, f->string)) {
*mask = f->mask;
return 0;
}
}