Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/makefs If an entry is in the specfile but not in th...
details: https://anonhg.NetBSD.org/src/rev/2849f2bbc3d4
branches: trunk
changeset: 521892:2849f2bbc3d4
user: lukem <lukem%NetBSD.org@localhost>
date: Fri Feb 08 01:17:32 2002 +0000
description:
If an entry is in the specfile but not in the underlying file system, and it's
marked "optional", don't add it. (e.g, don't create a zero-length file).
diffstat:
usr.sbin/makefs/makefs.8 | 14 +++++++++++---
usr.sbin/makefs/walk.c | 24 +++++++++++++++---------
2 files changed, 26 insertions(+), 12 deletions(-)
diffs (101 lines):
diff -r f83e301991e0 -r 2849f2bbc3d4 usr.sbin/makefs/makefs.8
--- a/usr.sbin/makefs/makefs.8 Fri Feb 08 00:58:58 2002 +0000
+++ b/usr.sbin/makefs/makefs.8 Fri Feb 08 01:17:32 2002 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: makefs.8,v 1.5 2002/01/24 03:21:07 lukem Exp $
+.\" $NetBSD: makefs.8,v 1.6 2002/02/08 01:17:32 lukem Exp $
.\"
.\" Copyright (c) 2001-2002 Wasabi Systems, Inc.
.\" All rights reserved.
@@ -33,7 +33,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd January 24, 2002
+.Dd February 8, 2002
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -169,7 +169,14 @@
An error will be raised if the type of entry in the specfile conflicts
with that of an existing entry.
.Pp
-Otherwise, it is necessary to specify at least the following parameters
+In the opposite case
+(where a specfile entry does not have an entry in the underlying file system)
+the following occurs:
+If the specfile entry is marked
+.Sy optional ,
+the specfile entry is ignored.
+Otherwise, the entry will be created in the image,
+and it is necessary to specify at least the following parameters
in the specfile:
.Sy type ,
.Sy mode ,
@@ -190,6 +197,7 @@
If
.Sy flags
isn't provided, the current file flags will be used.
+Missing regular file entries will be created as zero-length files.
.It Fl N Ar dbdir
Use the user database text file
.Pa master.passwd
diff -r f83e301991e0 -r 2849f2bbc3d4 usr.sbin/makefs/walk.c
--- a/usr.sbin/makefs/walk.c Fri Feb 08 00:58:58 2002 +0000
+++ b/usr.sbin/makefs/walk.c Fri Feb 08 01:17:32 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: walk.c,v 1.8 2002/01/31 22:44:03 tv Exp $ */
+/* $NetBSD: walk.c,v 1.9 2002/02/08 01:17:32 lukem Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -77,7 +77,7 @@
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: walk.c,v 1.8 2002/01/31 22:44:03 tv Exp $");
+__RCSID("$NetBSD: walk.c,v 1.9 2002/02/08 01:17:32 lukem Exp $");
#endif /* !__lint */
#include <sys/param.h>
@@ -279,14 +279,24 @@
if (strcmp(curnode->name, curfsnode->name) == 0)
break;
}
+ if (snprintf(path, sizeof(path), "%s/%s",
+ dir, curnode->name) >= sizeof(path))
+ errx(1, "Pathname too long.");
if (curfsnode == NULL) { /* need new entry */
struct stat stbuf;
+ /*
+ * don't add optional spec entries
+ * that lack an existing fs entry
+ */
+ if ((curnode->flags & F_OPT) &&
+ lstat(path, &stbuf) == -1)
+ continue;
+
/* check that enough info is provided */
#define NODETEST(t, m) \
if (!(t)) \
- errx(1, "`%s/%s': %s not provided", \
- dir, curnode->name, m)
+ errx(1, "`%s': %s not provided", path, m)
NODETEST(curnode->flags & F_TYPE, "type");
NODETEST(curnode->flags & F_MODE, "mode");
/* XXX: require F_TIME ? */
@@ -334,12 +344,8 @@
apply_specentry(dir, curnode, curfsnode);
if (curnode->type == F_DIR) {
if (curfsnode->type != S_IFDIR)
- errx(1, "`%s/%s' is not a directory",
- dir, curfsnode->name);
+ errx(1, "`%s' is not a directory", path);
assert (curfsnode->child != NULL);
- if (snprintf(path, sizeof(path), "%s/%s",
- dir, curnode->name) >= sizeof(path))
- errx(1, "Pathname too long.");
apply_specdir(path, curnode, curfsnode->child);
}
}
Home |
Main Index |
Thread Index |
Old Index