diff -dPNur nash/.cvsignore nash-new/.cvsignore --- nash/.cvsignore 2002-06-24 04:33:33.000000000 +0500 +++ nash-new/.cvsignore 1970-01-01 04:00:00.000000000 +0400 @@ -1 +0,0 @@ -nash diff -dPNur nash/nash.c nash-new/nash.c --- nash/nash.c 2005-06-24 20:41:11.000000000 +0500 +++ nash-new/nash.c 2006-05-20 16:33:47.000000000 +0500 @@ -44,6 +44,7 @@ #include #include #include +#include #include @@ -272,6 +273,8 @@ int rc = 0; int flags = MS_MGC_VAL; char * newOpts; + char *fsTypeSpace; + char *deviceSpace; cmd = getArg(cmd, end, &device); if (!cmd) { @@ -307,15 +310,9 @@ } if (!(cmd = getArg(cmd, end, &mntPoint))) { - printf("mount: missing mount point\n"); - return 1; - } - - if (!fsType) { - printf("mount: filesystem type expected\n"); - return 1; - } - + mntPoint = device; + device = NULL; + } else if (cmd < end) { printf("mount: unexpected arguments\n"); return 1; @@ -382,6 +379,40 @@ options = newOpts; } + if (((!device)||(!fsType))&&(flags&MS_REMOUNT)) { + FILE *mounts; + struct mntent *record; + + mounts = setmntent("/proc/mounts", "r"); + if (mounts) { + while ((record = getmntent(mounts)) != NULL) { + if (!strcmp(record->mnt_dir, mntPoint)) { + deviceSpace = alloca(strlen(record->mnt_fsname)+1); + fsTypeSpace = alloca(strlen(record->mnt_type)+1); + if ((!deviceSpace)||(!fsTypeSpace)) break; + strcpy(deviceSpace, record->mnt_fsname); + strcpy(fsTypeSpace, record->mnt_type); + device = deviceSpace; + fsType = fsTypeSpace; + break; + } + } + + endmntent(mounts); + } + } + + if (!device) { + printf("mount: missing mount point\n"); + return 1; + } + + if (!fsType) { + printf("mount: filesystem type expected\n"); + return 1; + } + + if (!strncmp("LABEL=", device, 6)) { int major, minor; char * devName;