mount: support nfs mount option nordiplus.

By Octavian Purdila <opurdila AT ixiacom.com>

function                                             old     new   delta
static.options                                       272     281      +9
daemonize                                            130     107     -23
singlemount                                         4674    4579     -95
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/2 up/down: 9/-118)           Total: -109 bytes
This commit is contained in:
Denis Vlasenko 2008-07-19 22:40:30 +00:00
parent 2e157ddf9e
commit c29684afd6

View File

@ -701,7 +701,8 @@ enum {
NFS_MOUNT_TCP = 0x0040, /* 2 */ NFS_MOUNT_TCP = 0x0040, /* 2 */
NFS_MOUNT_VER3 = 0x0080, /* 3 */ NFS_MOUNT_VER3 = 0x0080, /* 3 */
NFS_MOUNT_KERBEROS = 0x0100, /* 3 */ NFS_MOUNT_KERBEROS = 0x0100, /* 3 */
NFS_MOUNT_NONLM = 0x0200 /* 3 */ NFS_MOUNT_NONLM = 0x0200, /* 3 */
NFS_MOUNT_NORDIRPLUS = 0x4000
}; };
@ -896,18 +897,16 @@ get_mountport(struct pmap *pm_mnt,
#if BB_MMU #if BB_MMU
static int daemonize(void) static int daemonize(void)
{ {
int fd;
int pid = fork(); int pid = fork();
if (pid < 0) /* error */ if (pid < 0) /* error */
return -errno; return -errno;
if (pid > 0) /* parent */ if (pid > 0) /* parent */
return 0; return 0;
/* child */ /* child */
fd = xopen(bb_dev_null, O_RDWR); close(0);
dup2(fd, 0); xopen(bb_dev_null, O_RDWR);
dup2(fd, 1); xdup2(0, 1);
dup2(fd, 2); xdup2(0, 2);
while (fd > 2) close(fd--);
setsid(); setsid();
openlog(applet_name, LOG_PID, LOG_DAEMON); openlog(applet_name, LOG_PID, LOG_DAEMON);
logmode = LOGMODE_SYSLOG; logmode = LOGMODE_SYSLOG;
@ -959,23 +958,25 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
int mountport; int mountport;
int proto; int proto;
#if BB_MMU #if BB_MMU
int bg = 0; smallint bg = 0;
#else #else
enum { bg = 0 }; enum { bg = 0 };
#endif #endif
int soft;
int intr;
int posix;
int nocto;
int noac;
int nolock;
int retry; int retry;
int tcp;
int mountprog; int mountprog;
int mountvers; int mountvers;
int nfsprog; int nfsprog;
int nfsvers; int nfsvers;
int retval; int retval;
/* these all are one-bit really. 4.3.1 likes this combination: */
smallint tcp;
smallint soft;
int intr;
int posix;
int nocto;
int noac;
int nordirplus;
int nolock;
find_kernel_nfs_mount_version(); find_kernel_nfs_mount_version();
@ -1036,12 +1037,12 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
* let the kernel decide. * let the kernel decide.
* timeo is filled in after we know whether it'll be TCP or UDP. */ * timeo is filled in after we know whether it'll be TCP or UDP. */
memset(&data, 0, sizeof(data)); memset(&data, 0, sizeof(data));
data.retrans = 3; data.retrans = 3;
data.acregmin = 3; data.acregmin = 3;
data.acregmax = 60; data.acregmax = 60;
data.acdirmin = 30; data.acdirmin = 30;
data.acdirmax = 60; data.acdirmax = 60;
data.namlen = NAME_MAX; data.namlen = NAME_MAX;
soft = 0; soft = 0;
intr = 0; intr = 0;
@ -1049,6 +1050,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
nocto = 0; nocto = 0;
nolock = 0; nolock = 0;
noac = 0; noac = 0;
nordirplus = 0;
retry = 10000; /* 10000 minutes ~ 1 week */ retry = 10000; /* 10000 minutes ~ 1 week */
tcp = 0; tcp = 0;
@ -1183,7 +1185,8 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
"ac\0" "ac\0"
"tcp\0" "tcp\0"
"udp\0" "udp\0"
"lock\0"; "lock\0"
"rdirplus\0";
int val = 1; int val = 1;
if (!strncmp(opt, "no", 2)) { if (!strncmp(opt, "no", 2)) {
val = 0; val = 0;
@ -1230,6 +1233,9 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
else else
bb_error_msg("warning: option nolock is not supported"); bb_error_msg("warning: option nolock is not supported");
break; break;
case 11: //rdirplus
nordirplus = !val;
break;
default: default:
bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt); bb_error_msg("unknown nfs mount option: %s%s", val ? "" : "no", opt);
goto fail; goto fail;
@ -1242,7 +1248,8 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
| (intr ? NFS_MOUNT_INTR : 0) | (intr ? NFS_MOUNT_INTR : 0)
| (posix ? NFS_MOUNT_POSIX : 0) | (posix ? NFS_MOUNT_POSIX : 0)
| (nocto ? NFS_MOUNT_NOCTO : 0) | (nocto ? NFS_MOUNT_NOCTO : 0)
| (noac ? NFS_MOUNT_NOAC : 0); | (noac ? NFS_MOUNT_NOAC : 0)
| (nordirplus ? NFS_MOUNT_NORDIRPLUS : 0);
if (nfs_mount_version >= 2) if (nfs_mount_version >= 2)
data.flags |= (tcp ? NFS_MOUNT_TCP : 0); data.flags |= (tcp ? NFS_MOUNT_TCP : 0);
if (nfs_mount_version >= 3) if (nfs_mount_version >= 3)
@ -1325,6 +1332,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
retry_timeout.tv_usec = 0; retry_timeout.tv_usec = 0;
total_timeout.tv_sec = 20; total_timeout.tv_sec = 20;
total_timeout.tv_usec = 0; total_timeout.tv_usec = 0;
//FIXME: use monotonic()?
timeout = time(NULL) + 60 * retry; timeout = time(NULL) + 60 * retry;
prevt = 0; prevt = 0;
t = 30; t = 30;
@ -1511,7 +1519,7 @@ static int nfsmount(struct mntent *mp, long vfsflags, char *filteropts)
if (!daemonized) { if (!daemonized) {
daemonized = daemonize(); daemonized = daemonize();
if (daemonized <= 0) { /* parent or error */ if (daemonized <= 0) { /* parent or error */
// FIXME: parent doesn't close fsock - ??! // FIXME: parent doesn't close fsock - ??!
retval = -daemonized; retval = -daemonized;
goto ret; goto ret;
} }