Update mkfs, mknod, mkpasswd, mount.

This commit is contained in:
Serge
2022-07-10 14:19:42 -07:00
parent c6f46414ed
commit dbe1779a29
9 changed files with 67 additions and 55 deletions

View File

@@ -154,6 +154,7 @@ int fsync(int fd);
int getpagesize(void);
int symlink(const char *target, const char *linkpath);
int vhangup(void);
int mknod(const char *, mode_t, dev_t);
#ifndef _VA_LIST_
# ifdef __GNUC__

View File

@@ -178,7 +178,7 @@ iput (ip)
printf("ilist too small\n");
return;
}
rdfs(d, buf);
rdfs(d, (char *) buf);
dp = (struct dinode *)buf;
dp += itoo(ip->i_number);
@@ -186,7 +186,7 @@ iput (ip)
dp->di_addr[i] = ip->i_addr[i];
dp->di_ic1 = ip->i_ic1;
dp->di_ic2 = ip->i_ic2;
wtfs(d, buf);
wtfs(d, (char *) buf);
}
daddr_t

View File

@@ -1,28 +1,43 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
main(argc, argv)
int number(s)
char *s;
{
int n, c;
n = 0;
while ((c = *s++)) {
if (c < '0' || c > '9')
return -1;
n = n*10 + c - '0';
}
return n;
}
int main(argc, argv)
int argc;
char **argv;
{
int m, a, b;
if(argc != 5) {
if (argc != 5) {
printf("arg count\n");
goto usage;
}
if(*argv[2] == 'b')
if (*argv[2] == 'b')
m = 060666; else
if(*argv[2] == 'c')
if (*argv[2] == 'c')
m = 020666; else
goto usage;
a = number(argv[3]);
if(a < 0)
if (a < 0)
goto usage;
b = number(argv[4]);
if(b < 0)
if (b < 0)
goto usage;
if(mknod(argv[1], m, (a<<8)|b) < 0) {
if (mknod(argv[1], m, (a << 8) | b) < 0) {
fprintf(stderr, "mknod: ");
perror(argv[1]);
}
@@ -31,17 +46,3 @@ main(argc, argv)
usage:
printf("usage: mknod name b/c major minor\n");
}
number(s)
char *s;
{
int n, c;
n = 0;
while(c = *s++) {
if(c<'0' || c>'9')
return(-1);
n = n*10 + c-'0';
}
return(n);
}

View File

@@ -16,12 +16,15 @@
*/
#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <ndbm.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
static FILE *_pw_fp;
static struct passwd _pw_passwd;
@@ -30,9 +33,12 @@ static off_t offset;
#define MAXLINELENGTH 256
static char line[MAXLINELENGTH];
static void usage(void);
static void rmall(char *fname);
/* from libc/gen/getpwent.c */
static
static int
scanpw()
{
register char *cp;
@@ -79,7 +85,7 @@ scanpw()
* required the addition of a flag field to the dbm database to distinguish
* between a record keyed by name, and one keyed by uid.
*/
main(argc, argv)
int main(argc, argv)
int argc;
char **argv;
{
@@ -145,7 +151,7 @@ main(argc, argv)
while (scanpw()) {
/* create dbm entry */
p = buf;
#define COMPACT(e) t = e; while (*p++ = *t++);
#define COMPACT(e) t = e; while ((*p++ = *t++));
COMPACT(_pw_passwd.pw_name);
(void)sprintf(nbuf, "%ld", offset);
COMPACT(nbuf);
@@ -189,7 +195,7 @@ bad: (void)fprintf(stderr, "mkpasswd: dbm_store failed.\n");
exit(1);
}
rmall(fname)
void rmall(fname)
char *fname;
{
register char *p;
@@ -204,7 +210,7 @@ rmall(fname)
(void)unlink(buf);
}
usage()
void usage()
{
(void)fprintf(stderr, "usage: mkpasswd [-p] passwd_file\n");
exit(1);

View File

@@ -37,6 +37,8 @@
#include <fstab.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "mntopts.h"

View File

@@ -78,4 +78,5 @@ struct mntopt {
MOPT_NOSUID, \
MOPT_RDONLY
void getmntopts();
int mount_ufs(int argc, char *argv[]);
void getmntopts(char *options, struct mntopt *m0, int *flagp);

View File

@@ -42,22 +42,10 @@
#include <string.h>
#include <unistd.h>
#include <paths.h>
#include "mntopts.h"
int debug, verbose, skipvfs, mountrw;
int badvfsname();
int badvfstype();
char *catopt();
struct statfs *getmntpt();
char **makevfslist();
void mangle();
int mountfs();
void prmount();
void usage();
/* From mount_ufs.c. */
int mount_ufs();
/* Map from mount otions to printable formats. */
static struct opt {
int o_opt;
@@ -74,6 +62,16 @@ static struct opt {
{ NULL }
};
static char *catopt(char *s0, char *s1);
static char **makevfslist(char *fslist);
static void usage(void);
static int badvfsname(char *vfsname, char **vfslist);
static int mountfs(char *vfstype, char *spec, char *name, int flags, char *options, char *mntopts);
static int badvfstype(int vfstype, register char **vfslist);
static void prmount(char *spec, char *name, int flags);
static struct statfs *getmntpt(char *name);
static void mangle(char *options, int *argcp, char **argv);
int
main(argc, argv)
int argc;
@@ -385,7 +383,7 @@ badvfstype(vfstype, vfslist)
int vfstype;
register char **vfslist;
{
static char *vfsnames[] = INITMOUNTNAMES;
static char *vfsnames[] = INITMOUNTNAMES;
if ((vfstype < 0) || (vfstype > MOUNT_MAXTYPE))
return (0);
@@ -457,8 +455,8 @@ mangle(options, argcp, argv)
register int argc;
argc = *argcp;
for (s = options; (p = strsep(&s, ",")) != NULL;)
if (*p != '\0')
for (s = options; (p = strsep(&s, ",")) != NULL;) {
if (*p != '\0') {
if (*p == '-') {
argv[argc++] = p;
p = strchr(p, '=');
@@ -470,6 +468,8 @@ mangle(options, argcp, argv)
argv[argc++] = "-o";
argv[argc++] = p;
}
}
}
*argcp = argc;
}

View File

@@ -41,8 +41,6 @@
#include "mntopts.h"
void ufs_usage();
static struct mntopt mopts[] = {
MOPT_STDOPTS,
MOPT_ASYNC,
@@ -51,6 +49,13 @@ static struct mntopt mopts[] = {
{ NULL }
};
void
ufs_usage()
{
(void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n");
exit(1);
}
int
mount_ufs(argc, argv)
int argc;
@@ -99,10 +104,3 @@ mount_ufs(argc, argv)
}
return (0);
}
void
ufs_usage()
{
(void)fprintf(stderr, "usage: mount_ufs [-o options] special node\n");
exit(1);
}

View File

@@ -96,6 +96,9 @@ struct mount mount[NMOUNT];
#else
int getfsstat (struct statfs *buf, int bufsize, unsigned flags);
int getfsstat(struct statfs *buf, int bufsize, unsigned flags);
int getmntinfo(struct statfs **mntbufp, int flags);
int statfs(const char *path, struct statfs *buf);
int mount(const char *source, const char *target, int mountflags);
#endif