disk/mkfs: rmeove kfs support
This commit is contained in:
parent
0ce50ebc57
commit
46a7876d32
2 changed files with 16 additions and 123 deletions
|
@ -6,12 +6,8 @@ mkfs, mkext \- archive or update a file system
|
||||||
.RB [ -aprvoxU ]
|
.RB [ -aprvoxU ]
|
||||||
.RB [ -d
|
.RB [ -d
|
||||||
.IR root ]
|
.IR root ]
|
||||||
.RB [ -n
|
|
||||||
.IR name ]
|
|
||||||
.RB [ -s
|
.RB [ -s
|
||||||
.IR source ]
|
.IR source ]
|
||||||
.RB [ -u
|
|
||||||
.IR users ]
|
|
||||||
.RB [ -z
|
.RB [ -z
|
||||||
.IR n ]
|
.IR n ]
|
||||||
.I proto ...
|
.I proto ...
|
||||||
|
@ -31,35 +27,24 @@ copies files from the file tree
|
||||||
.I source
|
.I source
|
||||||
(default
|
(default
|
||||||
.BR / )
|
.BR / )
|
||||||
to a
|
to a new file system
|
||||||
.B kfs
|
|
||||||
file system (see
|
|
||||||
.IR kfs (4)).
|
|
||||||
The kfs service is mounted on
|
|
||||||
.I root
|
.I root
|
||||||
(default
|
(default
|
||||||
.BR /n/kfs ),
|
.BR /n/newfs ).
|
||||||
and
|
|
||||||
.B /adm/users
|
|
||||||
is copied to
|
|
||||||
.IB root /adm/users\f1.
|
|
||||||
The
|
The
|
||||||
.I proto
|
.I proto
|
||||||
files are read
|
files are read
|
||||||
(see
|
(see
|
||||||
.IR proto (2)
|
.IR proto (2)
|
||||||
for their format)
|
for their format)
|
||||||
and any files specified in them that are out of date are copied to
|
and any files specified in them that are out of date are copied.
|
||||||
.BR /n/kfs .
|
|
||||||
.PP
|
.PP
|
||||||
.I Mkfs
|
.I Mkfs
|
||||||
copies only those files that are out of date.
|
copies only those files that are out of date.
|
||||||
Such a file is first copied into a temporary
|
Such a file is first copied into a temporary
|
||||||
file in the appropriate destination directory
|
file in the appropriate destination directory
|
||||||
and then moved to the destination file.
|
and then moved to the destination file.
|
||||||
Files in the
|
Files that are not specified in the
|
||||||
.I kfs
|
|
||||||
file system that are not specified in the
|
|
||||||
.I proto
|
.I proto
|
||||||
file
|
file
|
||||||
are not updated and not removed.
|
are not updated and not removed.
|
||||||
|
@ -94,7 +79,7 @@ rather than producing an archive file.
|
||||||
Copy files into the tree rooted at
|
Copy files into the tree rooted at
|
||||||
.I root
|
.I root
|
||||||
(default
|
(default
|
||||||
.BR /n/kfs ).
|
.BR /n/newfs ).
|
||||||
This option suppresses setting the
|
This option suppresses setting the
|
||||||
.B uid
|
.B uid
|
||||||
and
|
and
|
||||||
|
@ -104,12 +89,6 @@ Use
|
||||||
.B -U
|
.B -U
|
||||||
to reenable it.
|
to reenable it.
|
||||||
.TP
|
.TP
|
||||||
.BI "n " name
|
|
||||||
Use
|
|
||||||
.RI kfs. name
|
|
||||||
as the name of the kfs service (default
|
|
||||||
.BR kfs ).
|
|
||||||
.TP
|
|
||||||
.B p
|
.B p
|
||||||
Update the permissions of a file even if it is up to date.
|
Update the permissions of a file even if it is up to date.
|
||||||
.TP
|
.TP
|
||||||
|
@ -123,18 +102,11 @@ Copy all files.
|
||||||
Copy from files rooted at the tree
|
Copy from files rooted at the tree
|
||||||
.IR source .
|
.IR source .
|
||||||
.TP
|
.TP
|
||||||
.BI "u " users
|
|
||||||
Copy file
|
|
||||||
.I users
|
|
||||||
into
|
|
||||||
.B /adm/users
|
|
||||||
in the new system.
|
|
||||||
.TP
|
|
||||||
.B v
|
.B v
|
||||||
Print the names of all of the files as they are copied.
|
Print the names of all of the files as they are copied.
|
||||||
.TP
|
.TP
|
||||||
.BI "z " n
|
.BI "z " n
|
||||||
Copy files assuming kfs block
|
Copy files assuming block size
|
||||||
.I n
|
.I n
|
||||||
(default 1024)
|
(default 1024)
|
||||||
bytes long.
|
bytes long.
|
||||||
|
@ -179,7 +151,7 @@ instead of unpacking the files.
|
||||||
Make an archive to establish a new file system:
|
Make an archive to establish a new file system:
|
||||||
.IP
|
.IP
|
||||||
.EX
|
.EX
|
||||||
disk/mkfs -a -u files/adm.users -s dist proto > arch
|
disk/mkfs -a -s dist proto > arch
|
||||||
.EE
|
.EE
|
||||||
.PP
|
.PP
|
||||||
Unpack that archive onto a new file system:
|
Unpack that archive onto a new file system:
|
||||||
|
@ -195,6 +167,5 @@ disk/mkext -u -d /n/newfs < arch
|
||||||
.B /sys/src/cmd/disk/mkext.c
|
.B /sys/src/cmd/disk/mkext.c
|
||||||
.SH "SEE ALSO"
|
.SH "SEE ALSO"
|
||||||
.IR prep (8),
|
.IR prep (8),
|
||||||
.IR kfscmd (8),
|
|
||||||
.IR sd (3),
|
.IR sd (3),
|
||||||
.IR tar (1)
|
.IR tar (1)
|
||||||
|
|
|
@ -10,8 +10,7 @@ enum{
|
||||||
/*
|
/*
|
||||||
* types of destination file sytems
|
* types of destination file sytems
|
||||||
*/
|
*/
|
||||||
Kfs = 0,
|
Fs = 0,
|
||||||
Fs,
|
|
||||||
Archive,
|
Archive,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -21,9 +20,7 @@ void protoenum(char *new, char *old, Dir *d, void *);
|
||||||
void arch(Dir*);
|
void arch(Dir*);
|
||||||
void copy(Dir*);
|
void copy(Dir*);
|
||||||
void error(char *, ...);
|
void error(char *, ...);
|
||||||
void kfscmd(char *);
|
|
||||||
void mkdir(Dir*);
|
void mkdir(Dir*);
|
||||||
void mountkfs(char*);
|
|
||||||
int uptodate(Dir*, char*);
|
int uptodate(Dir*, char*);
|
||||||
void usage(void);
|
void usage(void);
|
||||||
void warn(char *, ...);
|
void warn(char *, ...);
|
||||||
|
@ -34,7 +31,6 @@ char newfile[LEN];
|
||||||
char oldfile[LEN];
|
char oldfile[LEN];
|
||||||
char *proto;
|
char *proto;
|
||||||
char *cputype;
|
char *cputype;
|
||||||
char *users;
|
|
||||||
char *oldroot;
|
char *oldroot;
|
||||||
char *newroot;
|
char *newroot;
|
||||||
char *prog = "mkfs";
|
char *prog = "mkfs";
|
||||||
|
@ -48,47 +44,37 @@ int debug;
|
||||||
int xflag;
|
int xflag;
|
||||||
int oflag;
|
int oflag;
|
||||||
int sfd;
|
int sfd;
|
||||||
int fskind; /* Kfs, Fs, Archive */
|
int fskind; /* Fs, Archive */
|
||||||
int setuid; /* on Fs: set uid and gid? */
|
int setuid; /* on Fs: set uid and gid? */
|
||||||
char *user;
|
char *user;
|
||||||
|
|
||||||
void
|
void
|
||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *name;
|
|
||||||
int i, errs;
|
int i, errs;
|
||||||
|
|
||||||
quotefmtinstall();
|
quotefmtinstall();
|
||||||
user = getuser();
|
user = getuser();
|
||||||
name = "";
|
|
||||||
oldroot = "";
|
oldroot = "";
|
||||||
newroot = "/n/kfs";
|
newroot = "/n/newfs";
|
||||||
users = 0;
|
fskind = Fs;
|
||||||
fskind = Kfs;
|
|
||||||
ARGBEGIN{
|
ARGBEGIN{
|
||||||
case 'a':
|
case 'a':
|
||||||
if(fskind != Kfs) {
|
|
||||||
fprint(2, "cannot use -a with -d\n");
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
fskind = Archive;
|
fskind = Archive;
|
||||||
newroot = "";
|
newroot = "";
|
||||||
Binits(&bout, 1, OWRITE, boutbuf, sizeof boutbuf);
|
Binits(&bout, 1, OWRITE, boutbuf, sizeof boutbuf);
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
if(fskind != Kfs) {
|
if(fskind != Fs) {
|
||||||
fprint(2, "cannot use -d with -a\n");
|
fprint(2, "cannot use -d with -a\n");
|
||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
fskind = Fs;
|
fskind = Fs;
|
||||||
newroot = ARGF();
|
newroot = EARGF(usage());
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
debug = 1;
|
debug = 1;
|
||||||
break;
|
break;
|
||||||
case 'n':
|
|
||||||
name = EARGF(usage());
|
|
||||||
break;
|
|
||||||
case 'p':
|
case 'p':
|
||||||
modes = 1;
|
modes = 1;
|
||||||
break;
|
break;
|
||||||
|
@ -96,10 +82,7 @@ main(int argc, char **argv)
|
||||||
ream = 1;
|
ream = 1;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
oldroot = ARGF();
|
oldroot = EARGF(usage());
|
||||||
break;
|
|
||||||
case 'u':
|
|
||||||
users = ARGF();
|
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
setuid = 1;
|
setuid = 1;
|
||||||
|
@ -114,7 +97,7 @@ main(int argc, char **argv)
|
||||||
xflag = 1;
|
xflag = 1;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
buflen = atoi(ARGF())-8;
|
buflen = atoi(EARGF(usage()))-8;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
@ -132,8 +115,6 @@ main(int argc, char **argv)
|
||||||
zbuf = malloc(buflen);
|
zbuf = malloc(buflen);
|
||||||
memset(zbuf, 0, buflen);
|
memset(zbuf, 0, buflen);
|
||||||
|
|
||||||
mountkfs(name);
|
|
||||||
kfscmd("allow");
|
|
||||||
cputype = getenv("cputype");
|
cputype = getenv("cputype");
|
||||||
if(cputype == 0)
|
if(cputype == 0)
|
||||||
cputype = "386";
|
cputype = "386";
|
||||||
|
@ -149,8 +130,6 @@ main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprint(2, "file system made\n");
|
fprint(2, "file system made\n");
|
||||||
kfscmd("disallow");
|
|
||||||
kfscmd("sync");
|
|
||||||
if(errs)
|
if(errs)
|
||||||
exits("skipped protos");
|
exits("skipped protos");
|
||||||
if(fskind == Archive){
|
if(fskind == Archive){
|
||||||
|
@ -366,61 +345,6 @@ protoenum(char *new, char *old, Dir *d, void *)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
void
|
||||||
error(char *fmt, ...)
|
error(char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
@ -432,8 +356,6 @@ error(char *fmt, ...)
|
||||||
vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg);
|
vseprint(buf+strlen(buf), buf+sizeof(buf), fmt, arg);
|
||||||
va_end(arg);
|
va_end(arg);
|
||||||
fprint(2, "%s\n", buf);
|
fprint(2, "%s\n", buf);
|
||||||
kfscmd("disallow");
|
|
||||||
kfscmd("sync");
|
|
||||||
exits(0);
|
exits(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,6 +375,6 @@ warn(char *fmt, ...)
|
||||||
void
|
void
|
||||||
usage(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");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue