shithub: riscv

Download patch

ref: 46a7876d326c752f17b7993274f3234e647dfb65
parent: 0ce50ebc5750c15e30c6f2d5ba23a0dd329c6c47
author: cinap_lenrek <[email protected]>
date: Fri Aug 21 15:32:48 EDT 2015

disk/mkfs: rmeove kfs support

--- a/sys/man/8/mkfs
+++ b/sys/man/8/mkfs
@@ -6,12 +6,8 @@
 .RB [ -aprvoxU ]
 .RB [ -d
 .IR root ]
-.RB [ -n
-.IR name ]
 .RB [ -s
 .IR source ]
-.RB [ -u
-.IR users ]
 .RB [ -z
 .IR n ]
 .I proto ...
@@ -31,18 +27,10 @@
 .I source
 (default
 .BR / )
-to a
-.B kfs
-file system (see
-.IR kfs (4)).
-The kfs service is mounted on
+to a new file system
 .I root
 (default
-.BR /n/kfs ),
-and
-.B /adm/users
-is copied to
-.IB root /adm/users\f1.
+.BR /n/newfs ).
 The
 .I proto
 files are read
@@ -49,8 +37,7 @@
 (see
 .IR proto (2)
 for their format)
-and any files specified in them that are out of date are copied to
-.BR /n/kfs .
+and any files specified in them that are out of date are copied.
 .PP
 .I Mkfs
 copies only those files that are out of date.
@@ -57,9 +44,7 @@
 Such a file is first copied into a temporary
 file in the appropriate destination directory
 and then moved to the destination file.
-Files in the
-.I kfs
-file system that are not specified in the
+Files that are not specified in the
 .I proto
 file
 are not updated and not removed.
@@ -94,7 +79,7 @@
 Copy files into the tree rooted at
 .I root 
 (default
-.BR /n/kfs ).
+.BR /n/newfs ).
 This option suppresses setting the
 .B uid
 and
@@ -104,12 +89,6 @@
 .B -U
 to reenable it. 
 .TP
-.BI "n " name
-Use
-.RI kfs. name
-as the name of the kfs service (default
-.BR kfs ).
-.TP
 .B p
 Update the permissions of a file even if it is up to date.
 .TP
@@ -123,18 +102,11 @@
 Copy from files rooted at the tree
 .IR source .
 .TP
-.BI "u " users
-Copy file
-.I users
-into
-.B /adm/users
-in the new system.
-.TP
 .B v
 Print the names of all of the files as they are copied.
 .TP
 .BI "z " n
-Copy files assuming kfs block
+Copy files assuming block size
 .I n
 (default 1024)
 bytes long.
@@ -179,7 +151,7 @@
 Make an archive to establish a new file system:
 .IP
 .EX
-disk/mkfs -a -u files/adm.users -s dist proto > arch
+disk/mkfs -a -s dist proto > arch
 .EE
 .PP
 Unpack that archive onto a new file system:
@@ -195,6 +167,5 @@
 .B /sys/src/cmd/disk/mkext.c
 .SH "SEE ALSO"
 .IR prep (8),
-.IR kfscmd (8),
 .IR sd (3),
 .IR tar (1)
--- a/sys/src/cmd/disk/mkfs.c
+++ b/sys/src/cmd/disk/mkfs.c
@@ -10,8 +10,7 @@
 	/*
 	 * types of destination file sytems
 	 */
-	Kfs = 0,
-	Fs,
+	Fs = 0,
 	Archive,
 };
 
@@ -21,9 +20,7 @@
 void	arch(Dir*);
 void	copy(Dir*);
 void	error(char *, ...);
-void	kfscmd(char *);
 void	mkdir(Dir*);
-void	mountkfs(char*);
 int	uptodate(Dir*, char*);
 void	usage(void);
 void	warn(char *, ...);
@@ -34,7 +31,6 @@
 char	oldfile[LEN];
 char	*proto;
 char	*cputype;
-char	*users;
 char	*oldroot;
 char	*newroot;
 char	*prog = "mkfs";
@@ -48,7 +44,7 @@
 int	xflag;
 int	oflag;
 int	sfd;
-int	fskind;			/* Kfs, Fs, Archive */
+int	fskind;			/* Fs, Archive */
 int	setuid;			/* on Fs: set uid and gid? */
 char	*user;
 
@@ -55,40 +51,30 @@
 void
 main(int argc, char **argv)
 {
-	char *name;
 	int i, errs;
 
 	quotefmtinstall();
 	user = getuser();
-	name = "";
 	oldroot = "";
-	newroot = "/n/kfs";
-	users = 0;
-	fskind = Kfs;
+	newroot = "/n/newfs";
+	fskind = Fs;
 	ARGBEGIN{
 	case 'a':
-		if(fskind != Kfs) {
-			fprint(2, "cannot use -a with -d\n");
-			usage();
-		}
 		fskind = Archive;
 		newroot = "";
 		Binits(&bout, 1, OWRITE, boutbuf, sizeof boutbuf);
 		break;
 	case 'd':
-		if(fskind != Kfs) {
+		if(fskind != Fs) {
 			fprint(2, "cannot use -d with -a\n");
 			usage();
 		}
 		fskind = Fs;
-		newroot = ARGF();
+		newroot = EARGF(usage());
 		break;
 	case 'D':
 		debug = 1;
 		break;
-	case 'n':
-		name = EARGF(usage());
-		break;
 	case 'p':
 		modes = 1;
 		break;
@@ -96,11 +82,8 @@
 		ream = 1;
 		break;
 	case 's':
-		oldroot = ARGF();
+		oldroot = EARGF(usage());
 		break;
-	case 'u':
-		users = ARGF();
-		break;
 	case 'U':
 		setuid = 1;
 		break;
@@ -114,7 +97,7 @@
 		xflag = 1;
 		break;
 	case 'z':
-		buflen = atoi(ARGF())-8;
+		buflen = atoi(EARGF(usage()))-8;
 		break;
 	default:
 		usage();
@@ -132,8 +115,6 @@
 	zbuf = malloc(buflen);
 	memset(zbuf, 0, buflen);
 
-	mountkfs(name);
-	kfscmd("allow");
 	cputype = getenv("cputype");
 	if(cputype == 0)
 		cputype = "386";
@@ -149,8 +130,6 @@
 		}
 	}
 	fprint(2, "file system made\n");
-	kfscmd("disallow");
-	kfscmd("sync");
 	if(errs)
 		exits("skipped protos");
 	if(fskind == Archive){
@@ -367,61 +346,6 @@
 }
 
 void
-mountkfs(char *name)
-{
-	char kname[64];
-
-	if(fskind != Kfs)
-		return;
-	if(name[0])
-		snprint(kname, sizeof kname, "/srv/kfs.%s", name);
-	else
-		strcpy(kname, "/srv/kfs");
-	sfd = open(kname, ORDWR);
-	if(sfd < 0){
-		fprint(2, "can't open %q\n", kname);
-		exits("open /srv/kfs");
-	}
-	if(mount(sfd, -1, "/n/kfs", MREPL|MCREATE, "") < 0){
-		fprint(2, "can't mount kfs on /n/kfs\n");
-		exits("mount kfs");
-	}
-	close(sfd);
-	strcat(kname, ".cmd");
-	sfd = open(kname, ORDWR);
-	if(sfd < 0){
-		fprint(2, "can't open %q\n", kname);
-		exits("open /srv/kfs");
-	}
-}
-
-void
-kfscmd(char *cmd)
-{
-	char buf[4*1024];
-	int n;
-
-	if(fskind != Kfs)
-		return;
-	if(write(sfd, cmd, strlen(cmd)) != strlen(cmd)){
-		fprint(2, "%q: error writing %q: %r", prog, cmd);
-		return;
-	}
-	for(;;){
-		n = read(sfd, buf, sizeof buf - 1);
-		if(n <= 0)
-			return;
-		buf[n] = '\0';
-		if(strcmp(buf, "done") == 0 || strcmp(buf, "success") == 0)
-			return;
-		if(strcmp(buf, "unknown command") == 0){
-			fprint(2, "%q: command %q not recognized\n", prog, cmd);
-			return;
-		}
-	}
-}
-
-void
 error(char *fmt, ...)
 {
 	char buf[1024];
@@ -432,8 +356,6 @@
 	vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg);
 	va_end(arg);
 	fprint(2, "%s\n", buf);
-	kfscmd("disallow");
-	kfscmd("sync");
 	exits(0);
 }
 
@@ -453,6 +375,6 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %q [-adprvoxUD] [-d root] [-n name] [-s source] [-u users] [-z n] proto ...\n", prog);
+	fprint(2, "usage: %q [-adprvoxUD] [-d root] [-s source] [-z n] proto ...\n", prog);
 	exits("usage");
 }