summaryrefslogtreecommitdiffstats
path: root/sys-apps/mkinitrd/files/nash-ds-remount.patch
blob: c403535504fd5d9dc9e77ef36595472eb7e792d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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 <sys/ioctl.h>
 #include <sys/reboot.h>
 #include <termios.h>
+#include <mntent.h>
 
 #include <asm/unistd.h>
 
@@ -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;