summaryrefslogtreecommitdiffstats
path: root/usr.sbin/makefs
diff options
context:
space:
mode:
authornatano <natano@openbsd.org>2016-10-16 20:45:07 +0000
committernatano <natano@openbsd.org>2016-10-16 20:45:07 +0000
commit4a4455269d875fbeab805eaed358ddb3c4f51d3e (patch)
tree2a42e1717d8523af21f45586406839a41e04cbe3 /usr.sbin/makefs
parentRemove the -Z (spare ffs image) option. (diff)
downloadwireguard-openbsd-4a4455269d875fbeab805eaed358ddb3c4f51d3e.tar.xz
wireguard-openbsd-4a4455269d875fbeab805eaed358ddb3c4f51d3e.zip
Only allow one directory as argument and remove the -r option.
ok deraadt (on principle)
Diffstat (limited to 'usr.sbin/makefs')
-rw-r--r--usr.sbin/makefs/makefs.813
-rw-r--r--usr.sbin/makefs/makefs.c28
-rw-r--r--usr.sbin/makefs/makefs.h5
-rw-r--r--usr.sbin/makefs/walk.c35
4 files changed, 17 insertions, 64 deletions
diff --git a/usr.sbin/makefs/makefs.8 b/usr.sbin/makefs/makefs.8
index 7a481c3213c..309d2b03119 100644
--- a/usr.sbin/makefs/makefs.8
+++ b/usr.sbin/makefs/makefs.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: makefs.8,v 1.3 2016/10/16 20:30:40 natano Exp $
+.\" $OpenBSD: makefs.8,v 1.4 2016/10/16 20:45:07 natano Exp $
.\" $NetBSD: makefs.8,v 1.55 2015/11/25 16:32:00 wiz Exp $
.\"
.\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -42,7 +42,6 @@
.Nd create a file system image from a directory tree
.Sh SYNOPSIS
.Nm
-.Op Fl r
.Op Fl B Ar endian
.Op Fl b Ar free-blocks
.Op Fl d Ar debug-mask
@@ -57,7 +56,6 @@
.Op Fl t Ar fs-type
.Ar image-file
.Ar directory
-.Op Ar extra-directory ...
.Sh DESCRIPTION
The utility
.Nm
@@ -65,13 +63,6 @@ creates a file system image into
.Ar image-file
from the directory tree
.Ar directory .
-If any optional directory trees are passed in the
-.Ar extra-directory
-arguments, then the directory tree of each argument will be merged
-into the
-.Ar directory
-first before creating
-.Ar image-file .
No special devices or privileges are required to perform this task.
.Pp
The options are as follows:
@@ -135,8 +126,6 @@ Set file system specific options.
.Ar fs-options
is a comma separated list of options.
Valid file system specific options are detailed below.
-.It Fl r
-When merging multiple directories replace duplicate files with the last found.
.It Fl S Ar sector-size
Set the file system sector size to
.Ar sector-size .
diff --git a/usr.sbin/makefs/makefs.c b/usr.sbin/makefs/makefs.c
index b89334a1a39..06580074594 100644
--- a/usr.sbin/makefs/makefs.c
+++ b/usr.sbin/makefs/makefs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: makefs.c,v 1.4 2016/10/16 20:30:40 natano Exp $ */
+/* $OpenBSD: makefs.c,v 1.5 2016/10/16 20:45:07 natano Exp $ */
/* $NetBSD: makefs.c,v 1.53 2015/11/27 15:10:32 joerg Exp $ */
/*
@@ -108,7 +108,7 @@ main(int argc, char *argv[])
err(1, "Unable to get system time");
- while ((ch = getopt(argc, argv, "B:b:d:f:M:m:O:o:rs:S:t:T:")) != -1) {
+ while ((ch = getopt(argc, argv, "B:b:d:f:M:m:O:o:s:S:t:T:")) != -1) {
switch (ch) {
case 'B':
@@ -190,10 +190,6 @@ main(int argc, char *argv[])
break;
}
- case 'r':
- fsoptions.replace = 1;
- break;
-
case 's':
fsoptions.minsize = fsoptions.maxsize =
strsuftoll("size", optarg, 1LL, LLONG_MAX);
@@ -237,26 +233,14 @@ main(int argc, char *argv[])
argc -= optind;
argv += optind;
- if (argc < 2)
+ if (argc != 2)
usage(fstype, &fsoptions);
/* walk the tree */
TIMER_START(start);
- root = walk_dir(argv[1], ".", NULL, NULL, fsoptions.replace);
+ root = walk_dir(argv[1], ".", NULL, NULL);
TIMER_RESULTS(start, "walk_dir");
- /* append extra directory */
- for (i = 2; i < argc; i++) {
- struct stat sb;
- if (stat(argv[i], &sb) == -1)
- err(1, "Can't stat `%s'", argv[i]);
- if (!S_ISDIR(sb.st_mode))
- errx(1, "%s: not a directory", argv[i]);
- TIMER_START(start);
- root = walk_dir(argv[i], ".", NULL, root, fsoptions.replace);
- TIMER_RESULTS(start, "walk_dir2");
- }
-
if (debug & DEBUG_DUMP_FSNODES) {
printf("\nparent: %s\n", argv[1]);
dump_fsnodes(root);
@@ -411,11 +395,11 @@ usage(fstype_t *fstype, fsinfo_t *fsoptions)
prog = getprogname();
fprintf(stderr,
-"Usage: %s [-r] [-B endian] [-b free-blocks] [-d debug-mask]\n"
+"Usage: %s [-B endian] [-b free-blocks] [-d debug-mask]\n"
"\t[-f free-files] [-M minimum-size] [-m maximum-size]\n"
"\t[-O offset] [-o fs-options] [-S sector-size]\n"
"\t[-s image-size] [-T <timestamp/file>] [-t fs-type]"
-" image-file directory [extra-directory ...]\n",
+" image-file directory\n",
prog);
if (fstype) {
diff --git a/usr.sbin/makefs/makefs.h b/usr.sbin/makefs/makefs.h
index 26acdb8bc2e..3c9e81833d1 100644
--- a/usr.sbin/makefs/makefs.h
+++ b/usr.sbin/makefs/makefs.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: makefs.h,v 1.3 2016/10/16 20:30:40 natano Exp $ */
+/* $OpenBSD: makefs.h,v 1.4 2016/10/16 20:45:07 natano Exp $ */
/* $NetBSD: makefs.h,v 1.36 2015/11/25 00:48:49 christos Exp $ */
/*
@@ -158,7 +158,6 @@ typedef struct makefs_fsinfo {
int freeblockpc; /* free block % */
int needswap; /* non-zero if byte swapping needed */
int sectorsize; /* sector size */
- int replace; /* replace files when merging */
void *fs_specific; /* File system specific additions. */
option_t *fs_options; /* File system specific options */
@@ -172,7 +171,7 @@ const char * inode_type(mode_t);
int set_option(const option_t *, const char *, char *, size_t);
int set_option_var(const option_t *, const char *, const char *,
char *, size_t);
-fsnode * walk_dir(const char *, const char *, fsnode *, fsnode *, int);
+fsnode * walk_dir(const char *, const char *, fsnode *, fsnode *);
void free_fsnodes(fsnode *);
option_t * copy_opts(const option_t *);
diff --git a/usr.sbin/makefs/walk.c b/usr.sbin/makefs/walk.c
index 35c47749db1..eb69b4a834e 100644
--- a/usr.sbin/makefs/walk.c
+++ b/usr.sbin/makefs/walk.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: walk.c,v 1.3 2016/10/16 20:26:56 natano Exp $ */
+/* $OpenBSD: walk.c,v 1.4 2016/10/16 20:45:07 natano Exp $ */
/* $NetBSD: walk.c,v 1.29 2015/11/25 00:48:49 christos Exp $ */
/*
@@ -62,8 +62,7 @@ static fsinode *link_check(fsinode *);
* at the start of the list, and without ".." entries.
*/
fsnode *
-walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join,
- int replace)
+walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join)
{
fsnode *first, *cur, *prev, *last;
DIR *dirp;
@@ -141,30 +140,13 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join,
printf("merging %s with %p\n",
path, cur->child);
cur->child = walk_dir(root, rp, cur,
- cur->child, replace);
+ cur->child);
continue;
}
- if (!replace)
- errx(1, "Can't merge %s `%s' with "
- "existing %s",
- inode_type(stbuf.st_mode), path,
- inode_type(cur->type));
- else {
- if (debug & DEBUG_WALK_DIR_NODE)
- printf("replacing %s %s\n",
- inode_type(stbuf.st_mode),
- path);
- if (cur == join->next)
- join->next = cur->next;
- else {
- fsnode *p;
- for (p = join->next;
- p->next != cur; p = p->next)
- continue;
- p->next = cur->next;
- }
- free(cur);
- }
+ errx(1, "Can't merge %s `%s' with "
+ "existing %s",
+ inode_type(stbuf.st_mode), path,
+ inode_type(cur->type));
}
}
@@ -185,8 +167,7 @@ walk_dir(const char *root, const char *dir, fsnode *parent, fsnode *join,
first = cur;
cur->first = first;
if (S_ISDIR(cur->type)) {
- cur->child = walk_dir(root, rp, cur, NULL,
- replace);
+ cur->child = walk_dir(root, rp, cur, NULL);
continue;
}
}