CVS commit: src/usr.sbin/makefs

2021-04-03 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Sat Apr  3 14:10:56 UTC 2021

Modified Files:
src/usr.sbin/makefs: makefs.8 makefs.c makefs.h walk.c

Log Message:
Add a -L option to follow all symbolic links.  Useful if you have symlinks
in a makefs directory tree but want to refer to the actual file.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.29 -r1.30 src/usr.sbin/makefs/walk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.66 src/usr.sbin/makefs/makefs.8:1.67
--- src/usr.sbin/makefs/makefs.8:1.66	Sun Nov 15 00:18:48 2020
+++ src/usr.sbin/makefs/makefs.8	Sat Apr  3 14:10:56 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.66 2020/11/15 00:18:48 jmcneill Exp $
+.\"	$NetBSD: makefs.8,v 1.67 2021/04/03 14:10:56 simonb Exp $
 .\"
 .\" Copyright (c) 2001-2003 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 November 14, 2020
+.Dd April 4, 2021
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -41,7 +41,7 @@
 .Nd create a file system image from a directory tree
 .Sh SYNOPSIS
 .Nm
-.Op Fl rxZ
+.Op Fl LrxZ
 .Op Fl B Ar endian
 .Op Fl b Ar free-blocks
 .Op Fl d Ar debug-mask
@@ -158,6 +158,8 @@ An optional
 suffix may be provided to indicate that
 .Ar free-files
 indicates a percentage of the calculated image size.
+.It Fl L
+All symbolic links are followed.
 .It Fl M Ar minimum-size
 Set the minimum size of the file system image to
 .Ar minimum-size .

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.53 src/usr.sbin/makefs/makefs.c:1.54
--- src/usr.sbin/makefs/makefs.c:1.53	Fri Nov 27 15:10:32 2015
+++ src/usr.sbin/makefs/makefs.c	Sat Apr  3 14:10:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.53 2015/11/27 15:10:32 joerg Exp $	*/
+/*	$NetBSD: makefs.c,v 1.54 2021/04/03 14:10:56 simonb Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.53 2015/11/27 15:10:32 joerg Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.54 2021/04/03 14:10:56 simonb Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -129,7 +129,7 @@ main(int argc, char *argv[])
 		err(1, "Unable to get system time");
 
 
-	while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:O:o:rs:S:t:T:xZ")) != -1) {
+	while ((ch = getopt(argc, argv, "B:b:d:f:F:LM:m:N:O:o:rs:S:t:T:xZ")) != -1) {
 		switch (ch) {
 
 		case 'B':
@@ -187,6 +187,10 @@ main(int argc, char *argv[])
 			specfile = optarg;
 			break;
 
+		case 'L':
+			fsoptions.follow = true;
+			break;
+
 		case 'M':
 			fsoptions.minsize =
 			strsuftoll("minimum size", optarg, 1LL, LLONG_MAX);
@@ -286,7 +290,8 @@ main(int argc, char *argv[])
 
 /* walk the tree */
 	TIMER_START(start);
-	root = walk_dir(argv[1], ".", NULL, NULL, fsoptions.replace);
+	root = walk_dir(argv[1], ".", NULL, NULL, fsoptions.replace,
+	fsoptions.follow);
 	TIMER_RESULTS(start, "walk_dir");
 
 	/* append extra directory */
@@ -297,7 +302,8 @@ main(int argc, char *argv[])
 		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);
+		root = walk_dir(argv[i], ".", NULL, root, fsoptions.replace,
+		fsoptions.follow);
 		TIMER_RESULTS(start, "walk_dir2");
 	}
 

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.36 src/usr.sbin/makefs/makefs.h:1.37
--- src/usr.sbin/makefs/makefs.h:1.36	Wed Nov 25 00:48:49 2015
+++ src/usr.sbin/makefs/makefs.h	Sat Apr  3 14:10:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.36 2015/11/25 00:48:49 christos Exp $	*/
+/*	$NetBSD: makefs.h,v 1.37 2021/04/03 14:10:56 simonb Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -166,6 +166,7 @@ typedef struct makefs_fsinfo {
 	int	sectorsize;	/* sector size */
 	int	sparse;		/* sparse image, don't fill it with zeros */
 	int	replace;	/* replace files when merging */
+	int	follow;		/* follow symlinks */
 
 	void	*fs_specific;	/* File system specific additions. */
 	option_t *fs_options;	/* File system specific options */
@@ -180,7 +181,8 @@ 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 *, int,
+int);
 void		free_fsnodes(fsnode *);
 option_t *	copy_opts(const option_t *);
 

Index: src/usr.sbin/makefs/walk.c
diff -u 

CVS commit: src/usr.sbin/makefs

2020-11-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Nov 15 00:18:48 UTC 2020

Modified Files:
src/usr.sbin/makefs: makefs.8
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c

Log Message:
Add "efi" as a supported boot image type and derive the platform ID for
the validation entry from the default boot image instead of hard-coding
X86.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.65 src/usr.sbin/makefs/makefs.8:1.66
--- src/usr.sbin/makefs/makefs.8:1.65	Sat Apr  4 13:44:57 2020
+++ src/usr.sbin/makefs/makefs.8	Sun Nov 15 00:18:48 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.65 2020/04/04 13:44:57 reinoud Exp $
+.\"	$NetBSD: makefs.8,v 1.66 2020/11/15 00:18:48 jmcneill Exp $
 .\"
 .\" Copyright (c) 2001-2003 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 November 6, 2019
+.Dd November 14, 2020
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -358,6 +358,7 @@ Filename of a boot image in the format
 where
 .Dq sysid
 is one of
+.Ql efi ,
 .Ql i386 ,
 .Ql mac68k ,
 .Ql macppc ,

Index: src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.23 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.24
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.23	Wed Mar 28 06:48:55 2018
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Sun Nov 15 00:18:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.24 2020/11/15 00:18:48 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.24 2020/11/15 00:18:48 jmcneill Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -109,9 +109,11 @@ cd9660_add_boot_disk(iso9660_disk *diskS
 	else if (strcmp(sysname, "macppc") == 0 ||
 	 strcmp(sysname, "mac68k") == 0)
 		new_image->system = ET_SYS_MAC;
+	else if (strcmp(sysname, "efi") == 0)
+		new_image->system = ET_SYS_EFI;
 	else {
 		warnx("boot disk system must be "
-		  "i386, powerpc, macppc, or mac68k");
+		  "i386, powerpc, macppc, mac68k, or efi");
 		free(temp);
 		free(new_image);
 		return 0;
@@ -363,6 +365,7 @@ cd9660_setup_boot(iso9660_disk *diskStru
 	struct boot_catalog_entry *x86_head, *mac_head, *ppc_head, *efi_head,
 		*valid_entry, *default_entry, *temp, *head, **headp, *next;
 	struct cd9660_boot_image *tmp_disk;
+	u_char system;
 
 	headp = NULL;
 	x86_head = mac_head = ppc_head = efi_head = NULL;
@@ -377,9 +380,16 @@ cd9660_setup_boot(iso9660_disk *diskStru
 	cd9660_bothendian_dword(first_sector,
 		diskStructure->boot_descriptor->boot_catalog_pointer);
 
+	/*
+	 * Use system type of default image for validation entry. Fallback to
+	 * X86 system type if not found.
+	 */
+	system = default_boot_image != NULL ? default_boot_image->system :
+	  ET_SYS_X86; 
+
 	/* Step 1: Generate boot catalog */
 	/* Step 1a: Validation entry */
-	valid_entry = cd9660_boot_setup_validation_entry(ET_SYS_X86);
+	valid_entry = cd9660_boot_setup_validation_entry(system);
 	if (valid_entry == NULL)
 		return -1;
 



CVS commit: src/usr.sbin/makefs

2020-11-10 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Nov 10 20:48:29 UTC 2020

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
rock_ridge_move_count is only incremented and can never be negative so change
%08i to %08u.
This removes a warning when compiling with tools outside ./build.sh


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.56 src/usr.sbin/makefs/cd9660.c:1.57
--- src/usr.sbin/makefs/cd9660.c:1.56	Fri Oct 18 04:09:02 2019
+++ src/usr.sbin/makefs/cd9660.c	Tue Nov 10 20:48:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.56 2019/10/18 04:09:02 msaitoh Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.57 2020/11/10 20:48:29 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.56 2019/10/18 04:09:02 msaitoh Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.57 2020/11/10 20:48:29 reinoud Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -1295,7 +1295,7 @@ cd9660_rrip_move_directory(iso9660_disk 
 		return NULL;
 
 	diskStructure->rock_ridge_move_count++;
-	snprintf(newname, sizeof(newname), "%08i",
+	snprintf(newname, sizeof(newname), "%08u",
 	diskStructure->rock_ridge_move_count);
 
 	/* Point to old parent */



CVS commit: src/usr.sbin/makefs

2020-04-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Apr 18 12:25:01 UTC 2020

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
Remove unused variable (to fix the build)


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.20 src/usr.sbin/makefs/udf.c:1.21
--- src/usr.sbin/makefs/udf.c:1.20	Sat Apr 18 09:45:45 2020
+++ src/usr.sbin/makefs/udf.c	Sat Apr 18 12:25:01 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.20 2020/04/18 09:45:45 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.21 2020/04/18 12:25:01 martin Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf.c,v 1.20 2020/04/18 09:45:45 reinoud Exp $");
+__RCSID("$NetBSD: udf.c,v 1.21 2020/04/18 12:25:01 martin Exp $");
 
 #include 
 #include 
@@ -562,7 +562,6 @@ udf_file_inject_blob(union dscrptr *dscr
 	struct extfile_entry *efe;
 	uint64_t inf_len, obj_size;
 	uint32_t l_ea, l_ad;
-	uint32_t desc_size;
 	uint16_t crclen;
 	uint8_t *data, *pos;
 
@@ -576,7 +575,6 @@ udf_file_inject_blob(union dscrptr *dscr
 		icb   = >icbtag;
 		inf_len   = udf_rw64(fe->inf_len);
 		obj_size  = 0;
-		desc_size = sizeof(struct file_entry);
 	} else if (udf_rw16(dscr->tag.id) == TAGID_EXTFENTRY) {
 		efe   = >efe;
 		data  = efe->data;
@@ -585,7 +583,6 @@ udf_file_inject_blob(union dscrptr *dscr
 		icb   = >icbtag;
 		inf_len   = udf_rw64(efe->inf_len);
 		obj_size  = udf_rw64(efe->obj_size);
-		desc_size = sizeof(struct extfile_entry);
 	} else {
 		errx(1, "Bad tag passed to udf_file_inject_blob");
 	}



CVS commit: src/usr.sbin/makefs

2020-04-18 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Apr 18 09:45:45 UTC 2020

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
Believe the datablocks predictor when determining if data on a node gets
stored internal or not. Also make a note that the datablocks predictor takes
NO extended attributes stored in the node into account

In rare cases it could lead to confusion where the predictor would say it
wouldn't fit internally when it could just have fitted. This would trigger the
assertion. Now it will on rare accasions create a datablock even though it
might have fitted.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.19 src/usr.sbin/makefs/udf.c:1.20
--- src/usr.sbin/makefs/udf.c:1.19	Sun Feb  3 03:19:31 2019
+++ src/usr.sbin/makefs/udf.c	Sat Apr 18 09:45:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.19 2019/02/03 03:19:31 mrg Exp $ */
+/* $NetBSD: udf.c,v 1.20 2020/04/18 09:45:45 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf.c,v 1.19 2019/02/03 03:19:31 mrg Exp $");
+__RCSID("$NetBSD: udf.c,v 1.20 2020/04/18 09:45:45 reinoud Exp $");
 
 #include 
 #include 
@@ -514,6 +514,7 @@ static uint32_t
 udf_datablocks(off_t sz)
 {
 	/* predictor if it can be written inside the node */
+	/* XXX the predictor assumes NO extended attributes in the node */
 	if (sz < context.sector_size - UDF_EXTFENTRY_SIZE - 16)
 		return 0;
 
@@ -561,7 +562,7 @@ udf_file_inject_blob(union dscrptr *dscr
 	struct extfile_entry *efe;
 	uint64_t inf_len, obj_size;
 	uint32_t l_ea, l_ad;
-	uint32_t free_space, desc_size;
+	uint32_t desc_size;
 	uint16_t crclen;
 	uint8_t *data, *pos;
 
@@ -590,10 +591,9 @@ udf_file_inject_blob(union dscrptr *dscr
 	}
 	crclen = udf_rw16(dscr->tag.desc_crc_len);
 
-	/* calculate free space */
-	free_space = context.sector_size - (l_ea + l_ad) - desc_size;
+	/* check if it will fit internally */
 	if (udf_datablocks(size)) {
-		assert(free_space < size);
+		/* the predictor tells it won't fit internally */
 		return 1;
 	}
 
@@ -602,7 +602,6 @@ udf_file_inject_blob(union dscrptr *dscr
 	assert((udf_rw16(icb->flags) & UDF_ICB_TAG_FLAGS_ALLOC_MASK) ==
 			UDF_ICB_INTERN_ALLOC);
 
-	// assert(free_space >= size);
 	pos = data + l_ea + l_ad;
 	memcpy(pos, blob, size);
 	l_ad   += size;



CVS commit: src/usr.sbin/makefs

2020-04-04 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Sat Apr  4 13:44:57 UTC 2020

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Indent the makefs(8) options for UDF like the other filesystems described.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.64 src/usr.sbin/makefs/makefs.8:1.65
--- src/usr.sbin/makefs/makefs.8:1.64	Wed Nov  6 21:04:22 2019
+++ src/usr.sbin/makefs/makefs.8	Sat Apr  4 13:44:57 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.64 2019/11/06 21:04:22 christos Exp $
+.\"	$NetBSD: makefs.8,v 1.65 2020/04/04 13:44:57 reinoud Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -489,7 +489,7 @@ Each of the options consists of a keywor
 and a value.
 The following keywords are supported:
 .Pp
-.Bl -tag -width optimization -compact
+.Bl -tag -width optimization -offset indent -compact
 .It Sy disctype
 This can have the following values:
 .Bl -tag -width cdromXdvdromXbdromXXX -compact



CVS commit: src/usr.sbin/makefs/ffs

2020-03-25 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Mar 26 04:25:28 UTC 2020

Modified Files:
src/usr.sbin/makefs/ffs: mkfs.c

Log Message:
Fix the build, use %jd and (intmax_t) cast for big numbers, off_t
and ptrdiff_t aren't always the same size.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.38 src/usr.sbin/makefs/ffs/mkfs.c:1.39
--- src/usr.sbin/makefs/ffs/mkfs.c:1.38	Wed Mar 25 20:17:48 2020
+++ src/usr.sbin/makefs/ffs/mkfs.c	Thu Mar 26 04:25:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.38 2020/03/25 20:17:48 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.39 2020/03/26 04:25:28 kre Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.38 2020/03/25 20:17:48 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.39 2020/03/26 04:25:28 kre Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -821,8 +821,8 @@ ffs_wtfs(daddr_t bno, int size, void *bf
 
 	offset = bno * fsopts->sectorsize + fsopts->offset;
 	if (lseek(fsopts->fd, offset, SEEK_SET) == -1)
-		err(EXIT_FAILURE, "%s: seek error @%td for sector %jd",
-		__func__, offset, (intmax_t)bno);
+		err(EXIT_FAILURE, "%s: seek error @%jd for sector %jd",
+		__func__, (intmax_t)offset, (intmax_t)bno);
 	n = write(fsopts->fd, bf, size);
 	if (n == -1)
 		err(EXIT_FAILURE, "%s: write error for sector %jd", __func__,



CVS commit: src/usr.sbin/makefs/ffs

2020-03-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 25 20:17:48 UTC 2020

Modified Files:
src/usr.sbin/makefs/ffs: mkfs.c

Log Message:
improve error messages.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.37 src/usr.sbin/makefs/ffs/mkfs.c:1.38
--- src/usr.sbin/makefs/ffs/mkfs.c:1.37	Wed Feb  8 23:42:53 2017
+++ src/usr.sbin/makefs/ffs/mkfs.c	Wed Mar 25 16:17:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.37 2017/02/09 04:42:53 kre Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.38 2020/03/25 20:17:48 christos Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.37 2017/02/09 04:42:53 kre Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.38 2020/03/25 20:17:48 christos Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -821,15 +821,15 @@ ffs_wtfs(daddr_t bno, int size, void *bf
 
 	offset = bno * fsopts->sectorsize + fsopts->offset;
 	if (lseek(fsopts->fd, offset, SEEK_SET) == -1)
-		err(EXIT_FAILURE, "%s: seek error for sector %lld", __func__,
-		(long long)bno);
+		err(EXIT_FAILURE, "%s: seek error @%td for sector %jd",
+		__func__, offset, (intmax_t)bno);
 	n = write(fsopts->fd, bf, size);
 	if (n == -1)
-		err(EXIT_FAILURE, "%s: write error for sector %lld", __func__,
-		(long long)bno);
+		err(EXIT_FAILURE, "%s: write error for sector %jd", __func__,
+		(intmax_t)bno);
 	else if (n != size)
-		errx(EXIT_FAILURE, "%s: short write error for sector %lld",
-		__func__, (long long)bno);
+		errx(EXIT_FAILURE, "%s: short write error for sector %jd",
+		__func__, (intmax_t)bno);
 }
 
 



CVS commit: src/usr.sbin/makefs/cd9660

2018-03-28 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Mar 28 06:48:55 UTC 2018

Modified Files:
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c

Log Message:
Correctly mark the last El Torito section header.

Pointed out by Benno Rice via DM.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.23
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22	Thu Nov  9 01:28:05 2017
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Wed Mar 28 06:48:55 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.23 2018/03/28 06:48:55 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -497,6 +497,12 @@ cd9660_setup_boot(iso9660_disk *diskStru
 		LIST_INSERT_AFTER(head, temp, ll_struct);
 	}
 
+	/* Find the last Section Header entry and mark it as the last. */
+	head = NULL;
+	LIST_FOREACH(next, >boot_entries, ll_struct) {
+		if (next->entry_type == ET_ENTRY_SH)
+			head = next;
+	}
 	if (head != NULL)
 		head->entry_data.SH.header_indicator[0] = ET_SECTION_HEADER_LAST;
 



CVS commit: src/usr.sbin/makefs/msdos

2018-01-26 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sat Jan 27 02:07:33 UTC 2018

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vfsops.c

Log Message:
Need strings.h for ffs()


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vfsops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.10 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.11
--- src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.10	Sat Jan 30 09:59:27 2016
+++ src/usr.sbin/makefs/msdos/msdosfs_vfsops.c	Sat Jan 27 02:07:33 2018
@@ -50,7 +50,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.10 2016/01/30 09:59:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.11 2018/01/27 02:07:33 sevan Exp $");
 
 #include 
 
@@ -68,6 +68,7 @@ __KERNEL_RCSID(0, "$NetBSD: msdosfs_vfso
 #include 
 #include 
 #include 
+#include 
 
 #include "makefs.h"
 #include "msdos.h"



CVS commit: src/usr.sbin/makefs

2017-12-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec 16 23:08:40 UTC 2017

Modified Files:
src/usr.sbin/makefs: ffs.c

Log Message:
PR/52828: Mark Johnston: makefs UFS2 lazy inode initialization is buggy

makefs(8) emulates UFS2 in performing lazy initialization of inode
blocks when allocating and writing inodes. However, it only ever
initializes one inode block at a time, which may be insufficient.
If so, a later initialization may clobber an inode, resulting in
an inconsistent filesystem.

I committed a minimal fix for the problem to FreeBSD:
https://svnweb.freebsd.org/changeset/base/326912


To generate a diff of this commit:
cvs rdiff -u -r1.69 -r1.70 src/usr.sbin/makefs/ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.69 src/usr.sbin/makefs/ffs.c:1.70
--- src/usr.sbin/makefs/ffs.c:1.69	Wed Feb  8 16:27:26 2017
+++ src/usr.sbin/makefs/ffs.c	Sat Dec 16 18:08:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.69 2017/02/08 21:27:26 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.70 2017/12/16 23:08:40 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.69 2017/02/08 21:27:26 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.70 2017/12/16 23:08:40 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -1115,7 +1115,7 @@ ffs_write_inode(union dinode *dp, uint32
 	 * Initialize inode blocks on the fly for UFS2.
 	 */
 	initediblk = ufs_rw32(cgp->cg_initediblk, fsopts->needswap);
-	if (ffs_opts->version == 2 &&
+	while (ffs_opts->version == 2 &&
 	(uint32_t)(cgino + FFS_INOPB(fs)) > initediblk &&
 	initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
 		memset(buf, 0, fs->fs_bsize);



CVS commit: src/usr.sbin/makefs/cd9660

2017-11-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Nov  9 01:28:06 UTC 2017

Modified Files:
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c

Log Message:
Initialize boot_catalog_entry's entry_type properly.

This had been missing but the type was used in cd9660_setup_boot().

>From OpenBSD usr.sbin/makefs/cd9660/cd9660_eltorito.c r1.10.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.21 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.22
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.21	Tue Jan 24 11:22:43 2017
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Thu Nov  9 01:28:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.22 2017/11/09 01:28:05 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -247,6 +247,7 @@ cd9660_boot_setup_validation_entry(char 
 	size_t i;
 	entry = cd9660_init_boot_catalog_entry();
 
+	entry->entry_type = ET_ENTRY_VE;
 	ve = >entry_data.VE;
 
 	ve->header_id[0] = 1;
@@ -281,6 +282,7 @@ cd9660_boot_setup_default_entry(struct c
 	if (default_entry == NULL)
 		return NULL;
 
+	default_entry->entry_type = ET_ENTRY_IE;
 	ie = _entry->entry_data.IE;
 
 	ie->boot_indicator[0] = disk->bootable;
@@ -308,6 +310,7 @@ cd9660_boot_setup_section_head(char plat
 	if (entry == NULL)
 		return NULL;
 
+	entry->entry_type = ET_ENTRY_SH;
 	sh = >entry_data.SH;
 	/* More by default. The last one will manually be set to 0x91 */
 	sh->header_indicator[0] = ET_SECTION_HEADER_MORE;
@@ -324,6 +327,7 @@ cd9660_boot_setup_section_entry(struct c
 	if ((entry = cd9660_init_boot_catalog_entry()) == NULL)
 		return NULL;
 
+	entry->entry_type = ET_ENTRY_SE;
 	se = >entry_data.SE;
 
 	se->boot_indicator[0] = ET_BOOTABLE;



CVS commit: src/usr.sbin/makefs

2017-04-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 14 15:40:35 UTC 2017

Modified Files:
src/usr.sbin/makefs: msdos.c

Log Message:
leave the size alone and set the create_size to include the offset. It
does not matter anyway, but it makes more sense this way.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makefs/msdos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.19 src/usr.sbin/makefs/msdos.c:1.20
--- src/usr.sbin/makefs/msdos.c:1.19	Thu Apr 13 13:20:59 2017
+++ src/usr.sbin/makefs/msdos.c	Fri Apr 14 11:40:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.19 2017/04/13 17:20:59 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.20 2017/04/14 15:40:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: msdos.c,v 1.19 2017/04/13 17:20:59 christos Exp $");
+__RCSID("$NetBSD: msdos.c,v 1.20 2017/04/14 15:40:35 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -157,9 +157,9 @@ msdos_makefs(const char *image, const ch
 	assert(root != NULL);
 	assert(fsopts != NULL);
 
-	fsopts->size = fsopts->offset + fsopts->maxsize;
+	fsopts->size = fsopts->maxsize;
 	msdos_opt->options.create_size = MAX(msdos_opt->options.create_size,
-		fsopts->size);
+	fsopts->offset + fsopts->size);
 	msdos_opt->options.offset = fsopts->offset;
 	if (msdos_opt->options.bytes_per_sector == 0) {
 		if (fsopts->sectorsize == -1)



CVS commit: src/usr.sbin/makefs

2017-04-14 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Apr 14 07:09:43 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Whitespace fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.62 src/usr.sbin/makefs/makefs.8:1.63
--- src/usr.sbin/makefs/makefs.8:1.62	Thu Apr 13 17:21:29 2017
+++ src/usr.sbin/makefs/makefs.8	Fri Apr 14 07:09:43 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.62 2017/04/13 17:21:29 christos Exp $
+.\"	$NetBSD: makefs.8,v 1.63 2017/04/14 07:09:43 wiz Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -205,8 +205,8 @@ This is equivalent of setting both the m
 and the maximum
 .Fl ( M )
 sizes to
-.Ar image-size.
-For 
+.Ar image-size .
+For
 .Sy ffs
 and
 .Sy msdos



CVS commit: src/usr.sbin/makefs

2017-04-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 13 17:21:29 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Explain the 's' image size better.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.61 src/usr.sbin/makefs/makefs.8:1.62
--- src/usr.sbin/makefs/makefs.8:1.61	Sun Feb 12 09:45:09 2017
+++ src/usr.sbin/makefs/makefs.8	Thu Apr 13 13:21:29 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.61 2017/02/12 14:45:09 wiz Exp $
+.\"	$NetBSD: makefs.8,v 1.62 2017/04/13 17:21:29 christos Exp $
 .\"
 .\" Copyright (c) 2001-2003 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 February 11, 2017
+.Dd April 13, 2017
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -200,6 +200,19 @@ Defaults to 512.
 .It Fl s Ar image-size
 Set the size of the file system image to
 .Ar image-size .
+This is equivalent of setting both the minimum
+.Fl ( m )
+and the maximum
+.Fl ( M )
+sizes to
+.Ar image-size.
+For 
+.Sy ffs
+and
+.Sy msdos
+the
+.Ar offset
+is not included on that size.
 .It Fl T Ar timestamp
 Specify a timestamp to be set for all file system files and directories
 created so that repeatable builds are possible.



CVS commit: src/usr.sbin/makefs

2017-04-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 13 17:20:59 UTC 2017

Modified Files:
src/usr.sbin/makefs: msdos.c

Log Message:
for consistency with ffs, don't count the offset into the size.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makefs/msdos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.18 src/usr.sbin/makefs/msdos.c:1.19
--- src/usr.sbin/makefs/msdos.c:1.18	Thu Feb 16 17:44:06 2017
+++ src/usr.sbin/makefs/msdos.c	Thu Apr 13 13:20:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.18 2017/02/16 22:44:06 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.19 2017/04/13 17:20:59 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: msdos.c,v 1.18 2017/02/16 22:44:06 christos Exp $");
+__RCSID("$NetBSD: msdos.c,v 1.19 2017/04/13 17:20:59 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -157,12 +157,9 @@ msdos_makefs(const char *image, const ch
 	assert(root != NULL);
 	assert(fsopts != NULL);
 
-	/*
-	 * XXX: pick up other options from the msdos specific ones?
-	 * Is minsize right here?
-	 */
+	fsopts->size = fsopts->offset + fsopts->maxsize;
 	msdos_opt->options.create_size = MAX(msdos_opt->options.create_size,
-		fsopts->minsize);
+		fsopts->size);
 	msdos_opt->options.offset = fsopts->offset;
 	if (msdos_opt->options.bytes_per_sector == 0) {
 		if (fsopts->sectorsize == -1)



CVS commit: src/usr.sbin/makefs/msdos

2017-04-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Apr 13 17:10:12 UTC 2017

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
Fix error handling; msdosfs_wfile is supposed to return errno.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.18 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.19
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.18	Thu Feb 16 13:50:05 2017
+++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c	Thu Apr 13 13:10:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.18 2017/02/16 18:50:05 christos Exp $ */
+/*	$NetBSD: msdosfs_vnops.c,v 1.19 2017/04/13 17:10:12 christos Exp $ */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.18 2017/02/16 18:50:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.19 2017/04/13 17:10:12 christos Exp $");
 
 #include 
 #include 
@@ -440,31 +440,29 @@ msdosfs_wfile(const char *path, struct d
 		return 0;
 
 	/* Don't bother to try to write files larger than the fs limit */
-	if (st->st_size > MSDOSFS_FILESIZE_MAX) {
-		errno = EFBIG;
-		return -1;
-	}
+	if (st->st_size > MSDOSFS_FILESIZE_MAX)
+		return EFBIG;
 
 	nsize = st->st_size;
 	DPRINTF(("%s(nsize=%zu, osize=%zu)\n", __func__, nsize, osize));
 	if (nsize > osize) {
-		if ((error = deextend(dep, nsize, NULL)) != 0) {
-			errno = error;
-			return -1;
-		}
-		if ((error = msdosfs_updatede(dep)) != 0) {
-			errno = error;
-			return -1;
-		}
+		if ((error = deextend(dep, nsize, NULL)) != 0)
+			return error;
+		if ((error = msdosfs_updatede(dep)) != 0)
+			return error;
 	}
 
-	if ((fd = open(path, O_RDONLY)) == -1)
-		err(1, "open %s", path);
+	if ((fd = open(path, O_RDONLY)) == -1) {
+		error = errno;
+		DPRINTF((1, "open %s: %s", path, strerror(error)));
+		return error;
+	}
 
 	if ((dat = mmap(0, nsize, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0))
 	== MAP_FAILED) {
-		DPRINTF(("%s: mmap %s %s", __func__, node->name,
-		strerror(errno)));
+		error = errno;
+		DPRINTF(("%s: mmap %s: %s", __func__, node->name,
+		strerror(error)));
 		close(fd);
 		goto out;
 	}
@@ -478,6 +476,7 @@ msdosfs_wfile(const char *path, struct d
 		cn = dep->de_StartCluster;
 		if (cn == MSDOSFSROOT) {
 			DPRINTF(("%s: bad lbn %lu", __func__, cn));
+			error = EINVAL;
 			goto out;
 		}
 		bn = cntobn(pmp, cn);



CVS commit: src/usr.sbin/makefs

2017-03-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Mar 15 15:33:54 UTC 2017

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
Change duplicate 'D' option to 'm'. From Ed Maste @ FreeBSD


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.54 src/usr.sbin/makefs/cd9660.c:1.55
--- src/usr.sbin/makefs/cd9660.c:1.54	Tue Jan 24 06:22:43 2017
+++ src/usr.sbin/makefs/cd9660.c	Wed Mar 15 11:33:54 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.54 2017/01/24 11:22:43 nonaka Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.55 2017/03/15 15:33:54 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.54 2017/01/24 11:22:43 nonaka Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.55 2017/03/15 15:33:54 christos Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -298,7 +298,7 @@ cd9660_prep_opts(fsinfo_t *fsopts)
 		"Allow 37 char filenames (unimplemented)"),
 	OPT_BOOL('i', "allow-illegal-chars", allow_illegal_chars,
 		"Allow illegal characters in filenames"),
-	OPT_BOOL('D', "allow-multidot", allow_multidot,
+	OPT_BOOL('m', "allow-multidot", allow_multidot,
 		"Allow multiple periods in filenames"),
 	OPT_BOOL('o', "omit-trailing-period", omit_trailing_period,
 		"Omit trailing periods in filenames"),



CVS commit: src/usr.sbin/makefs

2017-02-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 16 22:44:06 UTC 2017

Modified Files:
src/usr.sbin/makefs: msdos.c

Log Message:
allow 0 timestamp


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/makefs/msdos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.17 src/usr.sbin/makefs/msdos.c:1.18
--- src/usr.sbin/makefs/msdos.c:1.17	Thu Feb 16 13:50:04 2017
+++ src/usr.sbin/makefs/msdos.c	Thu Feb 16 17:44:06 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.17 2017/02/16 18:50:04 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.18 2017/02/16 22:44:06 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: msdos.c,v 1.17 2017/02/16 18:50:04 christos Exp $");
+__RCSID("$NetBSD: msdos.c,v 1.18 2017/02/16 22:44:06 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -134,7 +134,10 @@ msdos_parse_opts(const char *option, fsi
 	else if (strcmp(msdos_options[rv].name, "hidden_sectors") == 0)
 		msdos_opt->hidden_sectors_set = 1;
 
-	msdos_opt->timestamp = stampst.st_ino ? stampst.st_mtime : 0;
+	if (stampst.st_ino) {
+		msdos_opt->timestamp_set = 1;
+		msdos_opt->timestamp = stampst.st_mtime;
+	}
 
 	return 1;
 }



CVS commit: src/usr.sbin/makefs/ffs

2017-02-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 16 22:10:50 UTC 2017

Modified Files:
src/usr.sbin/makefs/ffs: buf.h

Log Message:
need 


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/makefs/ffs/buf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.h
diff -u src/usr.sbin/makefs/ffs/buf.h:1.11 src/usr.sbin/makefs/ffs/buf.h:1.12
--- src/usr.sbin/makefs/ffs/buf.h:1.11	Thu Feb 16 14:11:13 2017
+++ src/usr.sbin/makefs/ffs/buf.h	Thu Feb 16 17:10:50 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.11 2017/02/16 19:11:13 christos Exp $	*/
+/*	$NetBSD: buf.h,v 1.12 2017/02/16 22:10:50 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -40,6 +40,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 



CVS commit: src/usr.sbin/makefs/ffs

2017-02-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 16 19:11:13 UTC 2017

Modified Files:
src/usr.sbin/makefs/ffs: buf.h

Log Message:
fix msdos reproducible builds!


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makefs/ffs/buf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.h
diff -u src/usr.sbin/makefs/ffs/buf.h:1.10 src/usr.sbin/makefs/ffs/buf.h:1.11
--- src/usr.sbin/makefs/ffs/buf.h:1.10	Sun Mar 29 01:52:59 2015
+++ src/usr.sbin/makefs/ffs/buf.h	Thu Feb 16 14:11:13 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.10 2015/03/29 05:52:59 agc Exp $	*/
+/*	$NetBSD: buf.h,v 1.11 2017/02/16 19:11:13 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -87,7 +87,20 @@ struct buf *	getblk(struct vnode *, dadd
 #define	BC_AGE		0
 
 #define min(a, b) MIN((a), (b))
-#define microtime(tv) gettimeofday((tv), NULL)
+
+static inline void
+microtime(struct timeval *tv)
+{
+	extern struct stat stampst;
+
+	if (stampst.st_ino) {
+		tv->tv_sec = stampst.st_mtime;
+		tv->tv_usec = 0;
+	} else {
+	gettimeofday((tv), NULL);
+	}
+}
+
 #define KASSERT(a)
 #define IO_SYNC	1
 



CVS commit: src/usr.sbin/makefs

2017-02-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 16 18:50:05 UTC 2017

Modified Files:
src/usr.sbin/makefs: msdos.c
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
start fixing msdosfs for reproducible builds; does not work yet.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/makefs/msdos.c
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.16 src/usr.sbin/makefs/msdos.c:1.17
--- src/usr.sbin/makefs/msdos.c:1.16	Sat Jan 30 04:59:27 2016
+++ src/usr.sbin/makefs/msdos.c	Thu Feb 16 13:50:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.16 2016/01/30 09:59:27 mlelstv Exp $	*/
+/*	$NetBSD: msdos.c,v 1.17 2017/02/16 18:50:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: msdos.c,v 1.16 2016/01/30 09:59:27 mlelstv Exp $");
+__RCSID("$NetBSD: msdos.c,v 1.17 2017/02/16 18:50:04 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -133,6 +133,9 @@ msdos_parse_opts(const char *option, fsi
 		msdos_opt->media_descriptor_set = 1;
 	else if (strcmp(msdos_options[rv].name, "hidden_sectors") == 0)
 		msdos_opt->hidden_sectors_set = 1;
+
+	msdos_opt->timestamp = stampst.st_ino ? stampst.st_mtime : 0;
+
 	return 1;
 }
 

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.17 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.18
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.17	Sat Jan 30 04:59:27 2016
+++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c	Thu Feb 16 13:50:05 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.17 2016/01/30 09:59:27 mlelstv Exp $ */
+/*	$NetBSD: msdosfs_vnops.c,v 1.18 2017/02/16 18:50:05 christos Exp $ */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.17 2016/01/30 09:59:27 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.18 2017/02/16 18:50:05 christos Exp $");
 
 #include 
 #include 
@@ -98,12 +98,20 @@ static void
 msdosfs_times(struct msdosfsmount *pmp, struct denode *dep,
 const struct stat *st)
 {
+	struct timespec at;
+	struct timespec mt;
+
+	if (stampst.st_ino) 
+	st = 
+
 #ifndef HAVE_NBTOOL_CONFIG_H
-	struct timespec at = st->st_atimespec;
-	struct timespec mt = st->st_mtimespec;
+	at = st->st_atimespec;
+	mt = st->st_mtimespec;
 #else
-	struct timespec at = { st->st_atime, 0 };
-	struct timespec mt = { st->st_mtime, 0 };
+	at.tv_sec = st->st_atime;
+	at.tv_nsec = 0;
+	mt.tv_sec = st->st_mtime;
+	mt.tv_nsec = 0;
 #endif
 	unix2dostime(, pmp->pm_gmtoff, >de_ADate, NULL, NULL);
 	unix2dostime(, pmp->pm_gmtoff, >de_MDate, >de_MTime, NULL);



CVS commit: src/usr.sbin/makefs

2017-02-12 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Sun Feb 12 14:45:09 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
file system police.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.60 src/usr.sbin/makefs/makefs.8:1.61
--- src/usr.sbin/makefs/makefs.8:1.60	Sat Feb 11 16:04:59 2017
+++ src/usr.sbin/makefs/makefs.8	Sun Feb 12 14:45:09 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.60 2017/02/11 16:04:59 christos Exp $
+.\"	$NetBSD: makefs.8,v 1.61 2017/02/12 14:45:09 wiz Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -215,7 +215,7 @@ value interpreted as the number of secon
 Note that timestamps specified in an
 .Xr mtree 5
 spec file, override the default timestamp.
-When this option is enabled, filesystems that regularly use
+When this option is enabled, file systems that regularly use
 .Xr localtime 3
 to convert times to the native format (such as udf and cd9660), use
 .Xr gmtime 3



CVS commit: src/usr.sbin/makefs

2017-02-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 11 16:04:59 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
untorture language.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.59 src/usr.sbin/makefs/makefs.8:1.60
--- src/usr.sbin/makefs/makefs.8:1.59	Sat Feb 11 10:32:51 2017
+++ src/usr.sbin/makefs/makefs.8	Sat Feb 11 11:04:59 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.59 2017/02/11 15:32:51 christos Exp $
+.\"	$NetBSD: makefs.8,v 1.60 2017/02/11 16:04:59 christos Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -215,12 +215,12 @@ value interpreted as the number of secon
 Note that timestamps specified in an
 .Xr mtree 5
 spec file, override the default timestamp.
-Some filesystems (cd9660, udf) that are using
+When this option is enabled, filesystems that regularly use
 .Xr localtime 3
-to convert times to the native format, use
+to convert times to the native format (such as udf and cd9660), use
 .Xr gmtime 3
-with the specified timestamps so that they are immune to timezone changes
-and get consistent timestamps.
+instead with the specified timestamps so that they are immune to
+timezone changes and get consistent timestamps.
 .It Fl t Ar fs-type
 Create an
 .Ar fs-type



CVS commit: src/usr.sbin/makefs

2017-02-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb 11 15:32:51 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
mention timezone change for -T timestamp


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.58 src/usr.sbin/makefs/makefs.8:1.59
--- src/usr.sbin/makefs/makefs.8:1.58	Tue Jan 24 06:22:43 2017
+++ src/usr.sbin/makefs/makefs.8	Sat Feb 11 10:32:51 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.58 2017/01/24 11:22:43 nonaka Exp $
+.\"	$NetBSD: makefs.8,v 1.59 2017/02/11 15:32:51 christos Exp $
 .\"
 .\" Copyright (c) 2001-2003 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 11, 2017
+.Dd February 11, 2017
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -215,6 +215,12 @@ value interpreted as the number of secon
 Note that timestamps specified in an
 .Xr mtree 5
 spec file, override the default timestamp.
+Some filesystems (cd9660, udf) that are using
+.Xr localtime 3
+to convert times to the native format, use
+.Xr gmtime 3
+with the specified timestamps so that they are immune to timezone changes
+and get consistent timestamps.
 .It Fl t Ar fs-type
 Create an
 .Ar fs-type



CVS commit: src/usr.sbin/makefs/ffs

2017-02-08 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Feb  9 04:42:53 UTC 2017

Modified Files:
src/usr.sbin/makefs/ffs: ffs_extern.h mkfs.c

Log Message:
Revert the part of mkfs.c 1.36 that "gutted the const" (while
retaining the part that added a different one).

That is, re-constipate makefs (well, just a bit, no real pain here.)


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/ffs/ffs_extern.h
cvs rdiff -u -r1.36 -r1.37 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/ffs_extern.h
diff -u src/usr.sbin/makefs/ffs/ffs_extern.h:1.6 src/usr.sbin/makefs/ffs/ffs_extern.h:1.7
--- src/usr.sbin/makefs/ffs/ffs_extern.h:1.6	Thu Aug  7 11:25:33 2003
+++ src/usr.sbin/makefs/ffs/ffs_extern.h	Thu Feb  9 04:42:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_extern.h,v 1.6 2003/08/07 11:25:33 agc Exp $	*/
+/*	$NetBSD: ffs_extern.h,v 1.7 2017/02/09 04:42:53 kre Exp $	*/
 /* From: NetBSD: ffs_extern.h,v 1.19 2001/08/17 02:18:48 lukem Exp */
 
 /*-
@@ -59,7 +59,7 @@ void ffs_clusteracct(struct fs *, struct
 int ffs_balloc(struct inode *, off_t, int, struct buf **);
 
 	/* ffs_bswap.c */
-void ffs_sb_swap(struct fs*, struct fs *);
+void ffs_sb_swap(const struct fs*, struct fs *);
 void ffs_dinode1_swap(struct ufs1_dinode *, struct ufs1_dinode *);
 void ffs_dinode2_swap(struct ufs2_dinode *, struct ufs2_dinode *);
 void ffs_csum_swap(struct csum *, struct csum *, int);

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.36 src/usr.sbin/makefs/ffs/mkfs.c:1.37
--- src/usr.sbin/makefs/ffs/mkfs.c:1.36	Wed Feb  8 16:00:30 2017
+++ src/usr.sbin/makefs/ffs/mkfs.c	Thu Feb  9 04:42:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.36 2017/02/08 16:00:30 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.37 2017/02/09 04:42:53 kre Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.36 2017/02/08 16:00:30 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.37 2017/02/09 04:42:53 kre Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -126,7 +126,7 @@ static int avgfilesize;	   /* expect
 static int avgfpdir;	   /* expected number of files per directory */
 
 static void
-ffs_sb_copy(struct fs *o, struct fs *i, size_t l, const fsinfo_t *fsopts)
+ffs_sb_copy(struct fs *o, const struct fs *i, size_t l, const fsinfo_t *fsopts)
 {
 	memcpy(o, i, l);
 	/* Zero out pointers */



CVS commit: src/usr.sbin/makefs

2017-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 21:33:12 UTC 2017

Modified Files:
src/usr.sbin/makefs: udf.c
src/usr.sbin/makefs/cd9660: cd9660_conversion.c

Log Message:
If we are using a timestamp from the command line, don't pay attention to
the user timezone, use UTC instead (for reproducible builds).


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/makefs/udf.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/cd9660/cd9660_conversion.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.17 src/usr.sbin/makefs/udf.c:1.18
--- src/usr.sbin/makefs/udf.c:1.17	Tue Jun 16 19:04:14 2015
+++ src/usr.sbin/makefs/udf.c	Wed Feb  8 16:33:12 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.17 2015/06/16 23:04:14 christos Exp $ */
+/* $NetBSD: udf.c,v 1.18 2017/02/08 21:33:12 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: udf.c,v 1.17 2015/06/16 23:04:14 christos Exp $");
+__RCSID("$NetBSD: udf.c,v 1.18 2017/02/08 21:33:12 christos Exp $");
 
 #include 
 #include 
@@ -290,9 +290,6 @@ udf_update_trackinfo(struct mmc_discinfo
 void
 udf_prep_opts(fsinfo_t *fsopts)
 {
-	struct tm *tm;
-	time_t now;
-
 	const option_t udf_options[] = {
 		OPT_STR('T', "disctype", "disc type (cdrom,dvdrom,bdrom,"
 			"dvdram,bdre,disk,cdr,dvdr,bdr,cdrw,dvdrw)"),
@@ -330,13 +327,16 @@ udf_prep_opts(fsinfo_t *fsopts)
 	context.max_udf = 0x201;	/* 0x250 and 0x260 are not ready */
 
 	/* use user's time zone as default */
-	(void)time();
-	tm = localtime();
 #ifdef HAVE_STRUCT_TM_TM_GMTOFF
-	context.gmtoff = tm->tm_gmtoff;
-#else
-	context.gmtoff = 0;
+	if (!stampst.st_ino)  {
+		struct tm tm;
+		time_t now;
+		(void)time();
+		(void)localtime_r(, );
+		context.gmtoff = tm.tm_gmtoff;
+	} else
 #endif
+		context.gmtoff = 0;
 
 	/* return info */
 	fsopts->fs_specific = NULL;

Index: src/usr.sbin/makefs/cd9660/cd9660_conversion.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_conversion.c:1.4 src/usr.sbin/makefs/cd9660/cd9660_conversion.c:1.5
--- src/usr.sbin/makefs/cd9660/cd9660_conversion.c:1.4	Wed Mar 14 10:11:17 2007
+++ src/usr.sbin/makefs/cd9660/cd9660_conversion.c	Wed Feb  8 16:33:12 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_conversion.c,v 1.4 2007/03/14 14:11:17 christos Exp $	*/
+/*	$NetBSD: cd9660_conversion.c,v 1.5 2017/02/08 21:33:12 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_conversion.c,v 1.4 2007/03/14 14:11:17 christos Exp $");
+__RCSID("$NetBSD: cd9660_conversion.c,v 1.5 2017/02/08 21:33:12 christos Exp $");
 #endif  /* !__lint */
 
 
@@ -150,6 +150,9 @@ cd9660_pad_string_spaces(char *str, int 
 static char
 cd9660_compute_gm_offset(time_t tim)
 {
+	if (stampst.st_ino)
+		return 0;
+
 	struct tm t, gm;
 
 	(void)localtime_r(, );
@@ -173,7 +176,10 @@ cd9660_time_8426(unsigned char *buf, tim
 	struct tm t;
 	char temp[18];
 
-	(void)localtime_r(, );
+	if (stampst.st_ino)
+		(void)gmtime_r(, );
+	else
+		(void)localtime_r(, );
 	(void)snprintf(temp, sizeof(temp), "%04i%02i%02i%02i%02i%02i%02i",
 		1900+(int)t.tm_year,
 		(int)t.tm_mon+1,
@@ -192,7 +198,10 @@ cd9660_time_915(unsigned char *buf, time
 {
 	struct tm t;
 
-	(void)localtime_r(, );
+	if (stampst.st_ino)
+		(void)gmtime_r(, );
+	else
+		(void)localtime_r(, );
 	buf[0] = t.tm_year;
 	buf[1] = t.tm_mon+1;
 	buf[2] = t.tm_mday;



CVS commit: src/usr.sbin/makefs

2017-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 21:27:26 UTC 2017

Modified Files:
src/usr.sbin/makefs: ffs.c

Log Message:
stampst.st_ion consistent treatment (non-zero vs zero instead of testing == 1)


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/usr.sbin/makefs/ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.68 src/usr.sbin/makefs/ffs.c:1.69
--- src/usr.sbin/makefs/ffs.c:1.68	Tue Feb  7 21:23:45 2017
+++ src/usr.sbin/makefs/ffs.c	Wed Feb  8 16:27:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.68 2017/02/08 02:23:45 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.69 2017/02/08 21:27:26 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.68 2017/02/08 02:23:45 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.69 2017/02/08 21:27:26 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -532,7 +532,7 @@ ffs_create_image(const char *image, fsin
 	if (debug & DEBUG_FS_CREATE_IMAGE)
 		printf("calling mkfs(\"%s\", ...)\n", image);
 
-	if (stampst.st_ino == 1)
+	if (stampst.st_ino)
 		tstamp = stampst.st_ctime;
 	else
 		tstamp = start_time.tv_sec;
@@ -646,7 +646,7 @@ ffs_build_dinode1(struct ufs1_dinode *di
 {
 	size_t slen;
 	void *membuf;
-	struct stat *st = stampst.st_ino == 1 ?  : >inode->st;
+	struct stat *st = stampst.st_ino ?  : >inode->st;
 
 	memset(dinp, 0, sizeof(*dinp));
 	dinp->di_mode = cur->inode->st.st_mode;
@@ -696,7 +696,7 @@ ffs_build_dinode2(struct ufs2_dinode *di
 {
 	size_t slen;
 	void *membuf;
-	struct stat *st = stampst.st_ino == 1 ?  : >inode->st;
+	struct stat *st = stampst.st_ino ?  : >inode->st;
 
 	memset(dinp, 0, sizeof(*dinp));
 	dinp->di_mode = cur->inode->st.st_mode;



CVS commit: src/usr.sbin/makefs/ffs

2017-02-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 16:00:30 UTC 2017

Modified Files:
src/usr.sbin/makefs/ffs: mkfs.c

Log Message:
gut const for now.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.35 src/usr.sbin/makefs/ffs/mkfs.c:1.36
--- src/usr.sbin/makefs/ffs/mkfs.c:1.35	Tue Feb  7 23:08:53 2017
+++ src/usr.sbin/makefs/ffs/mkfs.c	Wed Feb  8 11:00:30 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.35 2017/02/08 04:08:53 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.36 2017/02/08 16:00:30 christos Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.35 2017/02/08 04:08:53 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.36 2017/02/08 16:00:30 christos Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -126,7 +126,7 @@ static int avgfilesize;	   /* expect
 static int avgfpdir;	   /* expected number of files per directory */
 
 static void
-ffs_sb_copy(struct fs *o, const struct fs *i, size_t l, fsinfo_t *fsopts)
+ffs_sb_copy(struct fs *o, struct fs *i, size_t l, const fsinfo_t *fsopts)
 {
 	memcpy(o, i, l);
 	/* Zero out pointers */



CVS commit: src/usr.sbin/makefs/ffs

2017-02-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 04:08:53 UTC 2017

Modified Files:
src/usr.sbin/makefs/ffs: mkfs.c

Log Message:
Don't store random (from ASLR) pointers into the superblock. Should be the
last (famous last words) problem with reproducible builds!


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.34 src/usr.sbin/makefs/ffs/mkfs.c:1.35
--- src/usr.sbin/makefs/ffs/mkfs.c:1.34	Fri Jun 24 15:24:11 2016
+++ src/usr.sbin/makefs/ffs/mkfs.c	Tue Feb  7 23:08:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.34 2016/06/24 19:24:11 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.35 2017/02/08 04:08:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.34 2016/06/24 19:24:11 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.35 2017/02/08 04:08:53 christos Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -102,7 +102,11 @@ union {
 char *iobuf;
 int iobufsize;
 
-char writebuf[FFS_MAXBSIZE];
+union {
+	struct fs fs;
+	char pad[FFS_MAXBSIZE];
+} wb;
+#define writebuf wb.pad
 
 static int Oflag;	   /* format as an 4.3BSD file system */
 static int64_t fssize;	   /* file system size */
@@ -121,6 +125,17 @@ static int sbsize;	   /* superblock 
 static int avgfilesize;	   /* expected average file size */
 static int avgfpdir;	   /* expected number of files per directory */
 
+static void
+ffs_sb_copy(struct fs *o, const struct fs *i, size_t l, fsinfo_t *fsopts)
+{
+	memcpy(o, i, l);
+	/* Zero out pointers */
+	o->fs_csp = NULL;
+	o->fs_maxcluster = NULL;
+	if (fsopts->needswap)
+		ffs_sb_swap(i, o);
+}
+
 struct fs *
 ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 {
@@ -508,9 +523,7 @@ ffs_mkfs(const char *fsys, const fsinfo_
 	 * Make a copy of the superblock into the buffer that we will be
 	 * writing out in each cylinder group.
 	 */
-	memcpy(writebuf, , sbsize);
-	if (fsopts->needswap)
-		ffs_sb_swap(, (struct fs*)writebuf);
+	ffs_sb_copy(, , sbsize, fsopts);
 	memcpy(iobuf, writebuf, SBLOCKSIZE);
 
 	printf("super-block backups (for fsck -b #) at:");
@@ -555,9 +568,7 @@ ffs_write_superblock(struct fs *fs, cons
 	saveflag = fs->fs_flags & FS_INTERNAL;
 	fs->fs_flags &= ~FS_INTERNAL;
 
-memcpy(writebuf, , sbsize);
-	if (fsopts->needswap)
-		ffs_sb_swap(fs, (struct fs*)writebuf);
+	ffs_sb_copy(, , sbsize, fsopts);
 	ffs_wtfs(fs->fs_sblockloc / sectorsize, sbsize, writebuf, fsopts);
 
 	/* Write out the duplicate super blocks */



CVS commit: src/usr.sbin/makefs

2017-02-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 02:23:45 UTC 2017

Modified Files:
src/usr.sbin/makefs: ffs.c

Log Message:
no, this is wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/usr.sbin/makefs/ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.67 src/usr.sbin/makefs/ffs.c:1.68
--- src/usr.sbin/makefs/ffs.c:1.67	Tue Feb  7 21:20:35 2017
+++ src/usr.sbin/makefs/ffs.c	Tue Feb  7 21:23:45 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.67 2017/02/08 02:20:35 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.68 2017/02/08 02:23:45 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.67 2017/02/08 02:20:35 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.68 2017/02/08 02:23:45 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -294,7 +294,6 @@ ffs_makefs(const char *image, const char
 
 		/* update various superblock parameters */
 	superblock = fsopts->superblock;
-	memset(superblock, 0, sizeof(*superblock));
 	superblock->fs_fmod = 0;
 	superblock->fs_old_cstotal.cs_ndir   = superblock->fs_cstotal.cs_ndir;
 	superblock->fs_old_cstotal.cs_nbfree = superblock->fs_cstotal.cs_nbfree;



CVS commit: src/usr.sbin/makefs

2017-02-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb  8 02:20:35 UTC 2017

Modified Files:
src/usr.sbin/makefs: ffs.c

Log Message:
zero out the superblock so that it does not contain random stuff in the
spare fields.


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 src/usr.sbin/makefs/ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.66 src/usr.sbin/makefs/ffs.c:1.67
--- src/usr.sbin/makefs/ffs.c:1.66	Sun Dec 20 19:58:08 2015
+++ src/usr.sbin/makefs/ffs.c	Tue Feb  7 21:20:35 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.67 2017/02/08 02:20:35 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.67 2017/02/08 02:20:35 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -294,6 +294,7 @@ ffs_makefs(const char *image, const char
 
 		/* update various superblock parameters */
 	superblock = fsopts->superblock;
+	memset(superblock, 0, sizeof(*superblock));
 	superblock->fs_fmod = 0;
 	superblock->fs_old_cstotal.cs_ndir   = superblock->fs_cstotal.cs_ndir;
 	superblock->fs_old_cstotal.cs_nbfree = superblock->fs_cstotal.cs_nbfree;



CVS commit: src/usr.sbin/makefs

2017-01-24 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Jan 24 11:22:43 UTC 2017

Modified Files:
src/usr.sbin/makefs: cd9660.c makefs.8
src/usr.sbin/makefs/cd9660: cd9660_eltorito.c cd9660_eltorito.h

Log Message:
makefs(8): add cd9660 eltorito-alt-boot option for EFI boot.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makefs/cd9660/cd9660_eltorito.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.53 src/usr.sbin/makefs/cd9660.c:1.54
--- src/usr.sbin/makefs/cd9660.c:1.53	Fri Nov 25 23:02:44 2016
+++ src/usr.sbin/makefs/cd9660.c	Tue Jan 24 11:22:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.54 2017/01/24 11:22:43 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.54 2017/01/24 11:22:43 nonaka Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -321,6 +321,7 @@ cd9660_prep_opts(fsinfo_t *fsopts)
 		OPT_STR('\0', "no-boot", "No boot support"),
 		OPT_STR('\0', "hard-disk-boot", "Boot from hard disk"),
 		OPT_STR('\0', "boot-load-segment", "Boot load segment"),
+		OPT_STR('\0', "platformid", "Section Header Platform ID"),
 
 		{ .name = NULL }
 	};
@@ -458,7 +459,8 @@ cd9660_parse_opts(const char *option, fs
 			/* RRIP */
 			cd9660_eltorito_add_boot_option(diskStructure, name, 0);
 			rv = 1;
-		} else if (strcmp(name, "boot-load-segment") == 0) {
+		} else if (strcmp(name, "boot-load-segment") == 0 ||
+		strcmp(name, "platformid") == 0) {
 			if (buf[0] == '\0') {
 warnx("Option `%s' doesn't contain a value",
 name);

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.57 src/usr.sbin/makefs/makefs.8:1.58
--- src/usr.sbin/makefs/makefs.8:1.57	Wed Jan 11 13:47:27 2017
+++ src/usr.sbin/makefs/makefs.8	Tue Jan 24 11:22:43 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.57 2017/01/11 13:47:27 wiz Exp $
+.\"	$NetBSD: makefs.8,v 1.58 2017/01/24 11:22:43 nonaka Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -366,6 +366,8 @@ ElTorito image.
 Do not pad the image (apparently Linux needs the padding).
 .\" .It Sy omit-trailing-period
 .\" Unknown
+.It Sy platformid
+Set platform ID of section header entry of the boot image.
 .It Sy preparer
 Preparer ID of the image.
 .It Sy publisher

Index: src/usr.sbin/makefs/cd9660/cd9660_eltorito.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.20 src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.21
--- src/usr.sbin/makefs/cd9660/cd9660_eltorito.c:1.20	Mon Jan 28 21:03:28 2013
+++ src/usr.sbin/makefs/cd9660/cd9660_eltorito.c	Tue Jan 24 11:22:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_eltorito.c,v 1.20 2013/01/28 21:03:28 christos Exp $	*/
+/*	$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -40,7 +40,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_eltorito.c,v 1.20 2013/01/28 21:03:28 christos Exp $");
+__RCSID("$NetBSD: cd9660_eltorito.c,v 1.21 2017/01/24 11:22:43 nonaka Exp $");
 #endif  /* !__lint */
 
 #ifdef DEBUG
@@ -56,11 +56,12 @@ static struct boot_catalog_entry *cd9660
 static struct boot_catalog_entry *cd9660_boot_setup_default_entry(
 struct cd9660_boot_image *);
 static struct boot_catalog_entry *cd9660_boot_setup_section_head(char);
-static struct boot_catalog_entry *cd9660_boot_setup_validation_entry(char);
 #if 0
 static u_char cd9660_boot_get_system_type(struct cd9660_boot_image *);
 #endif
 
+static struct cd9660_boot_image *default_boot_image;
+
 int
 cd9660_add_boot_disk(iso9660_disk *diskStructure, const char *boot_info)
 {
@@ -175,9 +176,15 @@ cd9660_add_boot_disk(iso9660_disk *diskS
 
 	new_image->serialno = diskStructure->image_serialno++;
 
+	new_image->platform_id = new_image->system;
+
 	/* TODO : Need to do anything about the boot image in the tree? */
 	diskStructure->is_bootable = 1;
 
+	/* First boot image is initial/default entry. */
+	if (default_boot_image == NULL)
+		default_boot_image = new_image;
+
 	return 1;
 }
 
@@ -211,6 +218,13 @@ cd9660_eltorito_add_boot_option(iso9660_
 			warn("%s: strtoul", __func__);
 			return 0;
 		}
+	} else if (strcmp(option_string, "platformid") == 0) {
+		if (strcmp(value, "efi") == 0)
+			image->platform_id = ET_SYS_EFI;
+		else {
+			warn("%s: unknown platform: %s", __func__, value);
+			return 0;
+		}
 	} else {

CVS commit: src/usr.sbin/makefs

2017-01-11 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan 11 13:47:27 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Document msdos-specific options directly.

>From jmc@OpenBSD.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.56 src/usr.sbin/makefs/makefs.8:1.57
--- src/usr.sbin/makefs/makefs.8:1.56	Wed Jan 11 13:44:24 2017
+++ src/usr.sbin/makefs/makefs.8	Wed Jan 11 13:47:27 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.56 2017/01/11 13:44:24 wiz Exp $
+.\"	$NetBSD: makefs.8,v 1.57 2017/01/11 13:47:27 wiz Exp $
 .\"
 .\" Copyright (c) 2001-2003 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 November 23, 2015
+.Dd January 11, 2017
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -393,9 +393,63 @@ Type of the media.
 NOR: 0 or NAND: 1.
 .El
 .Ss msdos-specific options
-See
+.Sy msdos
+images have MS-DOS-specific optional parameters that may be
+provided.
+The arguments consist of a keyword, an equal sign
+.Pq Ql = ,
+and a value.
+The following keywords are supported (see
 .Xr newfs_msdos 8
-for related options.
+for more details):
+.Pp
+.Bl -tag -width omit-trailing-period -offset indent -compact
+.It Cm backup_sector
+Location of the backup boot sector.
+.It Cm block_size
+Block size.
+.It Cm bootstrap
+Bootstrap file.
+.It Cm bytes_per_sector
+Bytes per sector.
+.It Cm create_size
+Create file size.
+.It Cm directory_entries
+Directory entries.
+.It Cm drive_heads
+Drive heads.
+.It Cm fat_type
+FAT type (12, 16, or 32).
+.It Cm floppy
+Preset drive parameters for standard format floppy disks
+(160, 180, 320, 360, 640, 720, 1200, 1232, 1440, or 2880).
+.It Cm hidden_sectors
+Hidden sectors.
+.It Cm info_sector
+Location of the info sector.
+.It Cm media_descriptor
+Media descriptor.
+.It Cm num_FAT
+Number of FATs.
+.It Cm OEM_string
+OEM string.
+.It Cm offset
+Offset in device.
+.It Cm reserved_sectors
+Reserved sectors.
+.It Cm sectors_per_cluster
+Sectors per cluster.
+.It Cm sectors_per_fat
+Sectors per FAT.
+.It Cm sectors_per_track
+Sectors per track.
+.It Cm size
+File System size.
+.It Cm volume_id
+Volume ID.
+.It Cm volume_label
+Volume Label.
+.El
 .Ss V7FS-specific options
 The following keywords are supported:
 .Pp



CVS commit: src/usr.sbin/makefs

2017-01-11 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jan 11 13:44:24 UTC 2017

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Some changes and sorting based on diff sent from jmc@OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.55 src/usr.sbin/makefs/makefs.8:1.56
--- src/usr.sbin/makefs/makefs.8:1.55	Wed Nov 25 16:32:00 2015
+++ src/usr.sbin/makefs/makefs.8	Wed Jan 11 13:44:24 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.55 2015/11/25 16:32:00 wiz Exp $
+.\"	$NetBSD: makefs.8,v 1.56 2017/01/11 13:44:24 wiz Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -221,18 +221,18 @@ Create an
 file system image.
 The following file system types are supported:
 .Bl -tag -width cd9660 -offset indent
-.It Sy ffs
-BSD fast file system (default).
 .It Sy cd9660
 ISO 9660 file system.
 .It Sy chfs
 Chip flash file system.
+.It Sy ffs
+BSD fast file system (default).
 .It Sy msdos
 FAT12, FAT16, or FAT32 file system.
-.It Sy v7fs
-7th Edition(V7) file system.
 .It Sy udf
 ISO/Ecma UDF file system.
+.It Sy v7fs
+7th Edition(V7) file system.
 .El
 .It Fl x
 Exclude file system nodes not explicitly listed in the specfile.
@@ -244,7 +244,7 @@ This is useful for virtual machine image
 .Pp
 Where sizes are specified, a decimal number of bytes is expected.
 Two or more numbers may be separated by an
-.Dq x
+.Sq x
 to indicate a product.
 Each number may have one of the following optional suffixes:
 .Bl -tag -width 3n -offset indent -compact
@@ -280,10 +280,14 @@ Expected number of files per directory.
 Block size.
 .It Sy density
 Bytes per inode.
+.It Sy extent
+Maximum extent size.
 .It Sy fsize
 Fragment size.
 .It Sy label
 Label name of the image.
+.It Sy maxbpcg
+Maximum total number of blocks in a cylinder group.
 .It Sy maxbpg
 Maximum blocks per file in a cylinder group.
 .It Sy minfree
@@ -293,10 +297,6 @@ Optimization preference; one of
 .Ql space
 or
 .Ql time .
-.It Sy extent
-Maximum extent size.
-.It Sy maxbpcg
-Maximum total number of blocks in a cylinder group.
 .It Sy version
 UFS version.
 1 for FFS (default), 2 for UFS2.
@@ -320,7 +320,7 @@ the spec.
 .\" Unknown
 .It Sy allow-max-name
 Allow 37 instead of 33 characters for filenames by omitting the
-version id.
+version ID.
 .It Sy allow-multidot
 Allow multiple dots in a filename.
 .It Sy applicationid
@@ -331,9 +331,6 @@ Use the
 extension to encode
 .Tn RISC OS
 metadata.
-.It Sy chrp-boot
-Write an MBR partition table to the image to allow older CHRP hardware to
-boot.
 .It Sy boot-load-segment
 Set load segment for the boot image.
 .It Sy bootimage
@@ -347,6 +344,9 @@ is one of
 .Ql macppc ,
 or
 .Ql powerpc .
+.It Sy chrp-boot
+Write an MBR partition table to the image to allow older CHRP hardware to
+boot.
 .It Sy generic-bootimage
 Load a generic boot image into the first 32K of the cd9660 image.
 .It Sy hard-disk-boot
@@ -395,7 +395,7 @@ NOR: 0 or NAND: 1.
 .Ss msdos-specific options
 See
 .Xr newfs_msdos 8
-for fs specific options.
+for related options.
 .Ss V7FS-specific options
 The following keywords are supported:
 .Pp
@@ -469,8 +469,8 @@ utility appeared in
 .An UCHIYAMA Yasushi
 (v7fs support),
 .An Tamas Toth
-(chfs support).
+(chfs support),
 .An Christos Zoulas
-(msdos support).
+(msdos support),
 .An Reinoud Zandijk
 (udf support).



CVS commit: src/usr.sbin/makefs/chfs

2017-01-09 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jan 10 04:27:02 UTC 2017

Modified Files:
src/usr.sbin/makefs/chfs: chfs_mkfs.c

Log Message:
Include missing header  for write(2) read(2) close(2)

These functions are undefined after switch to new zlib.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/chfs/chfs_mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/chfs/chfs_mkfs.c
diff -u src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.7 src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.8
--- src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.7	Mon Mar  7 15:58:05 2016
+++ src/usr.sbin/makefs/chfs/chfs_mkfs.c	Tue Jan 10 04:27:02 2017
@@ -43,6 +43,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "makefs.h"
 #include "chfs_makefs.h"



CVS commit: src/usr.sbin/makefs

2016-11-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 25 23:02:45 UTC 2016

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
PR/51652: Sevan Janiyan: makefs dies due to segmentation fault
Don't dereference NULL when running out of nodes during rename.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.52 src/usr.sbin/makefs/cd9660.c:1.53
--- src/usr.sbin/makefs/cd9660.c:1.52	Thu Dec 24 10:52:37 2015
+++ src/usr.sbin/makefs/cd9660.c	Fri Nov 25 18:02:44 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.52 2015/12/24 15:52:37 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.52 2015/12/24 15:52:37 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.53 2016/11/25 23:02:44 christos Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -1079,7 +1079,7 @@ cd9660_rename_filename(iso9660_disk *dis
 
 	tmp = emalloc(ISO_FILENAME_MAXLENGTH_WITH_PADDING);
 
-	while (i < num) {
+	while (i < num && iter) {
 		powers = 1;
 		count = 0;
 		digits = 1;



CVS commit: src/usr.sbin/makefs/ffs

2016-06-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jun 24 19:24:11 UTC 2016

Modified Files:
src/usr.sbin/makefs/ffs: buf.c ffs_alloc.c mkfs.c

Log Message:
tidy up error messages


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/usr.sbin/makefs/ffs/buf.c
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.23 src/usr.sbin/makefs/ffs/buf.c:1.24
--- src/usr.sbin/makefs/ffs/buf.c:1.23	Thu Dec 24 10:52:37 2015
+++ src/usr.sbin/makefs/ffs/buf.c	Fri Jun 24 15:24:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.23 2015/12/24 15:52:37 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.24 2016/06/24 19:24:11 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: buf.c,v 1.23 2015/12/24 15:52:37 christos Exp $");
+__RCSID("$NetBSD: buf.c,v 1.24 2016/06/24 19:24:11 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -78,17 +78,17 @@ bread(struct vnode *vp, daddr_t blkno, i
 		(long long)(*bpp)->b_blkno, (long long) offset,
 		(*bpp)->b_bcount);
 	if (lseek((*bpp)->b_fs->fd, offset, SEEK_SET) == -1)
-		err(1, "%s: lseek %lld (%lld)", __func__,
+		err(EXIT_FAILURE, "%s: lseek %lld (%lld)", __func__,
 		(long long)(*bpp)->b_blkno, (long long)offset);
 	rv = read((*bpp)->b_fs->fd, (*bpp)->b_data, (size_t)(*bpp)->b_bcount);
 	if (debug & DEBUG_BUF_BREAD)
 		printf("bread: read %ld (%lld) returned %zd\n",
 		(*bpp)->b_bcount, (long long)offset, rv);
 	if (rv == -1)/* read error */
-		err(1, "%s: read %ld (%lld) returned %zd", __func__,
+		err(EXIT_FAILURE, "%s: read %ld (%lld) returned %zd", __func__,
 		(*bpp)->b_bcount, (long long)offset, rv);
 	else if (rv != (*bpp)->b_bcount)	/* short read */
-		err(1, "%s: read %ld (%lld) returned %zd", __func__,
+		errx(EXIT_FAILURE, "%s: read %ld (%lld) returned %zd", __func__,
 		(*bpp)->b_bcount, (long long)offset, rv);
 	else
 		return (0);

Index: src/usr.sbin/makefs/ffs/ffs_alloc.c
diff -u src/usr.sbin/makefs/ffs/ffs_alloc.c:1.28 src/usr.sbin/makefs/ffs/ffs_alloc.c:1.29
--- src/usr.sbin/makefs/ffs/ffs_alloc.c:1.28	Sun Mar 29 01:52:59 2015
+++ src/usr.sbin/makefs/ffs/ffs_alloc.c	Fri Jun 24 15:24:11 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.28 2015/03/29 05:52:59 agc Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.29 2016/06/24 19:24:11 christos Exp $	*/
 /* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
 
 /*
@@ -47,7 +47,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs_alloc.c,v 1.28 2015/03/29 05:52:59 agc Exp $");
+__RCSID("$NetBSD: ffs_alloc.c,v 1.29 2016/06/24 19:24:11 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -107,7 +107,7 @@ ffs_alloc(struct inode *ip, daddr_t lbn 
 	
 	*bnp = 0;
 	if (size > fs->fs_bsize || ffs_fragoff(fs, size) != 0) {
-		errx(1, "ffs_alloc: bad size: bsize %d size %d",
+		errx(EXIT_FAILURE, "%s: bad size: bsize %d size %d", __func__,
 		fs->fs_bsize, size);
 	}
 	if (size == fs->fs_bsize && fs->fs_cstotal.cs_nbfree == 0)
@@ -441,8 +441,8 @@ ffs_blkfree(struct inode *ip, daddr_t bn
 
 	if (size > fs->fs_bsize || ffs_fragoff(fs, size) != 0 ||
 	ffs_fragnum(fs, bno) + ffs_numfrags(fs, size) > fs->fs_frag) {
-		errx(1, "blkfree: bad size: bno %lld bsize %d size %ld",
-		(long long)bno, fs->fs_bsize, size);
+		errx(EXIT_FAILURE, "%s: bad size: bno %lld bsize %d "
+		"size %ld", __func__, (long long)bno, fs->fs_bsize, size);
 	}
 	cg = dtog(fs, bno);
 	if (bno >= fs->fs_size) {
@@ -465,8 +465,8 @@ ffs_blkfree(struct inode *ip, daddr_t bn
 	if (size == fs->fs_bsize) {
 		fragno = ffs_fragstoblks(fs, cgbno);
 		if (!ffs_isfreeblock(fs, cg_blksfree(cgp, needswap), fragno)) {
-			errx(1, "blkfree: freeing free block %lld",
-			(long long)bno);
+			errx(EXIT_FAILURE, "%s: freeing free block %lld",
+			__func__, (long long)bno);
 		}
 		ffs_setblock(fs, cg_blksfree(cgp, needswap), fragno);
 		ffs_clusteracct(fs, cgp, fragno, 1);
@@ -486,7 +486,8 @@ ffs_blkfree(struct inode *ip, daddr_t bn
 		frags = ffs_numfrags(fs, size);
 		for (i = 0; i < frags; i++) {
 			if (isset(cg_blksfree(cgp, needswap), cgbno + i)) {
-errx(1, "blkfree: freeing free frag: block %lld",
+errx(EXIT_FAILURE, "%s: freeing free frag: "
+"block %lld", __func__,
 (long long)(cgbno + i));
 			}
 			setbit(cg_blksfree(cgp, needswap), cgbno + i);
@@ -566,11 +567,10 @@ ffs_mapsearch(struct fs *fs, struct cg *
 			(const u_char *)fragtbl[fs->fs_frag],
 			(1 << (allocsiz - 1 + (fs->fs_frag % NBBY;
 		if (loc == 0) {
-			errx(1,
-"ffs_alloccg: map corrupted: start %d len %d offset %d %ld",
-ostart, olen,
-ufs_rw32(cgp->cg_freeoff, needswap),

CVS commit: src/usr.sbin/makefs/chfs

2016-03-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Mar  7 15:58:05 UTC 2016

Modified Files:
src/usr.sbin/makefs/chfs: chfs_mkfs.c

Log Message:
PR/50911: David Binderman: Optimize memset


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/chfs/chfs_mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/chfs/chfs_mkfs.c
diff -u src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.6 src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.7
--- src/usr.sbin/makefs/chfs/chfs_mkfs.c:1.6	Mon Jan 28 16:03:28 2013
+++ src/usr.sbin/makefs/chfs/chfs_mkfs.c	Mon Mar  7 10:58:05 2016
@@ -124,7 +124,6 @@ write_eb_header(fsinfo_t *fsopts)
 	if ((uint32_t)opts->pagesize < MINSIZE)
 		errx(EXIT_FAILURE, "pagesize cannot be less than %zu", MINSIZE);
 	buf = emalloc(opts->pagesize);
-	memset(buf, 0xFF, opts->pagesize);
 
 	ebhdr.ec_hdr.magic = htole32(CHFS_MAGIC_BITMASK);
 	ebhdr.ec_hdr.erase_cnt = htole32(1);
@@ -132,6 +131,8 @@ write_eb_header(fsinfo_t *fsopts)
 	(uint8_t *)_hdr + 8, 4));
 
 	memcpy(buf, _hdr, CHFS_EB_EC_HDR_SIZE);
+	memset(buf + CHFS_EB_EC_HDR_SIZE, 0xFF,
+	opts->pagesize - CHFS_EB_EC_HDR_SIZE);
 
 	buf_write(fsopts, buf, opts->pagesize);
 



CVS commit: src/usr.sbin/makefs

2015-12-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 24 15:52:37 UTC 2015

Modified Files:
src/usr.sbin/makefs: cd9660.c cd9660.h
src/usr.sbin/makefs/cd9660: cd9660_strings.c
src/usr.sbin/makefs/ffs: buf.c

Log Message:
little size_t/ssize_t...


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makefs/cd9660.h
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makefs/cd9660/cd9660_strings.c
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/ffs/buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.51 src/usr.sbin/makefs/cd9660.c:1.52
--- src/usr.sbin/makefs/cd9660.c:1.51	Sun Dec 20 22:19:17 2015
+++ src/usr.sbin/makefs/cd9660.c	Thu Dec 24 10:52:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.51 2015/12/21 03:19:17 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.52 2015/12/24 15:52:37 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.51 2015/12/21 03:19:17 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.52 2015/12/24 15:52:37 christos Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -124,7 +124,7 @@ __RCSID("$NetBSD: cd9660.c,v 1.51 2015/1
 static void cd9660_finalize_PVD(iso9660_disk *);
 static cd9660node *cd9660_allocate_cd9660node(void);
 static void cd9660_set_defaults(iso9660_disk *);
-static int cd9660_arguments_set_string(const char *, const char *, int,
+static int cd9660_arguments_set_string(const char *, const char *, size_t,
 char, char *);
 static void cd9660_populate_iso_dir_record(
 struct _iso_directory_record_cd9660 *, u_char, u_char, u_char,
@@ -339,10 +339,11 @@ cd9660_cleanup_opts(fsinfo_t *fsopts)
 }
 
 static int
-cd9660_arguments_set_string(const char *val, const char *fieldtitle, int length,
-			char testmode, char * dest)
+cd9660_arguments_set_string(const char *val, const char *fieldtitle,
+size_t length, char testmode, char * dest)
 {
-	int len, test;
+	size_t len;
+	int test;
 
 	if (val == NULL)
 		warnx("error: The %s requires a string argument", fieldtitle);

Index: src/usr.sbin/makefs/cd9660.h
diff -u src/usr.sbin/makefs/cd9660.h:1.20 src/usr.sbin/makefs/cd9660.h:1.21
--- src/usr.sbin/makefs/cd9660.h:1.20	Tue Jan 29 10:52:25 2013
+++ src/usr.sbin/makefs/cd9660.h	Thu Dec 24 10:52:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.h,v 1.20 2013/01/29 15:52:25 christos Exp $	*/
+/*	$NetBSD: cd9660.h,v 1.21 2015/12/24 15:52:37 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -308,7 +308,7 @@ typedef struct _iso9660_disk {
 / FUNCTIONS **/
 int			cd9660_valid_a_chars(const char *);
 int			cd9660_valid_d_chars(const char *);
-void			cd9660_uppercase_characters(char *, int);
+void			cd9660_uppercase_characters(char *, size_t);
 
 /* ISO Data Types */
 void			cd9660_721(uint16_t, unsigned char *);

Index: src/usr.sbin/makefs/cd9660/cd9660_strings.c
diff -u src/usr.sbin/makefs/cd9660/cd9660_strings.c:1.5 src/usr.sbin/makefs/cd9660/cd9660_strings.c:1.6
--- src/usr.sbin/makefs/cd9660/cd9660_strings.c:1.5	Wed Mar 23 09:11:51 2011
+++ src/usr.sbin/makefs/cd9660/cd9660_strings.c	Thu Dec 24 10:52:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660_strings.c,v 1.5 2011/03/23 13:11:51 christos Exp $	*/
+/*	$NetBSD: cd9660_strings.c,v 1.6 2015/12/24 15:52:37 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -46,14 +46,14 @@
 #include "cd9660.h"
 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660_strings.c,v 1.5 2011/03/23 13:11:51 christos Exp $");
+__RCSID("$NetBSD: cd9660_strings.c,v 1.6 2015/12/24 15:52:37 christos Exp $");
 #endif  /* !__lint */
 
 
 void
-cd9660_uppercase_characters(char *str, int len)
+cd9660_uppercase_characters(char *str, size_t len)
 {
-	int p;
+	size_t p;
 
 	for (p = 0; p < len; p++) {
 		if (islower((unsigned char)str[p]) )

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.22 src/usr.sbin/makefs/ffs/buf.c:1.23
--- src/usr.sbin/makefs/ffs/buf.c:1.22	Sun Mar 29 01:52:59 2015
+++ src/usr.sbin/makefs/ffs/buf.c	Thu Dec 24 10:52:37 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.22 2015/03/29 05:52:59 agc Exp $	*/
+/*	$NetBSD: buf.c,v 1.23 2015/12/24 15:52:37 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: buf.c,v 1.22 2015/03/29 05:52:59 agc Exp $");
+__RCSID("$NetBSD: buf.c,v 1.23 2015/12/24 15:52:37 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -80,7 +80,7 @@ bread(struct vnode *vp, daddr_t blkno, i
 	if (lseek((*bpp)->b_fs->fd, offset, SEEK_SET) == -1)
 		err(1, "%s: lseek %lld 

CVS commit: src/usr.sbin/makefs

2015-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 21 00:58:08 UTC 2015

Modified Files:
src/usr.sbin/makefs: ffs.c
src/usr.sbin/makefs/ffs: mkfs.c newfs_extern.h

Log Message:
more deterministic ffs for reproducible builds.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/makefs/ffs/mkfs.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makefs/ffs/newfs_extern.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.65 src/usr.sbin/makefs/ffs.c:1.66
--- src/usr.sbin/makefs/ffs.c:1.65	Sun Dec 20 17:54:44 2015
+++ src/usr.sbin/makefs/ffs.c	Sun Dec 20 19:58:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.65 2015/12/20 22:54:44 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.65 2015/12/20 22:54:44 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.66 2015/12/21 00:58:08 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -466,6 +466,7 @@ ffs_create_image(const char *image, fsin
 	char	*buf;
 	int	i, bufsize;
 	off_t	bufrem;
+	time_t	tstamp;
 	int	oflags = O_RDWR | O_CREAT;
 
 	assert (image != NULL);
@@ -530,7 +531,15 @@ ffs_create_image(const char *image, fsin
 		/* make the file system */
 	if (debug & DEBUG_FS_CREATE_IMAGE)
 		printf("calling mkfs(\"%s\", ...)\n", image);
-	fs = ffs_mkfs(image, fsopts);
+
+	if (stampst.st_ino == 1)
+		tstamp = stampst.st_ctime;
+	else
+		tstamp = start_time.tv_sec;
+
+	srandom(tstamp);
+
+	fs = ffs_mkfs(image, fsopts, tstamp);
 	fsopts->superblock = (void *)fs;
 	if (debug & DEBUG_FS_CREATE_IMAGE) {
 		time_t t;
@@ -,7 +1120,6 @@ ffs_write_inode(union dinode *dp, uint32
 	initediblk < ufs_rw32(cgp->cg_niblk, fsopts->needswap)) {
 		memset(buf, 0, fs->fs_bsize);
 		dip = (struct ufs2_dinode *)buf;
-		srandom(time(NULL));
 		for (i = 0; i < FFS_INOPB(fs); i++) {
 			dip->di_gen = random() / 2 + 1;
 			dip++;

Index: src/usr.sbin/makefs/ffs/mkfs.c
diff -u src/usr.sbin/makefs/ffs/mkfs.c:1.32 src/usr.sbin/makefs/ffs/mkfs.c:1.33
--- src/usr.sbin/makefs/ffs/mkfs.c:1.32	Sat Oct 19 13:16:37 2013
+++ src/usr.sbin/makefs/ffs/mkfs.c	Sun Dec 20 19:58:08 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: mkfs.c,v 1.32 2013/10/19 17:16:37 christos Exp $	*/
+/*	$NetBSD: mkfs.c,v 1.33 2015/12/21 00:58:08 christos Exp $	*/
 
 /*
  * Copyright (c) 2002 Networks Associates Technology, Inc.
@@ -48,7 +48,7 @@
 static char sccsid[] = "@(#)mkfs.c	8.11 (Berkeley) 5/3/95";
 #else
 #ifdef __RCSID
-__RCSID("$NetBSD: mkfs.c,v 1.32 2013/10/19 17:16:37 christos Exp $");
+__RCSID("$NetBSD: mkfs.c,v 1.33 2015/12/21 00:58:08 christos Exp $");
 #endif
 #endif
 #endif /* not lint */
@@ -122,7 +122,7 @@ static int avgfilesize;	   /* expect
 static int avgfpdir;	   /* expected number of files per directory */
 
 struct fs *
-ffs_mkfs(const char *fsys, const fsinfo_t *fsopts)
+ffs_mkfs(const char *fsys, const fsinfo_t *fsopts, time_t tstamp)
 {
 	int fragsperinode, optimalfpg, origdensity, minfpg, lastminfpg;
 	int32_t cylno, i, csfrags;
@@ -445,7 +445,7 @@ ffs_mkfs(const char *fsys, const fsinfo_
 	sblock.fs_state = 0;
 	sblock.fs_clean = FS_ISCLEAN;
 	sblock.fs_ronly = 0;
-	sblock.fs_id[0] = start_time.tv_sec;
+	sblock.fs_id[0] = tstamp;
 	sblock.fs_id[1] = random();
 	sblock.fs_fsmnt[0] = '\0';
 	csfrags = howmany(sblock.fs_cssize, sblock.fs_fsize);
@@ -461,9 +461,9 @@ ffs_mkfs(const char *fsys, const fsinfo_
 	sblock.fs_cstotal.cs_nifree = sblock.fs_ncg * sblock.fs_ipg - UFS_ROOTINO;
 	sblock.fs_cstotal.cs_ndir = 0;
 	sblock.fs_dsize -= csfrags;
-	sblock.fs_time = start_time.tv_sec;
+	sblock.fs_time = tstamp;
 	if (Oflag <= 1) {
-		sblock.fs_old_time = start_time.tv_sec;
+		sblock.fs_old_time = tstamp;
 		sblock.fs_old_dsize = sblock.fs_dsize;
 		sblock.fs_old_csaddr = sblock.fs_csaddr;
 		sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
@@ -515,7 +515,7 @@ ffs_mkfs(const char *fsys, const fsinfo_
 
 	printf("super-block backups (for fsck -b #) at:");
 	for (cylno = 0; cylno < sblock.fs_ncg; cylno++) {
-		initcg(cylno, start_time.tv_sec, fsopts);
+		initcg(cylno, tstamp, fsopts);
 		if (cylno % nprintcols == 0)
 			printf("\n");
 		printf(" %*lld,", printcolwidth,
@@ -528,7 +528,7 @@ ffs_mkfs(const char *fsys, const fsinfo_
 	 * Now construct the initial file system,
 	 * then write out the super-block.
 	 */
-	sblock.fs_time = start_time.tv_sec;
+	sblock.fs_time = tstamp;
 	if (Oflag <= 1) {
 		sblock.fs_old_cstotal.cs_ndir = sblock.fs_cstotal.cs_ndir;
 		sblock.fs_old_cstotal.cs_nbfree = sblock.fs_cstotal.cs_nbfree;

Index: src/usr.sbin/makefs/ffs/newfs_extern.h
diff -u src/usr.sbin/makefs/ffs/newfs_extern.h:1.3 src/usr.sbin/makefs/ffs/newfs_extern.h:1.4
--- 

CVS commit: src/usr.sbin/makefs

2015-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 21 03:19:17 UTC 2015

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
Fix some more MKREPRO issues in cdrom creation. Now amd64 passes MKREPRO.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.50 src/usr.sbin/makefs/cd9660.c:1.51
--- src/usr.sbin/makefs/cd9660.c:1.50	Tue Nov 24 19:48:49 2015
+++ src/usr.sbin/makefs/cd9660.c	Sun Dec 20 22:19:17 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.50 2015/11/25 00:48:49 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.51 2015/12/21 03:19:17 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.50 2015/11/25 00:48:49 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.51 2015/12/21 03:19:17 christos Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -483,7 +483,7 @@ cd9660_parse_opts(const char *option, fs
  */
 void
 cd9660_makefs(const char *image, const char *dir, fsnode *root,
-	  fsinfo_t *fsopts)
+fsinfo_t *fsopts)
 {
 	int64_t startoffset;
 	int numDirectories;
@@ -661,7 +661,7 @@ typedef int (*cd9660node_func)(cd9660nod
 static void
 cd9660_finalize_PVD(iso9660_disk *diskStructure)
 {
-	time_t tim;
+	time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
 
 	/* root should be a fixed size of 34 bytes since it has no name */
 	memcpy(diskStructure->primaryDescriptor.root_directory_record,
@@ -710,23 +710,23 @@ cd9660_finalize_PVD(iso9660_disk *diskSt
 		diskStructure->primaryDescriptor.bibliographic_file_id, 37);
 
 	/* Setup dates */
-	time();
 	cd9660_time_8426(
 	(unsigned char *)diskStructure->primaryDescriptor.creation_date,
-	tim);
+	tstamp);
 	cd9660_time_8426(
 	(unsigned char *)diskStructure->primaryDescriptor.modification_date,
-	tim);
+	tstamp);
 
-	/*
-	cd9660_set_date(diskStructure->primaryDescriptor.expiration_date, now);
-	*/
+#if 0
+	cd9660_set_date(diskStructure->primaryDescriptor.expiration_date,
+	tstamp);
+#endif
 	memset(diskStructure->primaryDescriptor.expiration_date, '0' ,16);
 	diskStructure->primaryDescriptor.expiration_date[16] = 0;
 
 	cd9660_time_8426(
 	(unsigned char *)diskStructure->primaryDescriptor.effective_date,
-	tim);
+	tstamp);
 }
 
 static void
@@ -821,7 +821,7 @@ cd9660_fill_extended_attribute_record(cd
 static int
 cd9660_translate_node_common(iso9660_disk *diskStructure, cd9660node *newnode)
 {
-	time_t tim;
+	time_t tstamp = stampst.st_ino ? stampst.st_mtime : time(NULL);
 	u_char flag;
 	char temp[ISO_FILENAME_MAXLENGTH_WITH_PADDING];
 
@@ -841,9 +841,8 @@ cd9660_translate_node_common(iso9660_dis
 	/* Set the various dates */
 
 	/* If we want to use the current date and time */
-	time();
 
-	cd9660_time_915(newnode->isoDirRecord->date, tim);
+	cd9660_time_915(newnode->isoDirRecord->date, tstamp);
 
 	cd9660_bothendian_dword(newnode->fileDataLength,
 	newnode->isoDirRecord->size);
@@ -883,7 +882,8 @@ cd9660_translate_node(iso9660_disk *disk
 		return 0;
 
 	/* Finally, overwrite some of the values that are set by default */
-	cd9660_time_915(newnode->isoDirRecord->date, node->inode->st.st_mtime);
+	cd9660_time_915(newnode->isoDirRecord->date,
+	stampst.st_ino ? stampst.st_mtime : node->inode->st.st_mtime);
 
 	return 1;
 }



CVS commit: src/usr.sbin/makefs

2015-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 20 22:54:44 UTC 2015

Modified Files:
src/usr.sbin/makefs: ffs.c

Log Message:
Add timestamp support to the ffs image creation; needed for in kernel memory
images MKREPRO.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/usr.sbin/makefs/ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.64 src/usr.sbin/makefs/ffs.c:1.65
--- src/usr.sbin/makefs/ffs.c:1.64	Mon Jan 12 14:50:25 2015
+++ src/usr.sbin/makefs/ffs.c	Sun Dec 20 17:54:44 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.64 2015/01/12 19:50:25 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.65 2015/12/20 22:54:44 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: ffs.c,v 1.64 2015/01/12 19:50:25 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.65 2015/12/20 22:54:44 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -637,19 +637,12 @@ ffs_build_dinode1(struct ufs1_dinode *di
 {
 	size_t slen;
 	void *membuf;
+	struct stat *st = stampst.st_ino == 1 ?  : >inode->st;
 
 	memset(dinp, 0, sizeof(*dinp));
 	dinp->di_mode = cur->inode->st.st_mode;
 	dinp->di_nlink = cur->inode->nlink;
 	dinp->di_size = cur->inode->st.st_size;
-	dinp->di_atime = cur->inode->st.st_atime;
-	dinp->di_mtime = cur->inode->st.st_mtime;
-	dinp->di_ctime = cur->inode->st.st_ctime;
-#if HAVE_STRUCT_STAT_ST_MTIMENSEC
-	dinp->di_atimensec = cur->inode->st.st_atimensec;
-	dinp->di_mtimensec = cur->inode->st.st_mtimensec;
-	dinp->di_ctimensec = cur->inode->st.st_ctimensec;
-#endif
 #if HAVE_STRUCT_STAT_ST_FLAGS
 	dinp->di_flags = cur->inode->st.st_flags;
 #endif
@@ -658,6 +651,15 @@ ffs_build_dinode1(struct ufs1_dinode *di
 #endif
 	dinp->di_uid = cur->inode->st.st_uid;
 	dinp->di_gid = cur->inode->st.st_gid;
+
+	dinp->di_atime = st->st_atime;
+	dinp->di_mtime = st->st_mtime;
+	dinp->di_ctime = st->st_ctime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+	dinp->di_atimensec = st->st_atimensec;
+	dinp->di_mtimensec = st->st_mtimensec;
+	dinp->di_ctimensec = st->st_ctimensec;
+#endif
 		/* not set: di_db, di_ib, di_blocks, di_spare */
 
 	membuf = NULL;
@@ -685,31 +687,33 @@ ffs_build_dinode2(struct ufs2_dinode *di
 {
 	size_t slen;
 	void *membuf;
+	struct stat *st = stampst.st_ino == 1 ?  : >inode->st;
 
 	memset(dinp, 0, sizeof(*dinp));
 	dinp->di_mode = cur->inode->st.st_mode;
 	dinp->di_nlink = cur->inode->nlink;
 	dinp->di_size = cur->inode->st.st_size;
-	dinp->di_atime = cur->inode->st.st_atime;
-	dinp->di_mtime = cur->inode->st.st_mtime;
-	dinp->di_ctime = cur->inode->st.st_ctime;
-#if HAVE_STRUCT_STAT_ST_MTIMENSEC
-	dinp->di_atimensec = cur->inode->st.st_atimensec;
-	dinp->di_mtimensec = cur->inode->st.st_mtimensec;
-	dinp->di_ctimensec = cur->inode->st.st_ctimensec;
-#endif
 #if HAVE_STRUCT_STAT_ST_FLAGS
 	dinp->di_flags = cur->inode->st.st_flags;
 #endif
 #if HAVE_STRUCT_STAT_ST_GEN
 	dinp->di_gen = cur->inode->st.st_gen;
 #endif
-#if HAVE_STRUCT_STAT_BIRTHTIME
-	dinp->di_birthtime = cur->inode->st.st_birthtime;
-	dinp->di_birthnsec = cur->inode->st.st_birthtimensec;
-#endif
 	dinp->di_uid = cur->inode->st.st_uid;
 	dinp->di_gid = cur->inode->st.st_gid;
+
+	dinp->di_atime = st->st_atime;
+	dinp->di_mtime = st->st_mtime;
+	dinp->di_ctime = st->st_ctime;
+#if HAVE_STRUCT_STAT_ST_MTIMENSEC
+	dinp->di_atimensec = st->st_atimensec;
+	dinp->di_mtimensec = st->st_mtimensec;
+	dinp->di_ctimensec = st->st_ctimensec;
+#endif
+#if HAVE_STRUCT_STAT_BIRTHTIME
+	dinp->di_birthtime = st->st_birthtime;
+	dinp->di_birthnsec = st->st_birthtimensec;
+#endif
 		/* not set: di_db, di_ib, di_blocks, di_spare */
 
 	membuf = NULL;



CVS commit: src/usr.sbin/makefs

2015-11-27 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Nov 27 15:10:32 UTC 2015

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
Don't pass garbage to parsedate, but do use the return value.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.52 src/usr.sbin/makefs/makefs.c:1.53
--- src/usr.sbin/makefs/makefs.c:1.52	Wed Nov 25 16:32:20 2015
+++ src/usr.sbin/makefs/makefs.c	Fri Nov 27 15:10:32 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.52 2015/11/25 16:32:20 wiz Exp $	*/
+/*	$NetBSD: makefs.c,v 1.53 2015/11/27 15:10:32 joerg Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.52 2015/11/25 16:32:20 wiz Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.53 2015/11/27 15:10:32 joerg Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -434,7 +434,7 @@ get_tstamp(const char *b, struct stat *s
 
 #ifndef HAVE_NBTOOL_CONFIG_H
 	errno = 0;
-	if (parsedate(b, , NULL) == -1 && errno != 0)
+	if ((when = parsedate(b, NULL, NULL)) == -1 && errno != 0)
 #endif
 	{
 		errno = 0;



CVS commit: src/usr.sbin/makefs

2015-11-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Nov 25 16:32:00 UTC 2015

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
"file system" as two words.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.54 src/usr.sbin/makefs/makefs.8:1.55
--- src/usr.sbin/makefs/makefs.8:1.54	Wed Nov 25 00:48:49 2015
+++ src/usr.sbin/makefs/makefs.8	Wed Nov 25 16:32:00 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.54 2015/11/25 00:48:49 christos Exp $
+.\"	$NetBSD: makefs.8,v 1.55 2015/11/25 16:32:00 wiz Exp $
 .\"
 .\" Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\" All rights reserved.
@@ -179,7 +179,7 @@ and
 .Xr getgrnam 3
 (and related) library calls.
 .It Fl O Ar offset
-Instead of creating the filesystem at the beginning of the file, start
+Instead of creating the file system at the beginning of the file, start
 at offset.
 Valid only for
 .Sy ffs
@@ -201,7 +201,7 @@ Defaults to 512.
 Set the size of the file system image to
 .Ar image-size .
 .It Fl T Ar timestamp
-Specify a timestamp to be set for all filesystem files and directories
+Specify a timestamp to be set for all file system files and directories
 created so that repeatable builds are possible.
 The
 .Ar timestamp



CVS commit: src/usr.sbin/makefs

2015-11-25 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Nov 25 16:32:20 UTC 2015

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
Sort options in usage to match man page order.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.51 src/usr.sbin/makefs/makefs.c:1.52
--- src/usr.sbin/makefs/makefs.c:1.51	Wed Nov 25 00:48:49 2015
+++ src/usr.sbin/makefs/makefs.c	Wed Nov 25 16:32:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.51 2015/11/25 00:48:49 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.52 2015/11/25 16:32:20 wiz Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.51 2015/11/25 00:48:49 christos Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.52 2015/11/25 16:32:20 wiz Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -462,7 +462,7 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
 "Usage: %s [-rxZ] [-B endian] [-b free-blocks] [-d debug-mask]\n"
 "\t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n"
 "\t[-N userdb-dir] [-O offset] [-o fs-options] [-S sector-size]\n"
-"\t[-s image-size] [-t fs-type] [-T ]"
+"\t[-s image-size] [-T ] [-t fs-type]"
 " image-file directory [extra-directory ...]\n",
 	prog);
 



CVS commit: src/usr.sbin/makefs

2015-11-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Nov 25 00:48:49 UTC 2015

Modified Files:
src/usr.sbin/makefs: cd9660.c makefs.8 makefs.c makefs.h walk.c

Log Message:
Provide a -T option to set timestamps to a consistent value for MKREPRO


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.53 -r1.54 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.28 -r1.29 src/usr.sbin/makefs/walk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.49 src/usr.sbin/makefs/cd9660.c:1.50
--- src/usr.sbin/makefs/cd9660.c:1.49	Tue Jun 16 21:05:41 2015
+++ src/usr.sbin/makefs/cd9660.c	Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.49 2015/06/17 01:05:41 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.50 2015/11/25 00:48:49 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: cd9660.c,v 1.49 2015/06/17 01:05:41 christos Exp $");
+__RCSID("$NetBSD: cd9660.c,v 1.50 2015/11/25 00:48:49 christos Exp $");
 #endif  /* !__lint */
 
 #include 
@@ -1281,6 +1281,8 @@ cd9660_rrip_move_directory(iso9660_disk 
 		diskStructure->rootNode, dir);
 		if (diskStructure->rr_moved_dir == NULL)
 			return 0;
+		cd9660_time_915(diskStructure->rr_moved_dir->isoDirRecord->date,
+		stampst.st_ino ? stampst.st_mtime : start_time.tv_sec);
 	}
 
 	/* Create a file with the same ORIGINAL name */

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.53 src/usr.sbin/makefs/makefs.8:1.54
--- src/usr.sbin/makefs/makefs.8:1.53	Tue Aug  6 16:16:54 2013
+++ src/usr.sbin/makefs/makefs.8	Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-.\"	$NetBSD: makefs.8,v 1.53 2013/08/06 20:16:54 wiz Exp $
+.\"	$NetBSD: makefs.8,v 1.54 2015/11/25 00:48:49 christos Exp $
 .\"
 .\" Copyright (c) 2001-2003 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 August 6, 2013
+.Dd November 23, 2015
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -54,6 +54,7 @@
 .Op Fl o Ar fs-options
 .Op Fl S Ar sector-size
 .Op Fl s Ar image-size
+.Op Fl T Ar timestamp
 .Op Fl t Ar fs-type
 .Ar image-file
 .Ar directory
@@ -199,6 +200,21 @@ Defaults to 512.
 .It Fl s Ar image-size
 Set the size of the file system image to
 .Ar image-size .
+.It Fl T Ar timestamp
+Specify a timestamp to be set for all filesystem files and directories
+created so that repeatable builds are possible.
+The
+.Ar timestamp
+can be a
+.Pa pathname ,
+where the timestamps are derived from that file, a parseable date
+for
+.Xr parsedate 3
+(this option is not yet available in the tools build), or an integer
+value interpreted as the number of seconds from the Epoch.
+Note that timestamps specified in an
+.Xr mtree 5
+spec file, override the default timestamp.
 .It Fl t Ar fs-type
 Create an
 .Ar fs-type

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.50 src/usr.sbin/makefs/makefs.c:1.51
--- src/usr.sbin/makefs/makefs.c:1.50	Mon Aug  5 10:41:57 2013
+++ src/usr.sbin/makefs/makefs.c	Tue Nov 24 19:48:49 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $	*/
+/*	$NetBSD: makefs.c,v 1.51 2015/11/25 00:48:49 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $");
+__RCSID("$NetBSD: makefs.c,v 1.51 2015/11/25 00:48:49 christos Exp $");
 #endif	/* !__lint */
 
 #include 
@@ -87,8 +87,10 @@ static fstype_t fstypes[] = {
 
 u_int		debug;
 struct timespec	start_time;
+struct stat stampst;
 
 static	fstype_t *get_fstype(const char *);
+static int get_tstamp(const char *, struct stat *);
 static	void	usage(fstype_t *, fsinfo_t *) __dead;
 
 int
@@ -116,13 +118,18 @@ main(int argc, char *argv[])
 		fstype->prepare_options();
 
 	specfile = NULL;
-	if (gettimeofday(, NULL) == -1)
-		err(1, "Unable to get system time");
-
+#ifdef CLOCK_REALTIME
+	ch = clock_gettime(CLOCK_REALTIME, _time);
+#else
+	ch = gettimeofday(, NULL);
 	start_time.tv_sec = start.tv_sec;
 	start_time.tv_nsec = start.tv_usec * 1000;
+#endif
+	if (ch == -1)
+		err(1, "Unable to get system time");
 
-	while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:O:o:rs:S:t:xZ")) != -1) {
+
+	while ((ch = getopt(argc, argv, "B:b:d:f:F:M:m:N:O:o:rs:S:t:T:xZ")) != -1) {
 		switch (ch) {
 
 		case 'B':
@@ -240,6 +247,12 @@ main(int argc, char *argv[])
 			fstype->prepare_options();
 			break;
 
+		case 'T':
+			if (get_tstamp(optarg, ) == 

CVS commit: src/usr.sbin/makefs

2015-10-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct 16 16:40:02 UTC 2015

Modified Files:
src/usr.sbin/makefs: msdos.c msdos.h

Log Message:
remove clause 3.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/makefs/msdos.c
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/makefs/msdos.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.14 src/usr.sbin/makefs/msdos.c:1.15
--- src/usr.sbin/makefs/msdos.c:1.14	Sat Feb  2 22:21:21 2013
+++ src/usr.sbin/makefs/msdos.c	Fri Oct 16 12:40:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.14 2013/02/03 03:21:21 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.15 2015/10/16 16:40:02 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -15,9 +15,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The NetBSD Foundation nor the names of its
- *contributors may be used to endorse or promote products derived
- *from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -37,7 +34,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(__lint)
-__RCSID("$NetBSD: msdos.c,v 1.14 2013/02/03 03:21:21 christos Exp $");
+__RCSID("$NetBSD: msdos.c,v 1.15 2015/10/16 16:40:02 christos Exp $");
 #endif	/* !__lint */
 
 #include 

Index: src/usr.sbin/makefs/msdos.h
diff -u src/usr.sbin/makefs/msdos.h:1.2 src/usr.sbin/makefs/msdos.h:1.3
--- src/usr.sbin/makefs/msdos.h:1.2	Fri Jan 25 19:31:49 2013
+++ src/usr.sbin/makefs/msdos.h	Fri Oct 16 12:40:02 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.h,v 1.2 2013/01/26 00:31:49 christos Exp $	*/
+/*	$NetBSD: msdos.h,v 1.3 2015/10/16 16:40:02 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -15,9 +15,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The NetBSD Foundation nor the names of its
- *contributors may be used to endorse or promote products derived
- *from this software without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED



CVS commit: src/usr.sbin/makefs

2015-06-16 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun 17 01:05:41 UTC 2015

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
more error normalization


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.48 src/usr.sbin/makefs/cd9660.c:1.49
--- src/usr.sbin/makefs/cd9660.c:1.48	Tue Jun 16 19:04:14 2015
+++ src/usr.sbin/makefs/cd9660.c	Tue Jun 16 21:05:41 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.48 2015/06/16 23:04:14 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.49 2015/06/17 01:05:41 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.48 2015/06/16 23:04:14 christos Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.49 2015/06/17 01:05:41 christos Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -499,7 +499,7 @@ cd9660_makefs(const char *image, const c
 		diskStructure-isoLevel);
 	if (diskStructure-isoLevel  2 
 	diskStructure-allow_multidot)
-		errx(1, allow-multidot requires iso level of 2);
+		errx(EXIT_FAILURE, allow-multidot requires iso level of 2);
 
 	assert(image != NULL);
 	assert(dir != NULL);
@@ -540,10 +540,10 @@ cd9660_makefs(const char *image, const c
 	numDirectories, error);
 
 	if (TAILQ_EMPTY(real_root-cn_children)) {
-		errx(1, %s: converted directory is empty. , __func__,
-		Tree conversion failed);
+		errx(EXIT_FAILURE, %s: converted directory is empty. 
+		Tree conversion failed, __func__);
 	} else if (error != 0) {
-		errx(1, cd9660_makefs: tree conversion failed);
+		errx(EXIT_FAILURE, %s: tree conversion failed, __func__);
 	} else {
 		if (diskStructure-verbose_level  0)
 			printf(%s: tree converted\n, __func__);
@@ -579,7 +579,7 @@ cd9660_makefs(const char *image, const c
 		firstAvailableSector = cd9660_setup_boot(diskStructure,
 		firstAvailableSector);
 		if (firstAvailableSector  0)
-			errx(1, setup_boot failed);
+			errx(EXIT_FAILURE, setup_boot failed);
 	}
 	/* LE first, then BE */
 	diskStructure-primaryLittleEndianTableSector = firstAvailableSector;
@@ -1603,7 +1603,7 @@ cd9660_compute_full_filename(cd9660node 
 	len = snprintf(buf, len, %s/%s/%s, node-node-root,
 	node-node-path, node-node-name);
 	if (len  CD9660MAXPATH)
-		errx(1, Pathname too long.);
+		errx(EXIT_FAILURE, Pathname too long.);
 }
 
 /* NEW filename conversion method */



CVS commit: src/usr.sbin/makefs

2015-03-28 Thread Alistair G. Crooks
Module Name:src
Committed By:   agc
Date:   Sun Mar 29 05:52:59 UTC 2015

Modified Files:
src/usr.sbin/makefs/ffs: buf.c buf.h ffs_alloc.c ffs_balloc.c
src/usr.sbin/makefs/msdos: msdosfs_denode.c msdosfs_vfsops.c
msdosfs_vnops.c

Log Message:
Make the userland signature and uses of bread() match the kernel ones,
after the removal of the cred argument.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makefs/ffs/buf.c
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/makefs/ffs/buf.h
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makefs/ffs/ffs_balloc.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/msdos/msdosfs_denode.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.21 src/usr.sbin/makefs/ffs/buf.c:1.22
--- src/usr.sbin/makefs/ffs/buf.c:1.21	Sun Feb  3 03:21:21 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Sun Mar 29 05:52:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.21 2013/02/03 03:21:21 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.22 2015/03/29 05:52:59 agc Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: buf.c,v 1.21 2013/02/03 03:21:21 christos Exp $);
+__RCSID($NetBSD: buf.c,v 1.22 2015/03/29 05:52:59 agc Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -60,8 +60,8 @@ __RCSID($NetBSD: buf.c,v 1.21 2013/02/0
 TAILQ_HEAD(buftailhead,buf) buftail;
 
 int
-bread(struct vnode *vp, daddr_t blkno, int size, struct kauth_cred *u1 __unused,
-   int u2 __unused, struct buf **bpp)
+bread(struct vnode *vp, daddr_t blkno, int size, int u2 __unused,
+	struct buf **bpp)
 {
 	off_t	offset;
 	ssize_t	rv;

Index: src/usr.sbin/makefs/ffs/buf.h
diff -u src/usr.sbin/makefs/ffs/buf.h:1.9 src/usr.sbin/makefs/ffs/buf.h:1.10
--- src/usr.sbin/makefs/ffs/buf.h:1.9	Wed Jan 30 19:19:19 2013
+++ src/usr.sbin/makefs/ffs/buf.h	Sun Mar 29 05:52:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.9 2013/01/30 19:19:19 christos Exp $	*/
+/*	$NetBSD: buf.h,v 1.10 2015/03/29 05:52:59 agc Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -75,8 +75,7 @@ struct buf {
 
 struct kauth_cred;
 void		bcleanup(void);
-int		bread(struct vnode *, daddr_t, int, struct kauth_cred *,
-int, struct buf **);
+int		bread(struct vnode *, daddr_t, int, int, struct buf **);
 void		brelse(struct buf *, int);
 int		bwrite(struct buf *);
 struct buf *	getblk(struct vnode *, daddr_t, int, int, int);

Index: src/usr.sbin/makefs/ffs/ffs_alloc.c
diff -u src/usr.sbin/makefs/ffs/ffs_alloc.c:1.27 src/usr.sbin/makefs/ffs/ffs_alloc.c:1.28
--- src/usr.sbin/makefs/ffs/ffs_alloc.c:1.27	Sun Jun 23 22:03:34 2013
+++ src/usr.sbin/makefs/ffs/ffs_alloc.c	Sun Mar 29 05:52:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_alloc.c,v 1.27 2013/06/23 22:03:34 dholland Exp $	*/
+/*	$NetBSD: ffs_alloc.c,v 1.28 2015/03/29 05:52:59 agc Exp $	*/
 /* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */
 
 /*
@@ -47,7 +47,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs_alloc.c,v 1.27 2013/06/23 22:03:34 dholland Exp $);
+__RCSID($NetBSD: ffs_alloc.c,v 1.28 2015/03/29 05:52:59 agc Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -308,7 +308,7 @@ ffs_alloccg(struct inode *ip, int cg, da
 	if (fs-fs_cs(fs, cg).cs_nbfree == 0  size == fs-fs_bsize)
 		return (0);
 	error = bread(ip-i_devvp, FFS_FSBTODB(fs, cgtod(fs, cg)),
-	(int)fs-fs_cgsize, NULL, 0, bp);
+	(int)fs-fs_cgsize, 0, bp);
 	if (error) {
 		return (0);
 	}
@@ -451,7 +451,7 @@ ffs_blkfree(struct inode *ip, daddr_t bn
 		return;
 	}
 	error = bread(ip-i_devvp, FFS_FSBTODB(fs, cgtod(fs, cg)),
-	(int)fs-fs_cgsize, NULL, 0, bp);
+	(int)fs-fs_cgsize, 0, bp);
 	if (error) {
 		brelse(bp, 0);
 		return;

Index: src/usr.sbin/makefs/ffs/ffs_balloc.c
diff -u src/usr.sbin/makefs/ffs/ffs_balloc.c:1.20 src/usr.sbin/makefs/ffs/ffs_balloc.c:1.21
--- src/usr.sbin/makefs/ffs/ffs_balloc.c:1.20	Sun Jun 23 07:28:37 2013
+++ src/usr.sbin/makefs/ffs/ffs_balloc.c	Sun Mar 29 05:52:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs_balloc.c,v 1.20 2013/06/23 07:28:37 dholland Exp $	*/
+/*	$NetBSD: ffs_balloc.c,v 1.21 2015/03/29 05:52:59 agc Exp $	*/
 /* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */
 
 /*
@@ -38,7 +38,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs_balloc.c,v 1.20 2013/06/23 07:28:37 dholland Exp $);
+__RCSID($NetBSD: ffs_balloc.c,v 1.21 2015/03/29 05:52:59 agc Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -139,7 +139,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t 
 
 			if (bpp != NULL) {
 		

CVS commit: src/usr.sbin/makefs

2015-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 12 19:50:25 UTC 2015

Modified Files:
src/usr.sbin/makefs: ffs.c

Log Message:
PR/49559: Christian Brueffer: Fix typo maxbpf instead of maxbpg.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/usr.sbin/makefs/ffs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.63 src/usr.sbin/makefs/ffs.c:1.64
--- src/usr.sbin/makefs/ffs.c:1.63	Sat Jun 22 22:06:06 2013
+++ src/usr.sbin/makefs/ffs.c	Mon Jan 12 14:50:25 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.63 2013/06/23 02:06:06 dholland Exp $	*/
+/*	$NetBSD: ffs.c,v 1.64 2015/01/12 19:50:25 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs.c,v 1.63 2013/06/23 02:06:06 dholland Exp $);
+__RCSID($NetBSD: ffs.c,v 1.64 2015/01/12 19:50:25 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -164,7 +164,7 @@ ffs_prep_opts(fsinfo_t *fsopts)
 	  1, INT_MAX, bytes per inode },
 	{ 'm', minfree, ffs_opts-minfree, OPT_INT32,
 	  0, 99, minfree },
-	{ 'M', maxbpf, ffs_opts-maxbpg, OPT_INT32,
+	{ 'M', maxbpg, ffs_opts-maxbpg, OPT_INT32,
 	  1, INT_MAX, max blocks per file in a cg },
 	{ 'a', avgfilesize, ffs_opts-avgfilesize, OPT_INT32,
 	  1, INT_MAX, expected average file size },



CVS commit: src/usr.sbin/makefs

2015-01-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 12 19:50:47 UTC 2015

Modified Files:
src/usr.sbin/makefs: README

Log Message:
reflect reality about filesystems supported.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/README

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/README
diff -u src/usr.sbin/makefs/README:1.6 src/usr.sbin/makefs/README:1.7
--- src/usr.sbin/makefs/README:1.6	Sat Oct 18 04:33:31 2014
+++ src/usr.sbin/makefs/README	Mon Jan 12 14:50:47 2015
@@ -1,4 +1,4 @@
-$NetBSD: README,v 1.6 2014/10/18 08:33:31 snj Exp $
+$NetBSD: README,v 1.7 2015/01/12 19:50:47 christos Exp $
 
 makefs - build a file system image from a directory tree
 
@@ -15,16 +15,21 @@ user overview:
 
 makefs creates a file system image from a given directory tree.
 the following file system types can be built:
-	ffs	BSD fast file system
+
 	cd9660	ISO 9660 file system
+	chfs	Chip file system, for flash devices
+	ffs	BSD fast file system
+	msdos	MS-DOS `FAT' file system (FAT12, FAT16, FAT32)
+	udf	Universal Disk Format file system
 	v7fs	7th edition(V7) file system
 
 Support for the following file systems maybe be added in the future
+
 	ext2fs	Linux EXT2 file system
-	fat	MS-DOS `FAT' file system (FAT12, FAT16, FAT32)
 
 Various file system independent parameters and contraints can be
 specified, such as:
+
 	- minimum file system size (in KB)
 	- maximum file system size (in KB)
 	- free inodes
@@ -38,6 +43,7 @@ specified, such as:
 File system specific parameters can be given as well, with a command
 line option such as -o fsspeccific-options,comma-separated.
 For example, ffs would allow tuning of:
+
 	- block  fragment size
 	- cylinder groups
 	- number of blocks per inode



CVS commit: src/usr.sbin/makefs/msdos

2014-07-09 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Wed Jul  9 06:04:16 UTC 2014

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vfsops.c

Log Message:
What a terrible use-after-free


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vfsops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.7 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.8
--- src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.7	Wed Jan 30 19:19:19 2013
+++ src/usr.sbin/makefs/msdos/msdosfs_vfsops.c	Wed Jul  9 06:04:16 2014
@@ -50,7 +50,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.7 2013/01/30 19:19:19 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.8 2014/07/09 06:04:16 maxv Exp $);
 
 #include sys/param.h
 
@@ -407,7 +407,7 @@ error_exit:
 		free(pmp);
 	}
 	errno = error;
-	return pmp;
+	return NULL;
 }
 
 int



CVS commit: src/usr.sbin/makefs/cd9660

2014-05-30 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri May 30 13:14:48 UTC 2014

Modified Files:
src/usr.sbin/makefs/cd9660: iso9660_rrip.c

Log Message:
PR kern/48852 (which should have been bin/ in retrospect): apply patch
from Thomas Schmitt to fix rockridge encoding of device nodes.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makefs/cd9660/iso9660_rrip.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660/iso9660_rrip.c
diff -u src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.13 src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.14
--- src/usr.sbin/makefs/cd9660/iso9660_rrip.c:1.13	Tue Jul 30 16:02:23 2013
+++ src/usr.sbin/makefs/cd9660/iso9660_rrip.c	Fri May 30 13:14:47 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: iso9660_rrip.c,v 1.13 2013/07/30 16:02:23 reinoud Exp $	*/
+/*	$NetBSD: iso9660_rrip.c,v 1.14 2014/05/30 13:14:47 martin Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -44,7 +44,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: iso9660_rrip.c,v 1.13 2013/07/30 16:02:23 reinoud Exp $);
+__RCSID($NetBSD: iso9660_rrip.c,v 1.14 2014/05/30 13:14:47 martin Exp $);
 #endif  /* !__lint */
 
 static void cd9660_rrip_initialize_inode(cd9660node *);
@@ -657,13 +657,14 @@ cd9660node_rrip_pn(struct ISO_SUSP_ATTRI
 	pn_field-attr.rr_entry.PN.h.length[0] = 20;
 	pn_field-attr.rr_entry.PN.h.version[0] = 1;
 
-	if (sizeof (fnode-inode-st.st_dev)  32)
-		cd9660_bothendian_dword((uint64_t)fnode-inode-st.st_dev  32,
+	if (sizeof (fnode-inode-st.st_rdev)  4)
+		cd9660_bothendian_dword(
+		(uint64_t)fnode-inode-st.st_rdev  32,
 		pn_field-attr.rr_entry.PN.high);
 	else
 		cd9660_bothendian_dword(0, pn_field-attr.rr_entry.PN.high);
 
-	cd9660_bothendian_dword(fnode-inode-st.st_dev  0x,
+	cd9660_bothendian_dword(fnode-inode-st.st_rdev  0x,
 		pn_field-attr.rr_entry.PN.low);
 	return 1;
 }



CVS commit: src/usr.sbin/makefs

2013-12-19 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 19 22:10:03 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
initialize dummy_ref


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.14 src/usr.sbin/makefs/udf.c:1.15
--- src/usr.sbin/makefs/udf.c:1.14	Sat Oct 19 13:16:37 2013
+++ src/usr.sbin/makefs/udf.c	Thu Dec 19 17:10:03 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.14 2013/10/19 17:16:37 christos Exp $ */
+/* $NetBSD: udf.c,v 1.15 2013/12/19 22:10:03 christos Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.14 2013/10/19 17:16:37 christos Exp $);
+__RCSID($NetBSD: udf.c,v 1.15 2013/12/19 22:10:03 christos Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -842,7 +842,7 @@ udf_estimate_walk(fsinfo_t *fsopts,
 		fsnode *root, char *dir, struct udf_stats *stats)
 {
 	struct fileid_desc *fid;
-	struct long_ad dummy_ref;
+	struct long_ad dummy_ref = { 0 };
 	fsnode *cur;
 	fsinode *fnode;
 	size_t pathlen = strlen(dir);



CVS commit: src/usr.sbin/makefs

2013-12-19 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Dec 19 23:00:50 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
long_ad is a mix of struct and union, so use memset to initialise in the
one place it is used.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.15 src/usr.sbin/makefs/udf.c:1.16
--- src/usr.sbin/makefs/udf.c:1.15	Thu Dec 19 22:10:03 2013
+++ src/usr.sbin/makefs/udf.c	Thu Dec 19 23:00:50 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.15 2013/12/19 22:10:03 christos Exp $ */
+/* $NetBSD: udf.c,v 1.16 2013/12/19 23:00:50 joerg Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.15 2013/12/19 22:10:03 christos Exp $);
+__RCSID($NetBSD: udf.c,v 1.16 2013/12/19 23:00:50 joerg Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -842,7 +842,7 @@ udf_estimate_walk(fsinfo_t *fsopts,
 		fsnode *root, char *dir, struct udf_stats *stats)
 {
 	struct fileid_desc *fid;
-	struct long_ad dummy_ref = { 0 };
+	struct long_ad dummy_ref;
 	fsnode *cur;
 	fsinode *fnode;
 	size_t pathlen = strlen(dir);
@@ -881,6 +881,7 @@ udf_estimate_walk(fsinfo_t *fsopts,
 		case S_IFLNK:
 		case S_IFREG:
 			/* create dummy FID to see how long name will become */
+			memset(dummy_ref, 0, sizeof(dummy_ref));
 			udf_create_fid(ddoff, fid, cur-name, 0, dummy_ref);
 
 			nentries++;



CVS commit: src/usr.sbin/makefs

2013-10-24 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Thu Oct 24 14:01:01 UTC 2013

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
Now that tools/compat/compat_defs.h defones __USE, there's no
need to treat the tools build as a special case.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.46 src/usr.sbin/makefs/cd9660.c:1.47
--- src/usr.sbin/makefs/cd9660.c:1.46	Sat Oct 19 20:49:22 2013
+++ src/usr.sbin/makefs/cd9660.c	Thu Oct 24 14:01:01 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.46 2013/10/19 20:49:22 mrg Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.47 2013/10/24 14:01:01 apb Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.46 2013/10/19 20:49:22 mrg Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.47 2013/10/24 14:01:01 apb Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -1133,7 +1133,7 @@ cd9660_rename_filename(iso9660_disk *dis
 }
 			}
 		}
-#elif !HAVE_NBTOOL_CONFIG_H
+#else
 		__USE(dot);
 		__USE(semi);
 		__USE(multiplier);



CVS commit: src/usr.sbin/makefs

2013-10-19 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sat Oct 19 20:49:22 UTC 2013

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
avoid using __USE() in the tools version of this.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.45 src/usr.sbin/makefs/cd9660.c:1.46
--- src/usr.sbin/makefs/cd9660.c:1.45	Sat Oct 19 17:16:37 2013
+++ src/usr.sbin/makefs/cd9660.c	Sat Oct 19 20:49:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.45 2013/10/19 17:16:37 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.46 2013/10/19 20:49:22 mrg Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.45 2013/10/19 17:16:37 christos Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.46 2013/10/19 20:49:22 mrg Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -1133,7 +1133,7 @@ cd9660_rename_filename(iso9660_disk *dis
 }
 			}
 		}
-#else
+#elif !HAVE_NBTOOL_CONFIG_H
 		__USE(dot);
 		__USE(semi);
 		__USE(multiplier);



CVS commit: src/usr.sbin/makefs

2013-08-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug 14 10:16:04 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
when building as a tool, only use struct tm tm_gmtoff if 
HAVE_STRUCT_TM_TM_GMTOFF is defined -- fixes cygwin build


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.12 src/usr.sbin/makefs/udf.c:1.13
--- src/usr.sbin/makefs/udf.c:1.12	Fri Aug  9 15:11:08 2013
+++ src/usr.sbin/makefs/udf.c	Wed Aug 14 10:16:04 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.12 2013/08/09 15:11:08 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.13 2013/08/14 10:16:04 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.12 2013/08/09 15:11:08 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.13 2013/08/14 10:16:04 jmcneill Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -53,6 +53,10 @@ __RCSID($NetBSD: udf.c,v 1.12 2013/08/0
 #include udf/cdio_mmc_structs.h
 #endif
 
+#if !HAVE_NBTOOL_CONFIG_H
+#define HAVE_STRUCT_TM_TM_GMTOFF
+#endif
+
 #include makefs.h
 #include udf_create.h
 #include udf_write.h
@@ -328,7 +332,11 @@ udf_prep_opts(fsinfo_t *fsopts)
 	/* use user's time zone as default */
 	(void)time(now);
 	tm = localtime(now);
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
 	context.gmtoff = tm-tm_gmtoff;
+#else
+	context.gmtoff = 0;
+#endif
 
 	/* return info */
 	fsopts-fs_specific = NULL;



CVS commit: src/usr.sbin/makefs

2013-08-09 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Fri Aug  9 11:29:44 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
Oops, used size_t when off_t was meant. This results in the 4G file size
modulation seen on 32 bit machines due to size_t being 32 bit there.

While here, also fix compilation errors he@ discovered while compiling on
NetBSD/vax.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.10 src/usr.sbin/makefs/udf.c:1.11
--- src/usr.sbin/makefs/udf.c:1.10	Tue Aug  6 13:15:30 2013
+++ src/usr.sbin/makefs/udf.c	Fri Aug  9 11:29:44 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.10 2013/08/06 13:15:30 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.11 2013/08/09 11:29:44 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.10 2013/08/06 13:15:30 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.11 2013/08/09 11:29:44 reinoud Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -549,7 +549,7 @@ udf_prepare_fids(struct long_ad *dir_icb
 }
 
 static int
-udf_file_inject_blob(union dscrptr *dscr,  uint8_t *blob, size_t size)
+udf_file_inject_blob(union dscrptr *dscr,  uint8_t *blob, off_t size)
 {
 	struct icb_tag *icb;
 	struct file_entry *fe;
@@ -646,9 +646,11 @@ udf_append_file_mapping(union dscrptr *d
 	const int use_shorts = (context.data_part == context.metadata_part);
 	uint64_t max_len = UDF_ROUNDDOWN(UDF_EXT_MAXLEN, sector_size);
 
+	fe  = NULL;
+	efe = NULL;
 	if (udf_rw16(dscr-tag.id) == TAGID_FENTRY) {
 		fe  = dscr-fe;
-		data=fe-data;
+		data= fe-data;
 		l_ea= fe-l_ea;
 		l_ad= udf_rw32(fe-l_ad);
 		icb = fe-icbtag;
@@ -678,6 +680,9 @@ udf_append_file_mapping(union dscrptr *d
 	last_len  = 0;
 	last_lb_num   = 0;
 	last_part_num = 0;
+	last_flags= 0;
+	last_short= NULL;
+	last_long = NULL;
 	if (l_ad != 0) {
 		if (use_shorts) {
 			assert(cur_alloc == UDF_ICB_SHORT_ALLOC);
@@ -764,7 +769,7 @@ udf_append_file_mapping(union dscrptr *d
 
 static int
 udf_append_file_contents(union dscrptr *dscr, struct long_ad *data_icb,
-		uint8_t *fdata, size_t flen)
+		uint8_t *fdata, off_t flen)
 {
 	struct long_ad icb;
 	uint32_t location;
@@ -954,7 +959,7 @@ udf_copy_file(struct stat *st, char *pat
 	union dscrptr *dscr;
 	struct long_ad data_icb;
 	fsinode *fnode;
-	size_t sz, chunk, rd;
+	off_t sz, chunk, rd;
 	uint8_t *data;
 	int nblk;
 	int i, f;



CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 08:24:56 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
Fix assert() on allocation type by masking it with the flag allocation bit
mask. Fixes internal allocation writing in nodes with suid/sgid/sticky
accessnode.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.5 src/usr.sbin/makefs/udf.c:1.6
--- src/usr.sbin/makefs/udf.c:1.5	Tue Aug  6 08:18:08 2013
+++ src/usr.sbin/makefs/udf.c	Tue Aug  6 08:24:56 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.5 2013/08/06 08:18:08 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.6 2013/08/06 08:24:56 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.5 2013/08/06 08:18:08 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.6 2013/08/06 08:24:56 reinoud Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -517,7 +517,8 @@ udf_file_inject_blob(union dscrptr *dscr
 
 	/* going internal */
 	assert(l_ad == 0);
-	assert(udf_rw16(icb-flags) == UDF_ICB_INTERN_ALLOC);
+	assert((udf_rw16(icb-flags)  UDF_ICB_TAG_FLAGS_ALLOC_MASK) ==
+			UDF_ICB_INTERN_ALLOC);
 
 	// assert(free_space = size);
 	pos = data + l_ea + l_ad;



CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 09:32:23 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
Implement auto-setting of sector size and disc size when specifying
-oT=devtype to one of the supported disk types.

While here, also fix where the -s size argument would be overriden by the
calculated size.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.6 src/usr.sbin/makefs/udf.c:1.7
--- src/usr.sbin/makefs/udf.c:1.6	Tue Aug  6 08:24:56 2013
+++ src/usr.sbin/makefs/udf.c	Tue Aug  6 09:32:23 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.6 2013/08/06 08:24:56 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.7 2013/08/06 09:32:23 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.6 2013/08/06 08:24:56 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.7 2013/08/06 09:32:23 reinoud Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -133,7 +133,8 @@ udf_dump_discinfo(struct mmc_discinfo *d
 	printf(\tfst on last ses%d\n, di-first_track_last_session);
 	printf(\tlst on last ses%d\n, di-last_track_last_session);
 	printf(\tlink block penalty %d\n, di-link_block_penalty);
-	snprintb(bits, sizeof(bits), MMC_DFLAGS_FLAGBITS, (uint64_t) di-disc_flags);
+	snprintb(bits, sizeof(bits), MMC_DFLAGS_FLAGBITS,
+			(uint64_t) di-disc_flags);
 	printf(\tdisc flags %s\n, bits);
 	printf(\tdisc id%x\n, di-disc_id);
 	printf(\tdisc barcode   %PRIx64\n, di-disc_barcode);
@@ -191,7 +192,8 @@ udf_emulate_discinfo(fsinfo_t *fsopts, s
 	switch (mmc_emuprofile) {
 	case 0x00:	/* unknown, treat as CDROM */
 	case 0x08:	/* CDROM */
-	case 0x10:	/* DVD-ROM */
+	case 0x10:	/* DVDROM */
+	case 0x40:	/* BDROM */
 		req_enable |= FORMAT_READONLY;
 		/* FALLTROUGH */
 	case 0x01:	/* disc */
@@ -286,7 +288,7 @@ udf_prep_opts(fsinfo_t *fsopts)
 	time_t now;
 
 	const option_t udf_options[] = {
-		OPT_STR('T', disctype, disc type (cdrom,dvdrom,dvdram,bdre,disk,cdr,dvdr,cdrw,dvdrw)),
+		OPT_STR('T', disctype, disc type (cdrom,dvdrom,bdrom,dvdram,bdre,disk,cdr,dvdr,bdr,cdrw,dvdrw)),
 //		{ 'P', progress, display_progressbar, OPT_INT32, false, true,
 //		  display progress bar },
 		{ .name = NULL }
@@ -330,10 +332,20 @@ udf_cleanup_opts(fsinfo_t *fsopts)
 }
 
 
+#define CDRSIZE((uint64_t)   700*1024*1024)	/* small approx */
+#define CDRWSIZE   ((uint64_t)   576*1024*1024)	/* small approx */
+#define DVDRSIZE   ((uint64_t)  4488*1024*1024)	/* small approx */
+#define DVDRAMSIZE ((uint64_t)  4330*1024*1024)	/* small approx with spare */
+#define DVDRWSIZE  ((uint64_t)  4482*1024*1024)	/* small approx */
+#define BDRSIZE((uint64_t) 23866*1024*1024)	/* small approx */
+#define BDRESIZE   ((uint64_t) 23098*1024*1024)	/* small approx */
+
 int
 udf_parse_opts(const char *option, fsinfo_t *fsopts)
 {
 	option_t *udf_options = fsopts-fs_options;
+	uint64_t stdsize;
+	uint32_t set_sectorsize;
 	const char *name, *desc;
 	char buf[1024];
 	int i;
@@ -350,6 +362,9 @@ udf_parse_opts(const char *option, fsinf
 	if (udf_options[i].name == NULL)
 		abort();
 
+	set_sectorsize = 0;
+	stdsize = 0;
+
 	name = udf_options[i].name;
 	desc = udf_options[i].desc;
 	switch (udf_options[i].letter) {
@@ -358,25 +373,42 @@ udf_parse_opts(const char *option, fsinf
 			mmc_profile = 0x00;
 		} else if (strcmp(buf, dvdrom) == 0) {
 			mmc_profile = 0x10;
+		} else if (strcmp(buf, bdrom) == 0) {
+			mmc_profile = 0x40;
 		} else if (strcmp(buf, dvdram) == 0) {
 			mmc_profile = 0x12;
+			stdsize = DVDRAMSIZE;
 		} else if (strcmp(buf, bdre) == 0) {
 			mmc_profile = 0x43;
+			stdsize = BDRESIZE;
 		} else if (strcmp(buf, disk) == 0) {
 			mmc_profile = 0x01;
 		} else if (strcmp(buf, cdr) == 0) {
 			mmc_profile = 0x09;
+			stdsize = CDRSIZE;
 		} else if (strcmp(buf, dvdr) == 0) {
 			mmc_profile = 0x1b;
+			stdsize = DVDRSIZE;
+		} else if (strcmp(buf, bdr) == 0) {
+			mmc_profile = 0x41;
+			stdsize = BDRSIZE;
 		} else if (strcmp(buf, cdrw) == 0) {
 			mmc_profile = 0x0a;
+			stdsize = CDRWSIZE;
 		} else if (strcmp(buf, dvdrw) == 0) {
 			mmc_profile = 0x13;
+			stdsize = DVDRWSIZE;
 		} else {
 			errx(EINVAL, Unknown or unimplemented disc format);
 			return 0;
 		}
+		if (mmc_profile != 0x01)
+			set_sectorsize = 2048;
 	}
+	if (set_sectorsize)
+		fsopts-sectorsize = set_sectorsize;
+	if (stdsize)
+		fsopts-size = stdsize;
 	return 1;
 }
 
@@ -1122,6 +1154,7 @@ udf_enumerate_and_estimate(const char *d
 		struct udf_stats *stats)
 {
 	char path[MAXPATHLEN + 1];
+	off_t proposed_size;
 	uint32_t n, nblk;
 
 	strncpy(path, dir, sizeof(path));
@@ -1162,11 +1195,17 @@ udf_enumerate_and_estimate(const char *d
 		stats-ndatablocks += (n - nblk);
 		nblk += n - nblk;

CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 09:43:41 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Update makefs(8) man page to reflect the selection of default sector and disc
sizes based on the disc type.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.48 src/usr.sbin/makefs/makefs.8:1.49
--- src/usr.sbin/makefs/makefs.8:1.48	Mon Aug  5 18:49:58 2013
+++ src/usr.sbin/makefs/makefs.8	Tue Aug  6 09:43:41 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.48 2013/08/05 18:49:58 reinoud Exp $
+.\	$NetBSD: makefs.8,v 1.49 2013/08/06 09:43:41 reinoud Exp $
 .\
 .\ Copyright (c) 2001-2003 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 August 5, 2013
+.Dd August 6, 2013
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -401,15 +401,18 @@ The following keywords are supported:
 .It Sy disctype
 This can have the following values:
 .Bl -tag -width dvdramXbdreXdiskXXX -compact
-.It Sy cdrom , Sy dvdrom
+.It Sy cdrom , Sy dvdrom , Sy bdrom
 create a read-only fs
 .It Sy dvdram , Sy bdre , Sy disk
 create a rewritable fs without sparing for defective sectors
-.It Sy cdr , Sy dvdr
+.It Sy cdr , Sy dvdr , Sy bdr
 create a rewritable fs on once recordable media using a VAT
 .It Sy cdrw , Sy dvdrw
 create a rewritable fs with sparing for defective sectors
 .El
+When an optical media is selected here, the sectorsize and the default disc
+size is assumed unless given explicitly. For rom images the disc size is the
+minimum needed.
 .El
 .Sh SEE ALSO
 .Xr strsuftoll 3 ,



CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  6 12:12:51 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
New sentence, new line.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.49 src/usr.sbin/makefs/makefs.8:1.50
--- src/usr.sbin/makefs/makefs.8:1.49	Tue Aug  6 09:43:41 2013
+++ src/usr.sbin/makefs/makefs.8	Tue Aug  6 12:12:51 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.49 2013/08/06 09:43:41 reinoud Exp $
+.\	$NetBSD: makefs.8,v 1.50 2013/08/06 12:12:51 wiz Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -411,7 +411,8 @@ create a rewritable fs on once recordabl
 create a rewritable fs with sparing for defective sectors
 .El
 When an optical media is selected here, the sectorsize and the default disc
-size is assumed unless given explicitly. For rom images the disc size is the
+size is assumed unless given explicitly.
+For rom images the disc size is the
 minimum needed.
 .El
 .Sh SEE ALSO



CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 12:19:34 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8 udf.c

Log Message:
Allow for the logical volume label to be specified as well as the physical
volume label. Also allow the volumeset name to be specified if desired. The
syntax follows the newfs_udf(8) syntax.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.50 src/usr.sbin/makefs/makefs.8:1.51
--- src/usr.sbin/makefs/makefs.8:1.50	Tue Aug  6 12:12:51 2013
+++ src/usr.sbin/makefs/makefs.8	Tue Aug  6 12:19:34 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.50 2013/08/06 12:12:51 wiz Exp $
+.\	$NetBSD: makefs.8,v 1.51 2013/08/06 12:19:34 reinoud Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -397,10 +397,11 @@ Each of the options consists of a keywor
 .Pq Ql = ,
 and a value.
 The following keywords are supported:
+.Pp
 .Bl -tag -width optimization -compact
 .It Sy disctype
 This can have the following values:
-.Bl -tag -width dvdramXbdreXdiskXXX -compact
+.Bl -tag -width cdromXdvdromXbdromXXX -compact
 .It Sy cdrom , Sy dvdrom , Sy bdrom
 create a read-only fs
 .It Sy dvdram , Sy bdre , Sy disk
@@ -412,9 +413,17 @@ create a rewritable fs with sparing for 
 .El
 When an optical media is selected here, the sectorsize and the default disc
 size is assumed unless given explicitly.
-For rom images the disc size is the
-minimum needed.
+For rom images the disc size is the minimum needed.
 .El
+.Bl -tag -width optimization -compact
+.It Sy loglabel
+Set the logical volume label of the disc to the specified argument.
+.It Sy discid
+Set the physical volume label of the disc to the specified argument. Prepend
+the physical volume label with a volumeset label separated with a ':' if
+wanted. For strict conformance and interchange, don't set the volumeset label
+manually unless it has an unique hex number in the first 8 character
+positions.
 .Sh SEE ALSO
 .Xr strsuftoll 3 ,
 .Xr installboot 8 ,

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.7 src/usr.sbin/makefs/udf.c:1.8
--- src/usr.sbin/makefs/udf.c:1.7	Tue Aug  6 09:32:23 2013
+++ src/usr.sbin/makefs/udf.c	Tue Aug  6 12:19:34 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.7 2013/08/06 09:32:23 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.8 2013/08/06 12:19:34 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.7 2013/08/06 09:32:23 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.8 2013/08/06 12:19:34 reinoud Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -288,9 +288,11 @@ udf_prep_opts(fsinfo_t *fsopts)
 	time_t now;
 
 	const option_t udf_options[] = {
-		OPT_STR('T', disctype, disc type (cdrom,dvdrom,bdrom,dvdram,bdre,disk,cdr,dvdr,bdr,cdrw,dvdrw)),
-//		{ 'P', progress, display_progressbar, OPT_INT32, false, true,
-//		  display progress bar },
+		OPT_STR('T', disctype, disc type (cdrom,dvdrom,bdrom,
+			dvdram,bdre,disk,cdr,dvdr,bdr,cdrw,dvdrw)),
+		OPT_STR('L', loglabel, \logical volume name\),
+		OPT_STR('P', discid,   [\volset name\':']
+			\physical volume name\),
 		{ .name = NULL }
 	};
 
@@ -347,7 +349,7 @@ udf_parse_opts(const char *option, fsinf
 	uint64_t stdsize;
 	uint32_t set_sectorsize;
 	const char *name, *desc;
-	char buf[1024];
+	char buffer[1024], *buf, *colon;
 	int i;
 
 	assert(option != NULL);
@@ -355,7 +357,7 @@ udf_parse_opts(const char *option, fsinf
 	if (debug  DEBUG_FS_PARSE_OPTS)
 		printf(udf_parse_opts: got `%s'\n, option);
 
-	i = set_option(udf_options, option, buf, sizeof(buf));
+	i = set_option(udf_options, option, buffer, sizeof(buffer));
 	if (i == -1)
 		return 0;
 
@@ -365,6 +367,7 @@ udf_parse_opts(const char *option, fsinf
 	set_sectorsize = 0;
 	stdsize = 0;
 
+	buf = buffer;
 	name = udf_options[i].name;
 	desc = udf_options[i].desc;
 	switch (udf_options[i].letter) {
@@ -404,6 +407,27 @@ udf_parse_opts(const char *option, fsinf
 		}
 		if (mmc_profile != 0x01)
 			set_sectorsize = 2048;
+		break;
+	case 'L':
+		if (context.logvol_name) free(context.logvol_name);
+		context.logvol_name = strdup(buf);
+		break;
+	case 'P':
+		if ((colon = strstr(buf, :))) {
+			if (context.volset_name)
+free(context.volset_name);
+			*colon = 0;
+			context.volset_name = strdup(buf);
+			buf = colon+1;
+		}
+		if (context.primary_name)
+			free(context.primary_name);
+		if ((strstr(buf, :))) {
+			perror(primary name can't have ':' in its name);
+			return 0;
+		}
+		context.primary_name = strdup(buf);
+		break;
 	}
 	if (set_sectorsize)
 		fsopts-sectorsize = set_sectorsize;



CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Tue Aug  6 12:47:21 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8 udf.c

Log Message:
Add minimum UDF version specification to makefs(8) -t udf.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.51 src/usr.sbin/makefs/makefs.8:1.52
--- src/usr.sbin/makefs/makefs.8:1.51	Tue Aug  6 12:19:34 2013
+++ src/usr.sbin/makefs/makefs.8	Tue Aug  6 12:47:21 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.51 2013/08/06 12:19:34 reinoud Exp $
+.\	$NetBSD: makefs.8,v 1.52 2013/08/06 12:47:21 reinoud Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -424,6 +424,11 @@ the physical volume label with a volumes
 wanted. For strict conformance and interchange, don't set the volumeset label
 manually unless it has an unique hex number in the first 8 character
 positions.
+.It Sy minver
+Set the minimum UDF version to be used. Choose UDF version numbers from 0x102,
+0x150, 0x200, and 0x201. Versions 0x250 and 0x260 are currently not supported
+in
+.Nm .
 .Sh SEE ALSO
 .Xr strsuftoll 3 ,
 .Xr installboot 8 ,

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.8 src/usr.sbin/makefs/udf.c:1.9
--- src/usr.sbin/makefs/udf.c:1.8	Tue Aug  6 12:19:34 2013
+++ src/usr.sbin/makefs/udf.c	Tue Aug  6 12:47:21 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.8 2013/08/06 12:19:34 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.9 2013/08/06 12:47:21 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,7 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.8 2013/08/06 12:19:34 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.9 2013/08/06 12:47:21 reinoud Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -97,7 +97,7 @@ udf_write_sector(void *sector, uint32_t 
 	ret = pwrite(fd, sector, context.sector_size, wpos);
 	if (ret == -1)
 		return errno;
-	if (ret  context.sector_size)
+	if (ret  (int) context.sector_size)
 		return EIO;
 	return 0;
 }
@@ -272,10 +272,10 @@ udf_update_trackinfo(struct mmc_discinfo
 	{ letter, name, NULL, OPT_STRBUF, 0, 0, desc }
 
 #define OPT_NUM(letter, name, field, min, max, desc) \
-	{ letter, name, diskStructure-field, \
-	  sizeof(diskStructure-field) == 8 ? OPT_INT64 : \
-	  (sizeof(diskStructure-field) == 4 ? OPT_INT32 : \
-	  (sizeof(diskStructure-field) == 2 ? OPT_INT16 : OPT_INT8)), \
+	{ letter, name, context.field, \
+	  sizeof(context.field) == 8 ? OPT_INT64 : \
+	  (sizeof(context.field) == 4 ? OPT_INT32 : \
+	  (sizeof(context.field) == 2 ? OPT_INT16 : OPT_INT8)), \
 	  min, max, desc }
 
 #define OPT_BOOL(letter, name, field, desc) \
@@ -291,8 +291,15 @@ udf_prep_opts(fsinfo_t *fsopts)
 		OPT_STR('T', disctype, disc type (cdrom,dvdrom,bdrom,
 			dvdram,bdre,disk,cdr,dvdr,bdr,cdrw,dvdrw)),
 		OPT_STR('L', loglabel, \logical volume name\),
-		OPT_STR('P', discid,   [\volset name\':']
-			\physical volume name\),
+		OPT_STR('P', discid,   \[volset name ':']
+			physical volume name\),
+		OPT_NUM('t', tz, gmtoff, -24, 24, timezone),
+		OPT_STR('v', minver, minimum UDF version in either 
+			``0x201'' or ``2.01'' format),
+#if notyet
+		OPT_STR('V', maxver, maximum UDF version in either 
+			``0x201'' or ``2.01'' format),
+#endif
 		{ .name = NULL }
 	};
 
@@ -314,7 +321,7 @@ udf_prep_opts(fsinfo_t *fsopts)
 
 	/* minimum and maximum UDF versions we advise */
 	context.min_udf = 0x102;
-	context.max_udf = 0x201;
+	context.max_udf = 0x201;	/* 0x250 and 0x260 are not ready */
 
 	/* use user's time zone as default */
 	(void)time(now);
@@ -334,6 +341,10 @@ udf_cleanup_opts(fsinfo_t *fsopts)
 }
 
 
+/* - included from newfs_udf.c -- */
+/* - */
+
+
 #define CDRSIZE((uint64_t)   700*1024*1024)	/* small approx */
 #define CDRWSIZE   ((uint64_t)   576*1024*1024)	/* small approx */
 #define DVDRSIZE   ((uint64_t)  4488*1024*1024)	/* small approx */
@@ -341,7 +352,6 @@ udf_cleanup_opts(fsinfo_t *fsopts)
 #define DVDRWSIZE  ((uint64_t)  4482*1024*1024)	/* small approx */
 #define BDRSIZE((uint64_t) 23866*1024*1024)	/* small approx */
 #define BDRESIZE   ((uint64_t) 23098*1024*1024)	/* small approx */
-
 int
 udf_parse_opts(const char *option, fsinfo_t *fsopts)
 {
@@ -423,11 +433,20 @@ udf_parse_opts(const char *option, fsinf
 		if (context.primary_name)
 			free(context.primary_name);
 		if ((strstr(buf, :))) {
-			perror(primary name can't have ':' in its name);
+			errx(EINVAL, primary name can't have ':' in its name);
 			return 0;
 		}
 		context.primary_name = strdup(buf);
 		break;
+	case 'v':
+		context.min_udf = a_udf_version(buf, min_udf);
+		if (context.min_udf  0x201) {
+			errx(EINVAL, maximum supported version is UDF 2.01);
+			return 

CVS commit: src/usr.sbin/makefs

2013-08-06 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Aug  6 20:16:54 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
New sentence, new line.
Use one list instead of two consecutive ones.
Add .El to end list.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.52 src/usr.sbin/makefs/makefs.8:1.53
--- src/usr.sbin/makefs/makefs.8:1.52	Tue Aug  6 12:47:21 2013
+++ src/usr.sbin/makefs/makefs.8	Tue Aug  6 20:16:54 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.52 2013/08/06 12:47:21 reinoud Exp $
+.\	$NetBSD: makefs.8,v 1.53 2013/08/06 20:16:54 wiz Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -414,21 +414,22 @@ create a rewritable fs with sparing for 
 When an optical media is selected here, the sectorsize and the default disc
 size is assumed unless given explicitly.
 For rom images the disc size is the minimum needed.
-.El
-.Bl -tag -width optimization -compact
 .It Sy loglabel
 Set the logical volume label of the disc to the specified argument.
 .It Sy discid
-Set the physical volume label of the disc to the specified argument. Prepend
-the physical volume label with a volumeset label separated with a ':' if
-wanted. For strict conformance and interchange, don't set the volumeset label
+Set the physical volume label of the disc to the specified argument.
+Prepend the physical volume label with a volumeset label separated
+with a ':' if wanted.
+For strict conformance and interchange, don't set the volumeset label
 manually unless it has an unique hex number in the first 8 character
 positions.
 .It Sy minver
-Set the minimum UDF version to be used. Choose UDF version numbers from 0x102,
-0x150, 0x200, and 0x201. Versions 0x250 and 0x260 are currently not supported
+Set the minimum UDF version to be used.
+Choose UDF version numbers from 0x102, 0x150, 0x200, and 0x201.
+Versions 0x250 and 0x260 are currently not supported
 in
 .Nm .
+.El
 .Sh SEE ALSO
 .Xr strsuftoll 3 ,
 .Xr installboot 8 ,



CVS commit: src/usr.sbin/makefs

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 14:41:57 UTC 2013

Modified Files:
src/usr.sbin/makefs: Makefile makefs.8 makefs.c makefs.h
Added Files:
src/usr.sbin/makefs: udf.c
src/usr.sbin/makefs/udf: Makefile.inc

Log Message:
Implement `makefs -t udf'.

Formatting options may be enhanced to make it more in line with newfs_udf on
say labeling.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.sbin/makefs/Makefile
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.49 -r1.50 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makefs/udf.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makefs/udf/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/Makefile
diff -u src/usr.sbin/makefs/Makefile:1.35 src/usr.sbin/makefs/Makefile:1.36
--- src/usr.sbin/makefs/Makefile:1.35	Sun Jan 27 20:05:46 2013
+++ src/usr.sbin/makefs/Makefile	Mon Aug  5 14:41:57 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2013/01/27 20:05:46 christos Exp $
+#	$NetBSD: Makefile,v 1.36 2013/08/05 14:41:57 reinoud Exp $
 #
 
 WARNS?=	5
@@ -6,7 +6,7 @@ WARNS?=	5
 .include bsd.own.mk
 
 PROG=	makefs
-SRCS=	cd9660.c chfs.c ffs.c v7fs.c msdos.c \
+SRCS=	cd9660.c chfs.c ffs.c v7fs.c msdos.c udf.c\
 	getid.c \
 	makefs.c misc.c \
 	pack_dev.c \
@@ -26,6 +26,7 @@ CPPFLAGS+=	-I${.CURDIR} -I${MKNODSRC} -I
 .include ${.CURDIR}/ffs/Makefile.inc
 .include ${.CURDIR}/v7fs/Makefile.inc
 .include ${.CURDIR}/msdos/Makefile.inc
+.include ${.CURDIR}/udf/Makefile.inc
 
 .if !defined(HOSTPROG)
 DPADD+= ${LIBUTIL}
@@ -33,3 +34,4 @@ LDADD+= -lutil
 .endif
 
 .include bsd.prog.mk
+# DO NOT DELETE

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.45 src/usr.sbin/makefs/makefs.8:1.46
--- src/usr.sbin/makefs/makefs.8:1.45	Sun Feb  3 06:16:53 2013
+++ src/usr.sbin/makefs/makefs.8	Mon Aug  5 14:41:57 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.45 2013/02/03 06:16:53 christos Exp $
+.\	$NetBSD: makefs.8,v 1.46 2013/08/05 14:41:57 reinoud Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -215,6 +215,8 @@ Chip flash file system.
 FAT12, FAT16, or FAT32 file system.
 .It Sy v7fs
 7th Edition(V7) file system.
+.It Sy udf
+ISO/Ecma UDF file system.
 .El
 .It Fl x
 Exclude file system nodes not explicitly listed in the specfile.
@@ -388,6 +390,32 @@ PDP endian.
 Display a progress meter for the file system construction and file
 population.
 .El
+.Ss UDF-specific options
+.Sy udf
+images have ffs-specific optional parameters that may be provided.
+Each of the options consists of a keyword, an equal sign
+.Pq Ql = ,
+and a value.
+The following keywords are supported:
+.Pp
+.Bl -tag -width optimization -offset indent -compact
+.It Sy T
+disctype. It can have the values
+.Bl -tag -width 3n -offset indent -compact
+.It cdrom,
+.It dvdrom
+create a read-only fs
+.It dvdram,
+.It bdre,
+.It disk
+create a rewriteable fs without sparing
+.It cdr,
+.It dvdr
+create a rewritable fs on once recordable media using a VAT
+.It cdrw,
+.It dvdrw
+create a rewritable fs with sparing for defective sectors
+.It 
 .Sh SEE ALSO
 .Xr strsuftoll 3 ,
 .Xr installboot 8 ,

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.49 src/usr.sbin/makefs/makefs.c:1.50
--- src/usr.sbin/makefs/makefs.c:1.49	Sun Feb  3 06:16:53 2013
+++ src/usr.sbin/makefs/makefs.c	Mon Aug  5 14:41:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.49 2013/02/03 06:16:53 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.49 2013/02/03 06:16:53 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.50 2013/08/05 14:41:57 reinoud Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -81,6 +81,7 @@ static fstype_t fstypes[] = {
 	ENTRY(chfs),
 	ENTRY(v7fs),
 	ENTRY(msdos),
+	ENTRY(udf),
 	{ .type = NULL	},
 };
 

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.34 src/usr.sbin/makefs/makefs.h:1.35
--- src/usr.sbin/makefs/makefs.h:1.34	Sun Feb  3 06:16:53 2013
+++ src/usr.sbin/makefs/makefs.h	Mon Aug  5 14:41:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.34 2013/02/03 06:16:53 christos Exp $	*/
+/*	$NetBSD: makefs.h,v 1.35 2013/08/05 14:41:57 reinoud Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -92,6 +92,7 @@ typedef struct {
 	uint32_t	 nlink;		/* number of links to this entry */
 	enum fi_flags	 flags;		/* flags used by fs specific code */
 	struct stat	 st;		/* stat entry */
+	void		*fsuse;		/* for storing FS dependent info */
 } fsinode;
 
 typedef struct _fsnode {
@@ -194,6 +195,7 @@ DECLARE_FUN(cd9660);
 DECLARE_FUN(chfs);
 

CVS commit: src/usr.sbin/makefs

2013-08-05 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Mon Aug  5 14:50:32 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Sort. Improve table formatting.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.46 src/usr.sbin/makefs/makefs.8:1.47
--- src/usr.sbin/makefs/makefs.8:1.46	Mon Aug  5 14:41:57 2013
+++ src/usr.sbin/makefs/makefs.8	Mon Aug  5 14:50:32 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.46 2013/08/05 14:41:57 reinoud Exp $
+.\	$NetBSD: makefs.8,v 1.47 2013/08/05 14:50:32 wiz Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -189,13 +189,13 @@ 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 .
 .\ XXX: next line also true for cd9660?
 Defaults to 512.
-.It Fl r
-When merging multiple directories replace duplicate files with the last found.
 .It Fl s Ar image-size
 Set the size of the file system image to
 .Ar image-size .
@@ -392,30 +392,25 @@ population.
 .El
 .Ss UDF-specific options
 .Sy udf
-images have ffs-specific optional parameters that may be provided.
+images have udf-specific optional parameters that may be provided.
 Each of the options consists of a keyword, an equal sign
 .Pq Ql = ,
 and a value.
 The following keywords are supported:
-.Pp
-.Bl -tag -width optimization -offset indent -compact
-.It Sy T
-disctype. It can have the values
-.Bl -tag -width 3n -offset indent -compact
-.It cdrom,
-.It dvdrom
+.Bl -tag -width optimization -compact
+.It Sy disctype
+This can have the following values:
+.Bl -tag -width dvdramXbdreXdiskXXX -compact
+.It Sy cdrom , Sy dvdrom
 create a read-only fs
-.It dvdram,
-.It bdre,
-.It disk
-create a rewriteable fs without sparing
-.It cdr,
-.It dvdr
+.It Sy dvdram , Sy bdre , Sy disk
+create a rewritable fs without sparing for defective sectors
+.It Sy cdr , Sy dvdr
 create a rewritable fs on once recordable media using a VAT
-.It cdrw,
-.It dvdrw
+.It Sy cdrw , Sy dvdrw
 create a rewritable fs with sparing for defective sectors
-.It 
+.El
+.El
 .Sh SEE ALSO
 .Xr strsuftoll 3 ,
 .Xr installboot 8 ,



CVS commit: src/usr.sbin/makefs

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 16:43:46 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c

Log Message:
Make memset() usage consequent in using the right types


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makefs/udf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.1 src/usr.sbin/makefs/udf.c:1.2
--- src/usr.sbin/makefs/udf.c:1.1	Mon Aug  5 14:41:57 2013
+++ src/usr.sbin/makefs/udf.c	Mon Aug  5 16:43:46 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.1 2013/08/05 14:41:57 reinoud Exp $ */
+/* $NetBSD: udf.c,v 1.2 2013/08/05 16:43:46 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -28,7 +28,7 @@
 
 #include sys/cdefs.h
 #ifndef lint
-__RCSID($NetBSD: udf.c,v 1.1 2013/08/05 14:41:57 reinoud Exp $);
+__RCSID($NetBSD: udf.c,v 1.2 2013/08/05 16:43:46 reinoud Exp $);
 #endif /* not lint */
 
 #define _EXPOSE_MMC
@@ -156,7 +156,7 @@ udf_emulate_discinfo(fsinfo_t *fsopts, s
 {
 	off_t sectors;
 
-	memset(di, 0, sizeof(struct mmc_discinfo));
+	memset(di, 0, sizeof(*di));
 
 	/* file support */
 	if ((mmc_emuprofile != 0x01)  (fsopts-sectorsize != 2048))
@@ -592,7 +592,10 @@ udf_append_file_mapping(union dscrptr *d
 	size = UDF_EXT_LEN(udf_rw32(piece-len));
 
 	/* extract last entry as a long_ad */
-	memset(last_piece, 0, sizeof(struct long_ad));
+	memset(last_piece, 0, sizeof(last_piece));
+	last_len  = 0;
+	last_lb_num   = 0;
+	last_part_num = 0;
 	if (l_ad != 0) {
 		if (use_shorts) {
 			assert(cur_alloc == UDF_ICB_SHORT_ALLOC);
@@ -1183,7 +1186,7 @@ udf_makefs(const char *image, const char
 	error = 1;
 
 	/* estimate the amount of space needed */
-	memset(stats, 0, sizeof(struct udf_stats));
+	memset(stats, 0, sizeof(stats));
 	udf_enumerate_and_estimate(dir, root, fsopts, stats);
 
 	printf(Calculated size of `%s': %lld bytes, %ld inodes\n,



CVS commit: src/usr.sbin/makefs

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 18:44:16 UTC 2013

Modified Files:
src/usr.sbin/makefs: udf.c
Added Files:
src/usr.sbin/makefs/udf: cdio_mmc_structs.h

Log Message:
Revert joergs patch and make it compile in both the normal as in the tools
environment by providing the MMC datastructures separately for compat.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makefs/udf.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/makefs/udf/cdio_mmc_structs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf.c
diff -u src/usr.sbin/makefs/udf.c:1.3 src/usr.sbin/makefs/udf.c:1.4
--- src/usr.sbin/makefs/udf.c:1.3	Mon Aug  5 17:12:04 2013
+++ src/usr.sbin/makefs/udf.c	Mon Aug  5 18:44:16 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: udf.c,v 1.3 2013/08/05 17:12:04 joerg Exp $ */
+/* $NetBSD: udf.c,v 1.4 2013/08/05 18:44:16 reinoud Exp $ */
 
 /*
  * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
@@ -30,9 +30,7 @@
 #endif
 
 #include sys/cdefs.h
-__RCSID($NetBSD: udf.c,v 1.3 2013/08/05 17:12:04 joerg Exp $);
-
-#define _EXPOSE_MMC
+__RCSID($NetBSD: udf.c,v 1.4 2013/08/05 18:44:16 reinoud Exp $);
 
 #include stdio.h
 #include stdlib.h
@@ -45,11 +43,15 @@ __RCSID($NetBSD: udf.c,v 1.3 2013/08/05
 #include fcntl.h
 #include sys/types.h
 #include sys/param.h
+#include sys/stat.h
+#include util.h
+
 #if !HAVE_NBTOOL_CONFIG_H
+#define _EXPOSE_MMC
 #include sys/cdio.h
+#else
+#include udf/cdio_mmc_structs.h
 #endif
-#include sys/stat.h
-#include util.h
 
 #include makefs.h
 #include udf_create.h
@@ -66,9 +68,7 @@ __RCSID($NetBSD: udf.c,v 1.3 2013/08/05
 /* global variables describing disc and format requests */
 int	 fd;/* device: file descriptor */
 char	*dev;/* device: name		   */
-#if !HAVE_NBTOOL_CONFIG_H
 struct mmc_discinfo mmc_discinfo;	/* device: disc info	   */
-#endif
 
 char	*format_str;			/* format: string representation */
 int	 format_flags;			/* format: attribute flags	 */
@@ -155,7 +155,6 @@ udf_dump_discinfo(struct mmc_discinfo *d
 
 /* - */
 
-#if !HAVE_NBTOOL_CONFIG_H
 static int
 udf_emulate_discinfo(fsinfo_t *fsopts, struct mmc_discinfo *di,
 		int mmc_emuprofile)
@@ -266,16 +265,6 @@ udf_update_trackinfo(struct mmc_discinfo
 
 	return 0;
 }
-#else
-off_t sectors;
-
-static int
-udf_emulate_discinfo(fsinfo_t *fsopts, int mmc_emuprofile)
-{
-	sectors = fsopts-size / fsopts-sectorsize;
-	return 0;
-}
-#endif
 
 #define OPT_STR(letter, name, desc)  \
 	{ letter, name, NULL, OPT_STRBUF, 0, 0, desc }
@@ -1184,11 +1173,7 @@ udf_makefs(const char *image, const char
 	int error;
 
 	/* determine format */
-#if !HAVE_NBTOOL_CONFIG_H
 	udf_emulate_discinfo(fsopts, mmc_discinfo, mmc_profile);
-#else
-	udf_emulate_discinfo(fsopts, mmc_profile);
-#endif
 	printf(req_enable %d, req_disable %d\n, req_enable, req_disable);
 
 	context.sector_size = fsopts-sectorsize;
@@ -1231,11 +1216,7 @@ udf_makefs(const char *image, const char
 	meta_fract = ((int) ((meta_fract + 0.005)*100.0)) / 100;
 
 	/* update mmc info but now with correct size */
-#if !HAVE_NBTOOL_CONFIG_H
 	udf_emulate_discinfo(fsopts, mmc_discinfo, mmc_profile);
-#else
-	udf_emulate_discinfo(fsopts, mmc_profile);
-#endif
 
 	udf_do_newfs_prefix();
 

Added files:

Index: src/usr.sbin/makefs/udf/cdio_mmc_structs.h
diff -u /dev/null src/usr.sbin/makefs/udf/cdio_mmc_structs.h:1.1
--- /dev/null	Mon Aug  5 18:44:16 2013
+++ src/usr.sbin/makefs/udf/cdio_mmc_structs.h	Mon Aug  5 18:44:16 2013
@@ -0,0 +1,163 @@
+/* $NetBSD: cdio_mmc_structs.h,v 1.1 2013/08/05 18:44:16 reinoud Exp $ */
+
+/*
+ * Copyright (c) 2006, 2008, 2013 Reinoud Zandijk
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 

CVS commit: src/usr.sbin/makefs/udf

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 18:45:00 UTC 2013

Modified Files:
src/usr.sbin/makefs/udf: Makefile.inc

Log Message:
Cleanup makefile for makefs


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/makefs/udf/Makefile.inc

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/udf/Makefile.inc
diff -u src/usr.sbin/makefs/udf/Makefile.inc:1.1 src/usr.sbin/makefs/udf/Makefile.inc:1.2
--- src/usr.sbin/makefs/udf/Makefile.inc:1.1	Mon Aug  5 14:41:57 2013
+++ src/usr.sbin/makefs/udf/Makefile.inc	Mon Aug  5 18:45:00 2013
@@ -1,8 +1,7 @@
-#	$NetBSD: Makefile.inc,v 1.1 2013/08/05 14:41:57 reinoud Exp $
+#	$NetBSD: Makefile.inc,v 1.2 2013/08/05 18:45:00 reinoud Exp $
 #
 
-SYSFS=	${NETBSDSRCDIR}/sys/fs
-UDF=	${SYSFS}/udf
+UDF=	${NETBSDSRCDIR}/sys/fs/udf
 UDF_NEWFS=	${NETBSDSRCDIR}/sbin/newfs_udf
 FSCK=	${NETBSDSRCDIR}/sbin/fsck	# use progress meter.
 
@@ -12,9 +11,3 @@ CPPFLAGS+= -I${UDF} -I${UDF_NEWFS} -I${F
 
 SRCS += udf_create.c udf_write.c udf_osta.c
 
-#SRCS += main.c		# newfs
-#.if !defined(HOSTPROG)
-#SRCS += progress.c	# progress bar (fsck)
-#.endif
-
-#SRCS += v7fs_estimate.c v7fs_populate.c



CVS commit: src/usr.sbin/makefs

2013-08-05 Thread Reinoud Zandijk
Module Name:src
Committed By:   reinoud
Date:   Mon Aug  5 18:49:58 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
Note that i added the UDF support to makefs(8) and bump data


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.47 src/usr.sbin/makefs/makefs.8:1.48
--- src/usr.sbin/makefs/makefs.8:1.47	Mon Aug  5 14:50:32 2013
+++ src/usr.sbin/makefs/makefs.8	Mon Aug  5 18:49:58 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.47 2013/08/05 14:50:32 wiz Exp $
+.\	$NetBSD: makefs.8,v 1.48 2013/08/05 18:49:58 reinoud Exp $
 .\
 .\ Copyright (c) 2001-2003 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 February 2, 2013
+.Dd August 5, 2013
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -437,3 +437,5 @@ utility appeared in
 (chfs support).
 .An Christos Zoulas
 (msdos support).
+.An Reinoud Zandijk
+(udf support).



CVS commit: src/usr.sbin/makefs

2013-02-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb  2 20:42:02 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8 makefs.c makefs.h
src/usr.sbin/makefs/ffs: buf.c

Log Message:
add and document offset.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.47 -r1.48 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.32 -r1.33 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makefs/ffs/buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.43 src/usr.sbin/makefs/makefs.8:1.44
--- src/usr.sbin/makefs/makefs.8:1.43	Mon Jan 28 20:52:04 2013
+++ src/usr.sbin/makefs/makefs.8	Sat Feb  2 15:42:02 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.43 2013/01/29 01:52:04 christos Exp $
+.\	$NetBSD: makefs.8,v 1.44 2013/02/02 20:42:02 christos Exp $
 .\
 .\ Copyright (c) 2001-2003 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 27, 2013
+.Dd February 2, 2013
 .Dt MAKEFS 8
 .Os
 .Sh NAME
@@ -50,6 +50,7 @@
 .Op Fl M Ar minimum-size
 .Op Fl m Ar maximum-size
 .Op Fl N Ar userdb-dir
+.Op Fl O Ar offset
 .Op Fl o Ar fs-options
 .Op Fl S Ar sector-size
 .Op Fl s Ar image-size
@@ -176,6 +177,13 @@ rather than using the results from the s
 and
 .Xr getgrnam 3
 (and related) library calls.
+.It Fl O Ar offset
+Instead of creating the filesystem at the beginning of the file, start
+at offset.
+Valid only for
+.Sy ffs
+and
+.Sy msdos .
 .It Fl o Ar fs-options
 Set file system specific options.
 .Ar fs-options

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.47 src/usr.sbin/makefs/makefs.c:1.48
--- src/usr.sbin/makefs/makefs.c:1.47	Fri Feb  1 09:02:17 2013
+++ src/usr.sbin/makefs/makefs.c	Sat Feb  2 15:42:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.47 2013/02/01 14:02:17 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.48 2013/02/02 20:42:02 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.47 2013/02/01 14:02:17 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.48 2013/02/02 20:42:02 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
 	start_time.tv_sec = start.tv_sec;
 	start_time.tv_nsec = start.tv_usec * 1000;
 
-	while ((ch = getopt(argc, argv, B:b:d:f:F:M:m:N:o:s:S:t:xZ)) != -1) {
+	while ((ch = getopt(argc, argv, B:b:d:f:F:M:m:N:O:o:s:S:t:xZ)) != -1) {
 		switch (ch) {
 
 		case 'B':
@@ -195,6 +195,11 @@ main(int argc, char *argv[])
 			fsoptions.maxsize =
 			strsuftoll(maximum size, optarg, 1LL, LLONG_MAX);
 			break;
+
+		case 'O':
+			fsoptions.offset = 
+			strsuftoll(offset, optarg, 0LL, LLONG_MAX);
+			break;
 			
 		case 'o':
 		{
@@ -407,8 +412,8 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
 	prog = getprogname();
 	fprintf(stderr,
 Usage: %s [-xZ] [-B endian] [-b free-blocks] [-d debug-mask]\n
-\t[-F mtree-specfile] [-f free-files] [-M minimum-size]\n
-\t[-m maximum-size] [-N userdb-dir] [-o fs-options] [-S sector-size]\n
+\t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n
+\t[-N userdb-dir] [-O offset] [-o fs-options] [-S sector-size]\n
 \t[-s image-size] [-t fs-type] image-file directory [extra-directory ...]\n,
 	prog);
 

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.32 src/usr.sbin/makefs/makefs.h:1.33
--- src/usr.sbin/makefs/makefs.h:1.32	Wed Jan 30 14:19:19 2013
+++ src/usr.sbin/makefs/makefs.h	Sat Feb  2 15:42:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.32 2013/01/30 19:19:19 christos Exp $	*/
+/*	$NetBSD: makefs.h,v 1.33 2013/02/02 20:42:02 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -157,8 +157,9 @@ typedef struct makefs_fsinfo {
 	off_t	minsize;	/* minimum size image should be */
 	off_t	maxsize;	/* maximum size image can be */
 	off_t	freefiles;	/* free file entries to leave */
-	int	freefilepc;	/* free file % */
 	off_t	freeblocks;	/* free blocks to leave */
+	off_t	offset;		/* offset from start of file */
+	int	freefilepc;	/* free file % */
 	int	freeblockpc;	/* free block % */
 	int	needswap;	/* non-zero if byte swapping needed */
 	int	sectorsize;	/* sector size */

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.19 src/usr.sbin/makefs/ffs/buf.c:1.20
--- src/usr.sbin/makefs/ffs/buf.c:1.19	Wed Jan 30 14:19:19 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Sat Feb  2 15:42:02 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.19 2013/01/30 19:19:19 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.20 2013/02/02 20:42:02 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, 

CVS commit: src/usr.sbin/makefs

2013-02-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Feb  3 03:21:21 UTC 2013

Modified Files:
src/usr.sbin/makefs: ffs.c msdos.c
src/usr.sbin/makefs/ffs: buf.c mkfs.c

Log Message:
- more changes to make -O work
- fix err* calls.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makefs/msdos.c
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/makefs/ffs/buf.c
cvs rdiff -u -r1.26 -r1.27 src/usr.sbin/makefs/ffs/mkfs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.59 src/usr.sbin/makefs/ffs.c:1.60
--- src/usr.sbin/makefs/ffs.c:1.59	Wed Jan 30 14:19:19 2013
+++ src/usr.sbin/makefs/ffs.c	Sat Feb  2 22:21:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.59 2013/01/30 19:19:19 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.60 2013/02/03 03:21:21 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs.c,v 1.59 2013/01/30 19:19:19 christos Exp $);
+__RCSID($NetBSD: ffs.c,v 1.60 2013/02/03 03:21:21 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -466,13 +466,15 @@ ffs_create_image(const char *image, fsin
 	char	*buf;
 	int	i, bufsize;
 	off_t	bufrem;
+	int	oflags = O_RDWR | O_CREAT;
 
 	assert (image != NULL);
 	assert (fsopts != NULL);
 
 		/* create image */
-	if ((fsopts-fd = open(image, O_RDWR | O_CREAT | O_TRUNC, 0666))
-	== -1) {
+	if (fsopts-offset == 0)
+		oflags |= O_TRUNC;
+	if ((fsopts-fd = open(image, oflags, 0666)) == -1) {
 		warn(Can't open `%s' for writing, image);
 		return (-1);
 	}
@@ -500,6 +502,12 @@ ffs_create_image(const char *image, fsin
 		}
 	}
 
+	if (fsopts-offset != 0)
+		if (lseek(fsopts-fd, fsopts-offset, SEEK_SET) == -1) {
+			warn(can't seek);
+			return -1;
+		}
+
 	if ((debug  DEBUG_FS_CREATE_IMAGE)  fsopts-sparse == 0)
 		printf(
 		zero-ing image `%s', %lld sectors, using %d byte chunks\n,

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.13 src/usr.sbin/makefs/msdos.c:1.14
--- src/usr.sbin/makefs/msdos.c:1.13	Wed Jan 30 14:19:19 2013
+++ src/usr.sbin/makefs/msdos.c	Sat Feb  2 22:21:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.13 2013/01/30 19:19:19 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.14 2013/02/03 03:21:21 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: msdos.c,v 1.13 2013/01/30 19:19:19 christos Exp $);
+__RCSID($NetBSD: msdos.c,v 1.14 2013/02/03 03:21:21 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -149,6 +149,7 @@ msdos_makefs(const char *image, const ch
 	 * Is minsize right here?
 	 */
 	msdos_opt-create_size = MAX(msdos_opt-create_size, fsopts-minsize);
+	msdos_opt-offset = fsopts-offset;
 	if (msdos_opt-bytes_per_sector == 0) {
 		if (fsopts-sectorsize == -1)
 			fsopts-sectorsize = 512;

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.20 src/usr.sbin/makefs/ffs/buf.c:1.21
--- src/usr.sbin/makefs/ffs/buf.c:1.20	Sat Feb  2 15:42:02 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Sat Feb  2 22:21:21 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.20 2013/02/02 20:42:02 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.21 2013/02/03 03:21:21 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: buf.c,v 1.20 2013/02/02 20:42:02 christos Exp $);
+__RCSID($NetBSD: buf.c,v 1.21 2013/02/03 03:21:21 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -78,18 +78,18 @@ bread(struct vnode *vp, daddr_t blkno, i
 		(long long)(*bpp)-b_blkno, (long long) offset,
 		(*bpp)-b_bcount);
 	if (lseek((*bpp)-b_fs-fd, offset, SEEK_SET) == -1)
-		err(1, bread: lseek %lld (%lld),
+		err(1, %s: lseek %lld (%lld), __func__,
 		(long long)(*bpp)-b_blkno, (long long)offset);
 	rv = read((*bpp)-b_fs-fd, (*bpp)-b_data, (*bpp)-b_bcount);
 	if (debug  DEBUG_BUF_BREAD)
-		printf(bread: read %ld (%lld) returned %d\n,
-		(*bpp)-b_bcount, (long long)offset, (int)rv);
+		printf(bread: read %ld (%lld) returned %zd\n,
+		(*bpp)-b_bcount, (long long)offset, rv);
 	if (rv == -1)/* read error */
-		err(1, bread: read %ld (%lld) returned %d,
-		(*bpp)-b_bcount, (long long)offset, (int)rv);
+		err(1, %s: read %ld (%lld) returned %zd, __func__,
+		(*bpp)-b_bcount, (long long)offset, rv);
 	else if (rv != (*bpp)-b_bcount)	/* short read */
-		err(1, bread: read %ld (%lld) returned %d,
-		(*bpp)-b_bcount, (long long)offset, (int)rv);
+		err(1, %s: read %ld (%lld) returned %zd, __func__,
+		(*bpp)-b_bcount, (long long)offset, rv);
 	else
 		return (0);
 }

Index: 

CVS commit: src/usr.sbin/makefs

2013-02-02 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Feb  3 06:16:53 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8 makefs.c makefs.h walk.c

Log Message:
add a replace flag so we can overlay exiting files when we merge directories.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/makefs/makefs.8
cvs rdiff -u -r1.48 -r1.49 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.33 -r1.34 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/makefs/walk.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.44 src/usr.sbin/makefs/makefs.8:1.45
--- src/usr.sbin/makefs/makefs.8:1.44	Sat Feb  2 15:42:02 2013
+++ src/usr.sbin/makefs/makefs.8	Sun Feb  3 01:16:53 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.44 2013/02/02 20:42:02 christos Exp $
+.\	$NetBSD: makefs.8,v 1.45 2013/02/03 06:16:53 christos Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -41,7 +41,7 @@
 .Nd create a file system image from a directory tree
 .Sh SYNOPSIS
 .Nm
-.Op Fl xZ
+.Op Fl rxZ
 .Op Fl B Ar endian
 .Op Fl b Ar free-blocks
 .Op Fl d Ar debug-mask
@@ -194,6 +194,8 @@ Set the file system sector size to
 .Ar sector-size .
 .\ XXX: next line also true for cd9660?
 Defaults to 512.
+.It Fl r
+When merging multiple directories replace duplicate files with the last found.
 .It Fl s Ar image-size
 Set the size of the file system image to
 .Ar image-size .

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.48 src/usr.sbin/makefs/makefs.c:1.49
--- src/usr.sbin/makefs/makefs.c:1.48	Sat Feb  2 15:42:02 2013
+++ src/usr.sbin/makefs/makefs.c	Sun Feb  3 01:16:53 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.48 2013/02/02 20:42:02 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.49 2013/02/03 06:16:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.48 2013/02/02 20:42:02 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.49 2013/02/03 06:16:53 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
 	start_time.tv_sec = start.tv_sec;
 	start_time.tv_nsec = start.tv_usec * 1000;
 
-	while ((ch = getopt(argc, argv, B:b:d:f:F:M:m:N:O:o:s:S:t:xZ)) != -1) {
+	while ((ch = getopt(argc, argv, B:b:d:f:F:M:m:N:O:o:rs:S:t:xZ)) != -1) {
 		switch (ch) {
 
 		case 'B':
@@ -214,6 +214,10 @@ main(int argc, char *argv[])
 			break;
 		}
 
+		case 'r':
+			fsoptions.replace = 1;
+			break;
+
 		case 's':
 			fsoptions.minsize = fsoptions.maxsize =
 			strsuftoll(size, optarg, 1LL, LLONG_MAX);
@@ -268,7 +272,7 @@ main(int argc, char *argv[])
 
 /* walk the tree */
 	TIMER_START(start);
-	root = walk_dir(argv[1], ., NULL, NULL);
+	root = walk_dir(argv[1], ., NULL, NULL, fsoptions.replace);
 	TIMER_RESULTS(start, walk_dir);
 
 	/* append extra directory */
@@ -279,7 +283,7 @@ main(int argc, char *argv[])
 		if (!S_ISDIR(sb.st_mode))
 			errx(1, %s: not a directory, argv[i]);
 		TIMER_START(start);
-		root = walk_dir(argv[i], ., NULL, root);
+		root = walk_dir(argv[i], ., NULL, root, fsoptions.replace);
 		TIMER_RESULTS(start, walk_dir2);
 	}
 
@@ -411,7 +415,7 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
 
 	prog = getprogname();
 	fprintf(stderr,
-Usage: %s [-xZ] [-B endian] [-b free-blocks] [-d debug-mask]\n
+Usage: %s [-rxZ] [-B endian] [-b free-blocks] [-d debug-mask]\n
 \t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n
 \t[-N userdb-dir] [-O offset] [-o fs-options] [-S sector-size]\n
 \t[-s image-size] [-t fs-type] image-file directory [extra-directory ...]\n,

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.33 src/usr.sbin/makefs/makefs.h:1.34
--- src/usr.sbin/makefs/makefs.h:1.33	Sat Feb  2 15:42:02 2013
+++ src/usr.sbin/makefs/makefs.h	Sun Feb  3 01:16:53 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.33 2013/02/02 20:42:02 christos Exp $	*/
+/*	$NetBSD: makefs.h,v 1.34 2013/02/03 06:16:53 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -164,6 +164,7 @@ typedef struct makefs_fsinfo {
 	int	needswap;	/* non-zero if byte swapping needed */
 	int	sectorsize;	/* sector size */
 	int	sparse;		/* sparse image, don't fill it with zeros */
+	int	replace;	/* replace files when merging */
 
 	void	*fs_specific;	/* File system specific additions. */
 	option_t *fs_options;	/* File system specific options */
@@ -178,7 +179,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 *);
+fsnode *	walk_dir(const char *, const char *, fsnode *, 

CVS commit: src/usr.sbin/makefs

2013-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb  1 14:00:33 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
while it is studly to play with token pasting, passing directly the type
is a lot more readable.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.45 src/usr.sbin/makefs/makefs.c:1.46
--- src/usr.sbin/makefs/makefs.c:1.45	Tue Jan 29 21:53:54 2013
+++ src/usr.sbin/makefs/makefs.c	Fri Feb  1 09:00:33 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.45 2013/01/30 02:53:54 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.46 2013/02/01 14:00:33 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.45 2013/01/30 02:53:54 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.46 2013/02/01 14:00:33 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -327,13 +327,12 @@ set_option_var(const option_t *options, 
 	char *s;
 	size_t i;
 
-#define NUM(width) \
+#define NUM(type) \
 	if (!*val) { \
-		*(uint ## width ## _t *)options[i].value = 1; \
+		*(type *)options[i].value = 1; \
 		break; \
 	} \
-	*(uint ## width ## _t *)options[i].value = \
-	(uint ## width ## _t)strsuftoll(options[i].desc, val, \
+	*(type *)options[i].value = (type)strsuftoll(options[i].desc, val, \
 	options[i].minimum, options[i].maximum); break
 
 	for (i = 0; options[i].name != NULL; i++) {
@@ -361,13 +360,13 @@ set_option_var(const option_t *options, 
 			strlcpy(buf, val, len);
 			break;
 		case OPT_INT64:
-			NUM(64);
+			NUM(uint64_t);
 		case OPT_INT32:
-			NUM(32);
+			NUM(uint32_t);
 		case OPT_INT16:
-			NUM(16);
+			NUM(uint16_t);
 		case OPT_INT8:
-			NUM(8);
+			NUM(uint8_t);
 		default:
 			warnx(Unknown type %d in option %s, options[i].type,
 			val);



CVS commit: src/usr.sbin/makefs

2013-02-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Feb  1 14:02:17 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
remove bogus err.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.46 src/usr.sbin/makefs/makefs.c:1.47
--- src/usr.sbin/makefs/makefs.c:1.46	Fri Feb  1 09:00:33 2013
+++ src/usr.sbin/makefs/makefs.c	Fri Feb  1 09:02:17 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.46 2013/02/01 14:00:33 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.47 2013/02/01 14:02:17 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.46 2013/02/01 14:00:33 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.47 2013/02/01 14:02:17 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -351,7 +351,6 @@ set_option_var(const option_t *options, 
 			break;
 		case OPT_STRPTR:
 			s = estrdup(val);
-err(1, NULL);
 			*(char **)options[i].value = s;
 			break;
 		case OPT_STRBUF:



CVS commit: src/usr.sbin/makefs

2013-01-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 31 14:56:32 UTC 2013

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
the allow options are 8 bits wide.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.41 src/usr.sbin/makefs/cd9660.c:1.42
--- src/usr.sbin/makefs/cd9660.c:1.41	Tue Jan 29 10:52:25 2013
+++ src/usr.sbin/makefs/cd9660.c	Thu Jan 31 09:56:32 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.41 2013/01/29 15:52:25 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.42 2013/01/31 14:56:32 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.41 2013/01/29 15:52:25 christos Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.42 2013/01/31 14:56:32 christos Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -279,19 +279,19 @@ cd9660_prep_opts(fsinfo_t *fsopts)
 	{ 'K', keep-bad-images, diskStructure-keep_bad_images,
 		  OPT_INT32, 0, 1, Keep bad images },
 	{ 'D', allow-deep-trees, diskStructure-allow_deep_trees,
-		  OPT_INT32, 0, 1, Allow trees more than 8 levels },
+		  OPT_INT8, 0, 1, Allow trees more than 8 levels },
 	{ 'a', allow-max-name, diskStructure-allow_max_name,
-		  OPT_INT32, 0, 1, Allow 37 char filenames (unimplemented) },
+		  OPT_INT8, 0, 1, Allow 37 char filenames (unimplemented) },
 	{ 'i', allow-illegal-chars, 
 		  diskStructure-allow_illegal_chars,
-		  OPT_INT32, 0, 1, Allow illegal characters in filenames },
+		  OPT_INT8, 0, 1, Allow illegal characters in filenames },
 	{ 'D', allow-multidot, diskStructure-allow_multidot,
-		  OPT_INT32, 0, 1, Allow multiple periods in filenames },
+		  OPT_INT8, 0, 1, Allow multiple periods in filenames },
 	{ 'o', omit-trailing-period,
 		  diskStructure-omit_trailing_period,
-		  OPT_INT32, 0, 1, Omit trailing periods in filenames },
+		  OPT_INT8, 0, 1, Omit trailing periods in filenames },
 	{ '\0', allow-lowercase, diskStructure-allow_lowercase,
-		  OPT_INT32, 0, 1, Allow lowercase characters in filenames },
+		  OPT_INT8, 0, 1, Allow lowercase characters in filenames },
 	{ '\0', archimedes, diskStructure-archimedes_enabled,
 		  OPT_INT32, 0, 1, Enable Archimedes structure },
 		{ '\0', no-trailing-padding,



CVS commit: src/usr.sbin/makefs

2013-01-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jan 31 15:15:15 UTC 2013

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
macroize to make it more type-safe.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.42 src/usr.sbin/makefs/cd9660.c:1.43
--- src/usr.sbin/makefs/cd9660.c:1.42	Thu Jan 31 09:56:32 2013
+++ src/usr.sbin/makefs/cd9660.c	Thu Jan 31 10:15:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.42 2013/01/31 14:56:32 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.43 2013/01/31 15:15:15 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.42 2013/01/31 14:56:32 christos Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.43 2013/01/31 15:15:15 christos Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -263,66 +263,65 @@ cd9660_prep_opts(fsinfo_t *fsopts)
 {
 	iso9660_disk *diskStructure = ecalloc(1, sizeof(*diskStructure));
 
+#define OPT_STR(letter, name, desc)  \
+	{ letter, name, NULL, OPT_STRBUF, 0, 0, desc }
+
+#define OPT_NUM(letter, name, field, min, max, desc) \
+	{ letter, name, diskStructure-field, \
+	  sizeof(diskStructure-field) == 8 ? OPT_INT64 : \
+	  (sizeof(diskStructure-field) == 4 ? OPT_INT32 : \
+	  (sizeof(diskStructure-field) == 2 ? OPT_INT16 : OPT_INT8)), \
+	  min, max, desc }
+
+#define OPT_BOOL(letter, name, field, desc) \
+	OPT_NUM(letter, name, field, 0, 1, desc)
+
 	const option_t cd9660_options[] = {
-		{ 'h', help, diskStructure-displayHelp,
-		  OPT_INT32, 0, 1, Show help message },
-		{ 'l', isolevel, diskStructure-isoLevel,
-		  OPT_INT32, 1, 3, ISO Level },
-		{ 'S', follow-symlinks, diskStructure-follow_sym_links,
-		  OPT_INT32, 0, 1, Resolve symlinks in pathnames },
-		{ 'v', verbose,  diskStructure-verbose_level,
-		  OPT_INT32, 0, 2, Turns on verbose output },
-	{ 'R', rockridge, diskStructure-rock_ridge_enabled,
-		  OPT_INT32, 0, 1, Enable Rock-Ridge extensions },
-	{ 'C', chrp-boot, diskStructure-chrp_boot,
-		  OPT_INT32, 0, 1, Enable CHRP boot },
-	{ 'K', keep-bad-images, diskStructure-keep_bad_images,
-		  OPT_INT32, 0, 1, Keep bad images },
-	{ 'D', allow-deep-trees, diskStructure-allow_deep_trees,
-		  OPT_INT8, 0, 1, Allow trees more than 8 levels },
-	{ 'a', allow-max-name, diskStructure-allow_max_name,
-		  OPT_INT8, 0, 1, Allow 37 char filenames (unimplemented) },
-	{ 'i', allow-illegal-chars, 
-		  diskStructure-allow_illegal_chars,
-		  OPT_INT8, 0, 1, Allow illegal characters in filenames },
-	{ 'D', allow-multidot, diskStructure-allow_multidot,
-		  OPT_INT8, 0, 1, Allow multiple periods in filenames },
-	{ 'o', omit-trailing-period,
-		  diskStructure-omit_trailing_period,
-		  OPT_INT8, 0, 1, Omit trailing periods in filenames },
-	{ '\0', allow-lowercase, diskStructure-allow_lowercase,
-		  OPT_INT8, 0, 1, Allow lowercase characters in filenames },
-	{ '\0', archimedes, diskStructure-archimedes_enabled,
-		  OPT_INT32, 0, 1, Enable Archimedes structure },
-		{ '\0', no-trailing-padding,
-		  diskStructure-include_padding_areas,
-		  OPT_INT32, 0, 1, Include padding areas },
-
-
-		{ 'A', applicationid, NULL, OPT_STRBUF, 0, 0,
-		  Application Identifier },
-		{ 'P', publisher, NULL, OPT_STRBUF, 0, 0, 
-		  Publisher Identifier },
-		{ 'p', preparer, NULL, OPT_STRBUF, 0, 0,
-		  Preparer Identifier },
-		{ 'L', label, NULL, OPT_STRBUF, 0, 0,
-		  Disk Label },
-		{ 'V', volumeid, NULL, OPT_STRBUF, 0, 0,
-		  Volume Set Identifier },
-		{ 'B', bootimage, NULL, OPT_STRBUF, 0, 0,
-		  Boot image parameter },
-		{ 'G', generic-bootimage, NULL, OPT_STRBUF, 0, 0,
-		  Generic boot image parameter },
-		{ '\0', bootimagedir, NULL, OPT_STRBUF, 0, 0,
-		  Boot image directory },
-		{ '\0', no-emul-boot, NULL, OPT_STRBUF, 0, 0,
-		  No boot emulation },
-		{ '\0', no-boot, NULL, OPT_STRBUF, 0, 0,
-		  No boot support },
-		{ '\0', hard-disk-boot, NULL, OPT_STRBUF, 0, 0,
-		  Boot from hard disk },
-		{ '\0', boot-load-segment, NULL, OPT_STRBUF, 0, 0,
-		  Boot load segment },
+		OPT_NUM('l', isolevel, isoLevel,
+		1, 3, ISO Level),
+		OPT_NUM('v', verbose,  verbose_level,
+		0, 2, Turns on verbose output),
+
+		OPT_BOOL('h', help, displayHelp,
+		Show help message),
+		OPT_BOOL('S', follow-symlinks, follow_sym_links,
+		Resolve symlinks in pathnames),
+	OPT_BOOL('R', rockridge, rock_ridge_enabled,
+		Enable Rock-Ridge extensions),
+	OPT_BOOL('C', chrp-boot, chrp_boot,
+		Enable CHRP boot),
+	OPT_BOOL('K', keep-bad-images, keep_bad_images,
+		Keep bad images),
+	OPT_BOOL('D', 

CVS commit: src/usr.sbin/makefs/ffs

2013-01-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 30 17:29:05 UTC 2013

Modified Files:
src/usr.sbin/makefs/ffs: buf.c buf.h

Log Message:
buf is generic; it has nothing to do with ffs and will eventually be moved.
gc sectorize.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/usr.sbin/makefs/ffs/buf.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/ffs/buf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.17 src/usr.sbin/makefs/ffs/buf.c:1.18
--- src/usr.sbin/makefs/ffs/buf.c:1.17	Mon Jan 28 16:03:29 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Wed Jan 30 12:29:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.17 2013/01/28 21:03:29 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.18 2013/01/30 17:29:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: buf.c,v 1.17 2013/01/28 21:03:29 christos Exp $);
+__RCSID($NetBSD: buf.c,v 1.18 2013/01/30 17:29:05 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -55,14 +55,7 @@ __RCSID($NetBSD: buf.c,v 1.17 2013/01/2
 #include util.h
 
 #include makefs.h
-
-#include ufs/ufs/dinode.h
-#include ufs/ffs/fs.h
-
-#include ffs/buf.h
-#include ffs/ufs_inode.h
-
-extern int sectorsize;		/* XXX: from ffs.c  mkfs.c */
+#include buf.h
 
 TAILQ_HEAD(buftailhead,buf) buftail;
 
@@ -72,15 +65,14 @@ bread(struct vnode *vp, daddr_t blkno, i
 {
 	off_t	offset;
 	ssize_t	rv;
-	struct fs *fs = vp-fs;
+	fsinfo_t *fs = vp-fs;
 
-	assert (fs != NULL);
 	assert (bpp != NULL);
 
 	if (debug  DEBUG_BUF_BREAD)
 		printf(bread: blkno %lld size %d\n, (long long)blkno, size);
 	*bpp = getblk(vp, blkno, size, 0, 0);
-	offset = (*bpp)-b_blkno * sectorsize;	/* XXX */
+	offset = (*bpp)-b_blkno * fs-sectorsize;
 	if (debug  DEBUG_BUF_BREAD)
 		printf(bread: blkno %lld offset %lld bcount %ld\n,
 		(long long)(*bpp)-b_blkno, (long long) offset,
@@ -138,9 +130,10 @@ bwrite(struct buf *bp)
 	off_t	offset;
 	ssize_t	rv;
 	int	bytes;
+	fsinfo_t *fs = bp-b_fs;
 
 	assert (bp != NULL);
-	offset = bp-b_blkno * sectorsize;	/* XXX */
+	offset = bp-b_blkno * fs-sectorsize;
 	bytes  = bp-b_bcount;
 	if (debug  DEBUG_BUF_BWRITE)
 		printf(bwrite: blkno %lld offset %lld bcount %d\n,
@@ -190,10 +183,7 @@ getblk(struct vnode *vp, daddr_t blkno, 
 	static int buftailinitted;
 	struct buf *bp;
 	void *n;
-	int fd = vp-fd;
-	struct fs *fs = vp-fs;
 
-	assert (fs != NULL);
 	if (debug  DEBUG_BUF_GETBLK)
 		printf(getblk: blkno %lld size %d\n, (long long)blkno, size);
 
@@ -214,8 +204,8 @@ getblk(struct vnode *vp, daddr_t blkno, 
 		bp = ecalloc(1, sizeof(*bp));
 		bp-b_bufsize = 0;
 		bp-b_blkno = bp-b_lblkno = blkno;
-		bp-b_fd = fd;
-		bp-b_fs = fs;
+		bp-b_fd = vp-fd;
+		bp-b_fs = vp-fs;
 		bp-b_data = NULL;
 		TAILQ_INSERT_HEAD(buftail, bp, b_tailq);
 	}

Index: src/usr.sbin/makefs/ffs/buf.h
diff -u src/usr.sbin/makefs/ffs/buf.h:1.7 src/usr.sbin/makefs/ffs/buf.h:1.8
--- src/usr.sbin/makefs/ffs/buf.h:1.7	Mon Jan 28 16:03:29 2013
+++ src/usr.sbin/makefs/ffs/buf.h	Wed Jan 30 12:29:05 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.7 2013/01/28 21:03:29 christos Exp $	*/
+/*	$NetBSD: buf.h,v 1.8 2013/01/30 17:29:05 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -69,7 +69,7 @@ struct buf {
 	daddr_t		b_blkno;
 	daddr_t		b_lblkno;
 	int		b_fd;
-	struct fs *	b_fs;
+	void *		b_fs;
 
 	TAILQ_ENTRY(buf)	b_tailq;
 };



CVS commit: src/usr.sbin/makefs

2013-01-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 30 17:29:25 UTC 2013

Modified Files:
src/usr.sbin/makefs: ffs.c msdos.c

Log Message:
gc global sectorsize.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/makefs/msdos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.57 src/usr.sbin/makefs/ffs.c:1.58
--- src/usr.sbin/makefs/ffs.c:1.57	Tue Jan 29 10:52:25 2013
+++ src/usr.sbin/makefs/ffs.c	Wed Jan 30 12:29:25 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.57 2013/01/29 15:52:25 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.58 2013/01/30 17:29:25 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs.c,v 1.57 2013/01/29 15:52:25 christos Exp $);
+__RCSID($NetBSD: ffs.c,v 1.58 2013/01/30 17:29:25 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -149,9 +149,6 @@ static  void	*ffs_build_dinode2(struct u
 
 
 
-int	sectorsize;		/* XXX: for buf.c::getblk() */
-
-
 	/* publically visible functions */
 void
 ffs_prep_opts(fsinfo_t *fsopts)
@@ -421,8 +418,6 @@ ffs_validate(const char *dir, fsnode *ro
 		printf(ffs_validate: dir %s; %lld bytes, %lld inodes\n,
 		dir, (long long)fsopts-size, (long long)fsopts-inodes);
 	}
-	sectorsize = fsopts-sectorsize;	/* XXX - see earlier */
-
 		/* now check calculated sizes vs requested sizes */
 	if (fsopts-maxsize  0  fsopts-size  fsopts-maxsize) {
 		errx(1, `%s' size of %lld is larger than the maxsize of %lld.,

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.11 src/usr.sbin/makefs/msdos.c:1.12
--- src/usr.sbin/makefs/msdos.c:1.11	Tue Jan 29 16:54:19 2013
+++ src/usr.sbin/makefs/msdos.c	Wed Jan 30 12:29:25 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.11 2013/01/29 21:54:19 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.12 2013/01/30 17:29:25 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: msdos.c,v 1.11 2013/01/29 21:54:19 christos Exp $);
+__RCSID($NetBSD: msdos.c,v 1.12 2013/01/30 17:29:25 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -63,8 +63,6 @@ __RCSID($NetBSD: msdos.c,v 1.11 2013/01
 #include msdos.h
 #include mkfs_msdos.h
 
-extern int sectorsize;	/* XXX: horrid */
-
 static int msdos_populate_dir(const char *, struct denode *, fsnode *,
 fsnode *, fsinfo_t *);
 
@@ -151,7 +149,17 @@ msdos_makefs(const char *image, const ch
 	 * Is minsize right here?
 	 */
 	msdos_opt-create_size = MAX(msdos_opt-create_size, fsopts-minsize);
-	msdos_opt-bytes_per_sector = sectorsize = 512;
+	if (msdos_opt-bytes_per_sector == 0) {
+		if (fsopts-sectorsize == 0)
+			fsopts-sectorsize = 512;
+		msdos_opt-bytes_per_sector = fsopts-sectorsize;
+	} else if (fsopts-sectorsize == 0) {
+		fsopts-sectorsize = msdos_opt-bytes_per_sector;
+	} else if (fsopts-sectorsize != msdos_opt-bytes_per_sector) {
+		err(1, inconsistent sectorsize -S %u
+		!= -o bytes_per_sector %u, 
+		fsopts-sectorsize, msdos_opt-bytes_per_sector);
+	}
 
 		/* create image */
 	printf(Creating `%s'\n, image);



CVS commit: src/usr.sbin/makefs

2013-01-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 30 19:19:20 UTC 2013

Modified Files:
src/usr.sbin/makefs: ffs.c makefs.h msdos.c
src/usr.sbin/makefs/ffs: buf.c buf.h ffs_alloc.c ffs_balloc.c
ufs_inode.h
src/usr.sbin/makefs/msdos: msdosfs_vfsops.c

Log Message:
- don't abuse vp-fs to mean struct fs for ffs and struct msdos_opts;
  make it always fsinfo_t and change void * to that.
- kill unused structure members.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/makefs/makefs.h
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/makefs/msdos.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makefs/ffs/buf.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/ffs/buf.h
cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/makefs/ffs/ffs_balloc.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/ffs/ufs_inode.h
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.58 src/usr.sbin/makefs/ffs.c:1.59
--- src/usr.sbin/makefs/ffs.c:1.58	Wed Jan 30 12:29:25 2013
+++ src/usr.sbin/makefs/ffs.c	Wed Jan 30 14:19:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.58 2013/01/30 17:29:25 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.59 2013/01/30 19:19:19 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs.c,v 1.58 2013/01/30 17:29:25 christos Exp $);
+__RCSID($NetBSD: ffs.c,v 1.59 2013/01/30 19:19:19 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -853,6 +853,7 @@ ffs_write_file(union dinode *din, uint32
 	struct inode	in;
 	struct buf *	bp;
 	ffs_opt_t	*ffs_opts = fsopts-fs_specific;
+	struct vnode vp = { fsopts, NULL };
 
 	assert (din != NULL);
 	assert (buf != NULL);
@@ -865,6 +866,7 @@ ffs_write_file(union dinode *din, uint32
 	p = NULL;
 
 	in.i_fs = (struct fs *)fsopts-superblock;
+	in.i_devvp = vp;
 
 	if (debug  DEBUG_FS_WRITE_FILE) {
 		printf(
@@ -885,7 +887,6 @@ ffs_write_file(union dinode *din, uint32
 	else
 		memcpy(in.i_din.ffs2_din, din-ffs2_din,
 		sizeof(in.i_din.ffs2_din));
-	in.i_fd = fsopts-fd;
 
 	if (DIP(din, size) == 0)
 		goto write_inode_and_leave;		/* mmm, cheating */

Index: src/usr.sbin/makefs/makefs.h
diff -u src/usr.sbin/makefs/makefs.h:1.31 src/usr.sbin/makefs/makefs.h:1.32
--- src/usr.sbin/makefs/makefs.h:1.31	Tue Jan 29 10:52:25 2013
+++ src/usr.sbin/makefs/makefs.h	Wed Jan 30 14:19:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.h,v 1.31 2013/01/29 15:52:25 christos Exp $	*/
+/*	$NetBSD: makefs.h,v 1.32 2013/01/30 19:19:19 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -141,7 +141,7 @@ typedef struct {
  * the image, including current settings, global options, and fs
  * specific options
  */
-typedef struct {
+typedef struct makefs_fsinfo {
 		/* current settings */
 	off_t	size;		/* total size */
 	off_t	inodes;		/* number of inodes */

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.12 src/usr.sbin/makefs/msdos.c:1.13
--- src/usr.sbin/makefs/msdos.c:1.12	Wed Jan 30 12:29:25 2013
+++ src/usr.sbin/makefs/msdos.c	Wed Jan 30 14:19:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.12 2013/01/30 17:29:25 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.13 2013/01/30 19:19:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: msdos.c,v 1.12 2013/01/30 17:29:25 christos Exp $);
+__RCSID($NetBSD: msdos.c,v 1.13 2013/01/30 19:19:19 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -150,10 +150,10 @@ msdos_makefs(const char *image, const ch
 	 */
 	msdos_opt-create_size = MAX(msdos_opt-create_size, fsopts-minsize);
 	if (msdos_opt-bytes_per_sector == 0) {
-		if (fsopts-sectorsize == 0)
+		if (fsopts-sectorsize == -1)
 			fsopts-sectorsize = 512;
 		msdos_opt-bytes_per_sector = fsopts-sectorsize;
-	} else if (fsopts-sectorsize == 0) {
+	} else if (fsopts-sectorsize == -1) {
 		fsopts-sectorsize = msdos_opt-bytes_per_sector;
 	} else if (fsopts-sectorsize != msdos_opt-bytes_per_sector) {
 		err(1, inconsistent sectorsize -S %u
@@ -168,8 +168,8 @@ msdos_makefs(const char *image, const ch
 		return;
 	TIMER_RESULTS(start, mkfs_msdos);
 
-	vp.fd = open(image, O_RDWR);
-	vp.fs = msdos_opt;
+	fsopts-fd = open(image, O_RDWR);
+	vp.fs = fsopts;
 
 	if ((pmp = msdosfs_mount(vp, 0)) == NULL)
 		err(1, msdosfs_mount);

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.18 src/usr.sbin/makefs/ffs/buf.c:1.19
--- src/usr.sbin/makefs/ffs/buf.c:1.18	Wed Jan 30 12:29:05 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Wed Jan 

CVS commit: src/usr.sbin/makefs

2013-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 14:09:48 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
Allow options without values meaning the empty string for string options
and = 1 to numerics.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.42 src/usr.sbin/makefs/makefs.c:1.43
--- src/usr.sbin/makefs/makefs.c:1.42	Mon Jan 28 20:06:15 2013
+++ src/usr.sbin/makefs/makefs.c	Tue Jan 29 09:09:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.42 2013/01/29 01:06:15 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.43 2013/01/29 14:09:48 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.42 2013/01/29 01:06:15 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.43 2013/01/29 14:09:48 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -310,16 +310,12 @@ set_option(const option_t *options, cons
 	assert(option != NULL);
 
 	var = estrdup(option);
-	retval = -1;
-	if ((val = strchr(var, '=')) == NULL) {
-		warnx(Option `%s' doesn't contain a value, var);
-		goto out;
-	}
-	*val++ = '\0';
-
+	for (val = var; *val; val++)
+		if (*val == '=') {
+			*val++ = '\0';
+			break;
+		}
 	retval = set_option_var(options, var, val);
-	
-out:
 	free(var);
 	return retval;
 }
@@ -330,9 +326,14 @@ set_option_var(const option_t *options, 
 	char *s;
 	size_t i;
 
-#define NUM(width) *(uint ## width ## _t *)options[i].value = \
-(uint ## width ## _t)strsuftoll(options[i].desc, val, \
-options[i].minimum, options[i].maximum); break
+#define NUM(width) \
+	if (!*var) { \
+		*(uint ## width ## _t *)options[i].value = 1; \
+		break; \
+	} \
+	*(uint ## width ## _t *)options[i].value = \
+	(uint ## width ## _t)strsuftoll(options[i].desc, val, \
+	options[i].minimum, options[i].maximum); break
 
 	for (i = 0; options[i].name != NULL; i++) {
 		if (var[1] == '\0') {



CVS commit: src/usr.sbin/makefs

2013-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 15:52:26 UTC 2013

Modified Files:
src/usr.sbin/makefs: cd9660.c cd9660.h chfs.c ffs.c makefs.c makefs.h
v7fs.c

Log Message:
make everything use the generic options parser.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/usr.sbin/makefs/cd9660.c
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/makefs/cd9660.h
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/chfs.c \
src/usr.sbin/makefs/v7fs.c
cvs rdiff -u -r1.56 -r1.57 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/makefs/makefs.c
cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/makefs/makefs.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.40 src/usr.sbin/makefs/cd9660.c:1.41
--- src/usr.sbin/makefs/cd9660.c:1.40	Mon Jan 28 20:05:57 2013
+++ src/usr.sbin/makefs/cd9660.c	Tue Jan 29 10:52:25 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.40 2013/01/29 01:05:57 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.41 2013/01/29 15:52:25 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.40 2013/01/29 01:05:57 christos Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.41 2013/01/29 15:52:25 christos Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -264,36 +264,65 @@ cd9660_prep_opts(fsinfo_t *fsopts)
 	iso9660_disk *diskStructure = ecalloc(1, sizeof(*diskStructure));
 
 	const option_t cd9660_options[] = {
+		{ 'h', help, diskStructure-displayHelp,
+		  OPT_INT32, 0, 1, Show help message },
 		{ 'l', isolevel, diskStructure-isoLevel,
 		  OPT_INT32, 1, 3, ISO Level },
+		{ 'S', follow-symlinks, diskStructure-follow_sym_links,
+		  OPT_INT32, 0, 1, Resolve symlinks in pathnames },
 		{ 'v', verbose,  diskStructure-verbose_level,
 		  OPT_INT32, 0, 2, Turns on verbose output },
-		{ 'L', Label, diskStructure-primaryDescriptor.volume_id, 
-		  OPT_STRARRAY, 1,
-		  sizeof(diskStructure-primaryDescriptor.volume_id),
-		  Disk Label },
 	{ 'R', rockridge, diskStructure-rock_ridge_enabled,
 		  OPT_INT32, 0, 1, Enable Rock-Ridge extensions },
-	{ 'A', archimedes, diskStructure-archimedes_enabled,
-		  OPT_INT32, 0, 1, Enable Archimedes structure },
-	{ '\0', chrp-boot, diskStructure-chrp_boot,
+	{ 'C', chrp-boot, diskStructure-chrp_boot,
 		  OPT_INT32, 0, 1, Enable CHRP boot },
 	{ 'K', keep-bad-images, diskStructure-keep_bad_images,
 		  OPT_INT32, 0, 1, Keep bad images },
-	{ '\0', allow-deep-trees, diskStructure-allow_deep_trees,
+	{ 'D', allow-deep-trees, diskStructure-allow_deep_trees,
 		  OPT_INT32, 0, 1, Allow trees more than 8 levels },
-	{ '\0', allow-max-name, diskStructure-allow_max_name,
+	{ 'a', allow-max-name, diskStructure-allow_max_name,
 		  OPT_INT32, 0, 1, Allow 37 char filenames (unimplemented) },
-	{ '\0', allow-illegal-chars, 
+	{ 'i', allow-illegal-chars, 
 		  diskStructure-allow_illegal_chars,
 		  OPT_INT32, 0, 1, Allow illegal characters in filenames },
-	{ '\0', allow-lowercase, diskStructure-allow_lowercase,
-		  OPT_INT32, 0, 1, Allow lowercase characters in filenames },
-	{ '\0', allow-multidot, diskStructure-allow_multidot,
+	{ 'D', allow-multidot, diskStructure-allow_multidot,
 		  OPT_INT32, 0, 1, Allow multiple periods in filenames },
-	{ '\0', omit-trailing-period,
+	{ 'o', omit-trailing-period,
 		  diskStructure-omit_trailing_period,
 		  OPT_INT32, 0, 1, Omit trailing periods in filenames },
+	{ '\0', allow-lowercase, diskStructure-allow_lowercase,
+		  OPT_INT32, 0, 1, Allow lowercase characters in filenames },
+	{ '\0', archimedes, diskStructure-archimedes_enabled,
+		  OPT_INT32, 0, 1, Enable Archimedes structure },
+		{ '\0', no-trailing-padding,
+		  diskStructure-include_padding_areas,
+		  OPT_INT32, 0, 1, Include padding areas },
+
+
+		{ 'A', applicationid, NULL, OPT_STRBUF, 0, 0,
+		  Application Identifier },
+		{ 'P', publisher, NULL, OPT_STRBUF, 0, 0, 
+		  Publisher Identifier },
+		{ 'p', preparer, NULL, OPT_STRBUF, 0, 0,
+		  Preparer Identifier },
+		{ 'L', label, NULL, OPT_STRBUF, 0, 0,
+		  Disk Label },
+		{ 'V', volumeid, NULL, OPT_STRBUF, 0, 0,
+		  Volume Set Identifier },
+		{ 'B', bootimage, NULL, OPT_STRBUF, 0, 0,
+		  Boot image parameter },
+		{ 'G', generic-bootimage, NULL, OPT_STRBUF, 0, 0,
+		  Generic boot image parameter },
+		{ '\0', bootimagedir, NULL, OPT_STRBUF, 0, 0,
+		  Boot image directory },
+		{ '\0', no-emul-boot, NULL, OPT_STRBUF, 0, 0,
+		  No boot emulation },
+		{ '\0', no-boot, NULL, OPT_STRBUF, 0, 0,
+		  No boot support },
+		{ '\0', hard-disk-boot, NULL, OPT_STRBUF, 0, 0,
+		  Boot from hard disk },
+		{ '\0', 

CVS commit: src/usr.sbin/makefs/msdos

2013-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 19:45:47 UTC 2013

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
workaround for gcc/vax


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.13 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.14
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.13	Sun Jan 27 19:16:48 2013
+++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c	Tue Jan 29 14:45:47 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.13 2013/01/28 00:16:48 christos Exp $ */
+/*	$NetBSD: msdosfs_vnops.c,v 1.14 2013/01/29 19:45:47 christos Exp $ */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.13 2013/01/28 00:16:48 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.14 2013/01/29 19:45:47 christos Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -426,6 +426,7 @@ msdosfs_wfile(const char *path, struct d
 	char *dat;
 	u_long cn = 0;
 
+	error = 0;	/* XXX: gcc/vax */
 	DPRINTF((%s(diroff %lu, dirclust %lu, startcluster %lu)\n, __func__,
 	dep-de_diroffset, dep-de_dirclust, dep-de_StartCluster));
 	if (st-st_size == 0)



CVS commit: src/usr.sbin/makefs

2013-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 21:54:19 UTC 2013

Modified Files:
src/usr.sbin/makefs: msdos.c

Log Message:
add missing arguments.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/makefs/msdos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.10 src/usr.sbin/makefs/msdos.c:1.11
--- src/usr.sbin/makefs/msdos.c:1.10	Mon Jan 28 16:03:27 2013
+++ src/usr.sbin/makefs/msdos.c	Tue Jan 29 16:54:19 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.10 2013/01/28 21:03:27 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.11 2013/01/29 21:54:19 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: msdos.c,v 1.10 2013/01/28 21:03:27 christos Exp $);
+__RCSID($NetBSD: msdos.c,v 1.11 2013/01/29 21:54:19 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -119,7 +119,7 @@ msdos_parse_opts(const char *option, fsi
 	if (debug  DEBUG_FS_PARSE_OPTS)
 		printf(msdos_parse_opts: got `%s'\n, option);
 
-	rv = set_option(msdos_options, option);
+	rv = set_option(msdos_options, option, NULL, 0);
 	if (rv == -1)
 		return rv;
 



CVS commit: src/usr.sbin/makefs

2013-01-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 30 02:53:54 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
use val not var


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.44 src/usr.sbin/makefs/makefs.c:1.45
--- src/usr.sbin/makefs/makefs.c:1.44	Tue Jan 29 10:52:25 2013
+++ src/usr.sbin/makefs/makefs.c	Tue Jan 29 21:53:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.44 2013/01/29 15:52:25 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.45 2013/01/30 02:53:54 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.44 2013/01/29 15:52:25 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.45 2013/01/30 02:53:54 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -328,7 +328,7 @@ set_option_var(const option_t *options, 
 	size_t i;
 
 #define NUM(width) \
-	if (!*var) { \
+	if (!*val) { \
 		*(uint ## width ## _t *)options[i].value = 1; \
 		break; \
 	} \



CVS commit: src/usr.sbin/makefs/ffs

2013-01-28 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Mon Jan 28 10:16:35 UTC 2013

Modified Files:
src/usr.sbin/makefs/ffs: buf.c

Log Message:
Do not use *bp after freeing it in brelse.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/makefs/ffs/buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.15 src/usr.sbin/makefs/ffs/buf.c:1.16
--- src/usr.sbin/makefs/ffs/buf.c:1.15	Sun Jan 27 20:05:46 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Mon Jan 28 10:16:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.16 2013/01/28 10:16:35 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 christos Exp $);
+__RCSID($NetBSD: buf.c,v 1.16 2013/01/28 10:16:35 mlelstv Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -136,20 +136,22 @@ bwrite(struct buf *bp)
 {
 	off_t	offset;
 	ssize_t	rv;
+	int	bytes;
 
 	assert (bp != NULL);
 	offset = bp-b_blkno * sectorsize;	/* XXX */
+	bytes  = bp-b_bcount;
 	if (debug  DEBUG_BUF_BWRITE)
-		printf(bwrite: blkno %lld offset %lld bcount %ld\n,
-		(long long)bp-b_blkno, (long long) offset, bp-b_bcount);
+		printf(bwrite: blkno %lld offset %lld bcount %d\n,
+		(long long)bp-b_blkno, (long long) offset, bytes);
 	if (lseek(bp-b_fd, offset, SEEK_SET) == -1)
 		return (errno);
-	rv = write(bp-b_fd, bp-b_data, bp-b_bcount);
+	rv = write(bp-b_fd, bp-b_data, bytes);
 	if (debug  DEBUG_BUF_BWRITE)
 		printf(bwrite: write %ld (offset %lld) returned %lld\n,
 		bp-b_bcount, (long long)offset, (long long)rv);
 	brelse(bp, 0);
-	if (rv == bp-b_bcount)
+	if (rv == bytes)
 		return (0);
 	else if (rv == -1)		/* write error */
 		return (errno);



CVS commit: src/usr.sbin/makefs

2013-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 01:05:57 UTC 2013

Modified Files:
src/usr.sbin/makefs: cd9660.c

Log Message:
handle some of the options by the generic parser.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makefs/cd9660.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/cd9660.c
diff -u src/usr.sbin/makefs/cd9660.c:1.39 src/usr.sbin/makefs/cd9660.c:1.40
--- src/usr.sbin/makefs/cd9660.c:1.39	Mon Jan 28 16:03:26 2013
+++ src/usr.sbin/makefs/cd9660.c	Mon Jan 28 20:05:57 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd9660.c,v 1.39 2013/01/28 21:03:26 christos Exp $	*/
+/*	$NetBSD: cd9660.c,v 1.40 2013/01/29 01:05:57 christos Exp $	*/
 
 /*
  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
@@ -103,7 +103,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: cd9660.c,v 1.39 2013/01/28 21:03:26 christos Exp $);
+__RCSID($NetBSD: cd9660.c,v 1.40 2013/01/29 01:05:57 christos Exp $);
 #endif  /* !__lint */
 
 #include string.h
@@ -272,6 +272,28 @@ cd9660_prep_opts(fsinfo_t *fsopts)
 		  OPT_STRARRAY, 1,
 		  sizeof(diskStructure-primaryDescriptor.volume_id),
 		  Disk Label },
+	{ 'R', rockridge, diskStructure-rock_ridge_enabled,
+		  OPT_INT32, 0, 1, Enable Rock-Ridge extensions },
+	{ 'A', archimedes, diskStructure-archimedes_enabled,
+		  OPT_INT32, 0, 1, Enable Archimedes structure },
+	{ '\0', chrp-boot, diskStructure-chrp_boot,
+		  OPT_INT32, 0, 1, Enable CHRP boot },
+	{ 'K', keep-bad-images, diskStructure-keep_bad_images,
+		  OPT_INT32, 0, 1, Keep bad images },
+	{ '\0', allow-deep-trees, diskStructure-allow_deep_trees,
+		  OPT_INT32, 0, 1, Allow trees more than 8 levels },
+	{ '\0', allow-max-name, diskStructure-allow_max_name,
+		  OPT_INT32, 0, 1, Allow 37 char filenames (unimplemented) },
+	{ '\0', allow-illegal-chars, 
+		  diskStructure-allow_illegal_chars,
+		  OPT_INT32, 0, 1, Allow illegal characters in filenames },
+	{ '\0', allow-lowercase, diskStructure-allow_lowercase,
+		  OPT_INT32, 0, 1, Allow lowercase characters in filenames },
+	{ '\0', allow-multidot, diskStructure-allow_multidot,
+		  OPT_INT32, 0, 1, Allow multiple periods in filenames },
+	{ '\0', omit-trailing-period,
+		  diskStructure-omit_trailing_period,
+		  OPT_INT32, 0, 1, Omit trailing periods in filenames },
 		{ .name = NULL }
 	};
 
@@ -392,26 +414,6 @@ cd9660_parse_opts(const char *option, fs
 	} else if (CD9660_IS_COMMAND_ARG(var, no-trailing-padding))
 		diskStructure-include_padding_areas = 0;
 	/* RRIP */
-	else if (CD9660_IS_COMMAND_ARG_DUAL(var, R, rockridge))
-		diskStructure-rock_ridge_enabled = 1;
-	else if (CD9660_IS_COMMAND_ARG_DUAL(var, A, archimedes))
-		diskStructure-archimedes_enabled = 1;
-	else if (CD9660_IS_COMMAND_ARG(var, chrp-boot))
-		diskStructure-chrp_boot = 1;
-	else if (CD9660_IS_COMMAND_ARG_DUAL(var, K, keep-bad-images))
-		diskStructure-keep_bad_images = 1;
-	else if (CD9660_IS_COMMAND_ARG(var, allow-deep-trees))
-		diskStructure-allow_deep_trees = 1;
-	else if (CD9660_IS_COMMAND_ARG(var, allow-max-name))
-		diskStructure-allow_max_name = 1;
-	else if (CD9660_IS_COMMAND_ARG(var, allow-illegal-chars))
-		diskStructure-allow_illegal_chars = 1;
-	else if (CD9660_IS_COMMAND_ARG(var, allow-lowercase))
-		diskStructure-allow_lowercase = 1;
-	else if (CD9660_IS_COMMAND_ARG(var,allow-multidot))
-		diskStructure-allow_multidot = 1;
-	else if (CD9660_IS_COMMAND_ARG(var, omit-trailing-period))
-		diskStructure-omit_trailing_period = 1;
 	else if (CD9660_IS_COMMAND_ARG(var, no-emul-boot) ||
 		 CD9660_IS_COMMAND_ARG(var, no-boot) ||
 		 CD9660_IS_COMMAND_ARG(var, hard-disk-boot)) {



CVS commit: src/usr.sbin/makefs

2013-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 01:06:15 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
deal with options that don't have a single letter argument.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.41 src/usr.sbin/makefs/makefs.c:1.42
--- src/usr.sbin/makefs/makefs.c:1.41	Mon Jan 28 16:03:27 2013
+++ src/usr.sbin/makefs/makefs.c	Mon Jan 28 20:06:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.41 2013/01/28 21:03:27 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.42 2013/01/29 01:06:15 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.41 2013/01/28 21:03:27 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.42 2013/01/29 01:06:15 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -414,7 +414,9 @@ usage(fstype_t *fstype, fsinfo_t *fsopti
 
 		fprintf(stderr, \n%s specific options:\n, fstype-type);
 		for (i = 0; o[i].name != NULL; i++)
-			fprintf(stderr, \t%c,%20.20s\t%s\n, o[i].letter,
+			fprintf(stderr, \t%c%c%20.20s\t%s\n,
+			o[i].letter ? o[i].letter : ' ',
+			o[i].letter ? ',' : ' ',
 			o[i].name, o[i].desc);
 	}
 	exit(1);



CVS commit: src/usr.sbin/makefs

2013-01-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 29 01:52:05 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.8

Log Message:
mention me


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/usr.sbin/makefs/makefs.8

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.8
diff -u src/usr.sbin/makefs/makefs.8:1.42 src/usr.sbin/makefs/makefs.8:1.43
--- src/usr.sbin/makefs/makefs.8:1.42	Sun Jan 27 19:23:18 2013
+++ src/usr.sbin/makefs/makefs.8	Mon Jan 28 20:52:04 2013
@@ -1,4 +1,4 @@
-.\	$NetBSD: makefs.8,v 1.42 2013/01/28 00:23:18 christos Exp $
+.\	$NetBSD: makefs.8,v 1.43 2013/01/29 01:52:04 christos Exp $
 .\
 .\ Copyright (c) 2001-2003 Wasabi Systems, Inc.
 .\ All rights reserved.
@@ -402,3 +402,5 @@ utility appeared in
 (v7fs support),
 .An Tamas Toth
 (chfs support).
+.An Christos Zoulas
+(msdos support).



CVS commit: src/usr.sbin/makefs/msdos

2013-01-27 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Sun Jan 27 10:07:23 UTC 2013

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
Allow this to compile on 32bit architectures.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.4 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.5
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.4	Sat Jan 26 16:58:14 2013
+++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c	Sun Jan 27 10:07:23 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.4 2013/01/26 16:58:14 christos Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.5 2013/01/27 10:07:23 mbalmer Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.4 2013/01/26 16:58:14 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.5 2013/01/27 10:07:23 mbalmer Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -177,7 +177,7 @@ msdosfs_wfile(const char *path, struct d
 	int error, fd;
 	size_t osize = dep-de_FileSize;
 	struct stat *st = node-inode-st;
-	size_t nsize = st-st_size;
+	off_t nsize = st-st_size;
 	size_t offs = 0;
 	struct msdosfsmount *pmp = dep-de_pmp;
 	struct buf *bp;
@@ -207,7 +207,7 @@ msdosfs_wfile(const char *path, struct d
 	if ((fd = open(path, O_RDONLY)) == -1)
 		err(1, open %s, path);
 
-	if ((dat = mmap(0, nsize, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0))
+	if ((dat = mmap(0, (size_t)nsize, PROT_READ, MAP_FILE | MAP_PRIVATE, fd, 0))
 	== MAP_FAILED)
 		err(1, mmap %s, node-name);
 	close(fd);



CVS commit: src/usr.sbin/makefs/msdos

2013-01-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Jan 27 12:25:13 UTC 2013

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
Make it compile on 32bit AND 64bit archs.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.5 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.6
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.5	Sun Jan 27 10:07:23 2013
+++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c	Sun Jan 27 12:25:13 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.5 2013/01/27 10:07:23 mbalmer Exp $	*/
+/*	$NetBSD: msdosfs_vnops.c,v 1.6 2013/01/27 12:25:13 martin Exp $	*/
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.5 2013/01/27 10:07:23 mbalmer Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.6 2013/01/27 12:25:13 martin Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -177,7 +177,7 @@ msdosfs_wfile(const char *path, struct d
 	int error, fd;
 	size_t osize = dep-de_FileSize;
 	struct stat *st = node-inode-st;
-	off_t nsize = st-st_size;
+	size_t nsize;
 	size_t offs = 0;
 	struct msdosfsmount *pmp = dep-de_pmp;
 	struct buf *bp;
@@ -188,15 +188,16 @@ msdosfs_wfile(const char *path, struct d
 	printf(msdosfs_write(): diroff %lu, dirclust %lu, startcluster %lu\n,
 	dep-de_diroffset, dep-de_dirclust, dep-de_StartCluster);
 #endif
-	if (nsize == 0)
+	if (st-st_size == 0)
 		return 0;
 
 	/* Don't bother to try to write files larger than the fs limit */
-	if (nsize  MSDOSFS_FILESIZE_MAX) {
+	if (st-st_size  (off_t)min(MSDOSFS_FILESIZE_MAX,__SIZE_MAX__)) {
 		errno = EFBIG;
 		return -1;
 	}
 
+	nsize = st-st_size;
 	if (nsize  osize) {
 		if ((error = deextend(dep, nsize, NULL)) != 0) {
 			errno = error;



CVS commit: src/usr.sbin/makefs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 14:07:12 UTC 2013

Modified Files:
src/usr.sbin/makefs: makefs.c

Log Message:
fix single letter parsing.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/usr.sbin/makefs/makefs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/makefs.c
diff -u src/usr.sbin/makefs/makefs.c:1.39 src/usr.sbin/makefs/makefs.c:1.40
--- src/usr.sbin/makefs/makefs.c:1.39	Wed Jan 23 20:10:47 2013
+++ src/usr.sbin/makefs/makefs.c	Sun Jan 27 09:07:12 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: makefs.c,v 1.39 2013/01/24 01:10:47 christos Exp $	*/
+/*	$NetBSD: makefs.c,v 1.40 2013/01/27 14:07:12 christos Exp $	*/
 
 /*
  * Copyright (c) 2001-2003 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: makefs.c,v 1.39 2013/01/24 01:10:47 christos Exp $);
+__RCSID($NetBSD: makefs.c,v 1.40 2013/01/27 14:07:12 christos Exp $);
 #endif	/* !__lint */
 
 #include assert.h
@@ -336,9 +336,10 @@ set_option_var(const option_t *options, 
 options[i].minimum, options[i].maximum); break
 
 	for (i = 0; options[i].name != NULL; i++) {
-		if (options[i].letter != var[0]  var[1] == '\0')
-			continue;
-		else if (strcmp(options[i].name, var) != 0)
+		if (var[1] == '\0') {
+			if (options[i].letter != var[0])
+continue;
+		} else if (strcmp(options[i].name, var) != 0)
 			continue;
 		switch (options[i].type) {
 		case OPT_BOOL:



CVS commit: src/usr.sbin/makefs/ffs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 14:10:04 UTC 2013

Modified Files:
src/usr.sbin/makefs/ffs: buf.c

Log Message:
Don't print the pointers in debugging, it is not useful.
zero all memory


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/makefs/ffs/buf.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.13 src/usr.sbin/makefs/ffs/buf.c:1.14
--- src/usr.sbin/makefs/ffs/buf.c:1.13	Fri Jan 25 19:19:39 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Sun Jan 27 09:10:03 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.13 2013/01/26 00:19:39 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.14 2013/01/27 14:10:03 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: buf.c,v 1.13 2013/01/26 00:19:39 christos Exp $);
+__RCSID($NetBSD: buf.c,v 1.14 2013/01/27 14:10:03 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -77,13 +77,12 @@ bread(struct vnode *vp, daddr_t blkno, i
 	assert (bpp != NULL);
 
 	if (debug  DEBUG_BUF_BREAD)
-		printf(bread: fs %p blkno %lld size %d\n,
-		fs, (long long)blkno, size);
+		printf(bread: blkno %lld size %d\n, (long long)blkno, size);
 	*bpp = getblk(vp, blkno, size, 0, 0);
 	offset = (*bpp)-b_blkno * sectorsize;	/* XXX */
 	if (debug  DEBUG_BUF_BREAD)
-		printf(bread: bp %p blkno %lld offset %lld bcount %ld\n,
-		(*bpp), (long long)(*bpp)-b_blkno, (long long) offset,
+		printf(bread: blkno %lld offset %lld bcount %ld\n,
+		(long long)(*bpp)-b_blkno, (long long) offset,
 		(*bpp)-b_bcount);
 	if (lseek((*bpp)-b_fd, offset, SEEK_SET) == -1)
 		err(1, bread: lseek %lld (%lld),
@@ -141,9 +140,8 @@ bwrite(struct buf *bp)
 	assert (bp != NULL);
 	offset = bp-b_blkno * sectorsize;	/* XXX */
 	if (debug  DEBUG_BUF_BWRITE)
-		printf(bwrite: bp %p blkno %lld offset %lld bcount %ld\n,
-		bp, (long long)bp-b_blkno, (long long) offset,
-		bp-b_bcount);
+		printf(bwrite: blkno %lld offset %lld bcount %ld\n,
+		(long long)bp-b_blkno, (long long) offset, bp-b_bcount);
 	if (lseek(bp-b_fd, offset, SEEK_SET) == -1)
 		return (errno);
 	rv = write(bp-b_fd, bp-b_data, bp-b_bcount);
@@ -191,11 +189,10 @@ getblk(struct vnode *vp, daddr_t blkno, 
 	int fd = vp-fd;
 	struct fs *fs = vp-fs;
 
-	blkno += vp-offset;
+	// blkno += vp-offset;
 	assert (fs != NULL);
 	if (debug  DEBUG_BUF_GETBLK)
-		printf(getblk: fs %p blkno %lld size %d\n, fs,
-		(long long)blkno, size);
+		printf(getblk: blkno %lld size %d\n, (long long)blkno, size);
 
 	bp = NULL;
 	if (!buftailinitted) {
@@ -226,6 +223,7 @@ getblk(struct vnode *vp, daddr_t blkno, 
 		n = realloc(bp-b_data, size);
 		if (n == NULL)
 			err(1, getblk: realloc b_data %ld, bp-b_bcount);
+		memset(n, 0, size);
 		bp-b_data = n;
 		bp-b_bufsize = size;
 	}



CVS commit: src/usr.sbin/makefs/ffs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 14:10:22 UTC 2013

Modified Files:
src/usr.sbin/makefs/ffs: buf.h

Log Message:
zero memory


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/ffs/buf.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/ffs/buf.h
diff -u src/usr.sbin/makefs/ffs/buf.h:1.4 src/usr.sbin/makefs/ffs/buf.h:1.5
--- src/usr.sbin/makefs/ffs/buf.h:1.4	Sat Jan 26 11:50:46 2013
+++ src/usr.sbin/makefs/ffs/buf.h	Sun Jan 27 09:10:22 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.h,v 1.4 2013/01/26 16:50:46 christos Exp $	*/
+/*	$NetBSD: buf.h,v 1.5 2013/01/27 14:10:22 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -99,7 +99,7 @@ struct pool {
 };
 
 #define pool_init(p, s, a1, a2, a3, a4, a5, a6)	(p)-size = (s)
-#define pool_get(p, f)	malloc((p)-size)
+#define pool_get(p, f)	calloc(1, (p)-size)
 #define pool_put(p, a)	free(a)
 #define pool_destroy(p)
 



CVS commit: src/usr.sbin/makefs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 15:35:45 UTC 2013

Modified Files:
src/usr.sbin/makefs: msdos.c
src/usr.sbin/makefs/msdos: msdosfs_vfsops.c msdosfs_vnops.c

Log Message:
fixed directory entry allocation. Now the file data remains and is currently
broken.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/msdos.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c
cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.6 src/usr.sbin/makefs/msdos.c:1.7
--- src/usr.sbin/makefs/msdos.c:1.6	Fri Jan 25 19:20:40 2013
+++ src/usr.sbin/makefs/msdos.c	Sun Jan 27 10:35:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.6 2013/01/26 00:20:40 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.7 2013/01/27 15:35:45 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: msdos.c,v 1.6 2013/01/26 00:20:40 christos Exp $);
+__RCSID($NetBSD: msdos.c,v 1.7 2013/01/27 15:35:45 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -62,6 +62,8 @@ __RCSID($NetBSD: msdos.c,v 1.6 2013/01/
 #include msdos.h
 #include mkfs_msdos.h
 
+extern int sectorsize;	/* XXX: horrid */
+
 static int msdos_populate_dir(const char *, struct denode *, fsnode *,
 fsnode *, fsinfo_t *);
 
@@ -149,6 +151,7 @@ msdos_makefs(const char *image, const ch
 	 * Is minsize right here?
 	 */
 	msdos_opt-create_size = MAX(msdos_opt-create_size, fsopts-minsize);
+	msdos_opt-bytes_per_sector = sectorsize = 512;
 
 		/* create image */
 	printf(Creating `%s'\n, image);
@@ -159,7 +162,7 @@ msdos_makefs(const char *image, const ch
 
 	vp.fd = open(image, O_RDWR);
 	vp.fs = msdos_opt;
-	vp.offset = 1;
+	vp.offset = 0;
 
 	if ((pmp = msdosfs_mount(vp, 0)) == NULL)
 		err(1, msdosfs_mount);
@@ -171,9 +174,6 @@ msdos_makefs(const char *image, const ch
 		printf(msdos_makefs: image %s directory %s root %p\n,
 		image, dir, root);
 
-	printf(Calculated size of `%s': %lld bytes, %lld inodes\n,
-	image, (long long)fsopts-size, (long long)fsopts-inodes);
-
 		/* populate image */
 	printf(Populating `%s'\n, image);
 	TIMER_START(start);

Index: src/usr.sbin/makefs/msdos/msdosfs_vfsops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.3 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.4
--- src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.3	Sat Jan 26 11:50:46 2013
+++ src/usr.sbin/makefs/msdos/msdosfs_vfsops.c	Sun Jan 27 10:35:45 2013
@@ -50,7 +50,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.3 2013/01/26 16:50:46 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vfsops.c,v 1.4 2013/01/27 15:35:45 christos Exp $);
 
 #include sys/param.h
 
@@ -94,7 +94,8 @@ msdosfs_mount(struct vnode *devvp, int f
 	uint64_t psize = m-create_size;
 	unsigned secsize = 512;
 
-	if ((error = bread(devvp, 1, secsize, NULL, 0, bp)) != 0)
+	DPRINTF((%s(bread 0)\n, __func__));
+	if ((error = bread(devvp, 0, secsize, NULL, 0, bp)) != 0)
 		goto error_exit;
 
 	bsp = (union bootsector *)bp-b_data;
@@ -135,6 +136,11 @@ msdosfs_mount(struct vnode *devvp, int f
 	pmp-pm_Heads = getushort(b50-bpbHeads);
 	pmp-pm_Media = b50-bpbMedia;
 
+	DPRINTF((%s(BytesPerSec=%u, ResSectors=%u, FATs=%d, RootDirEnts=%u, 
+	Sectors=%u, FATsecs=%lu, SecPerTrack=%u, Heads=%u, Media=%u)\n,
+	__func__, pmp-pm_BytesPerSec, pmp-pm_ResSectors, pmp-pm_FATs,
+	pmp-pm_RootDirEnts, pmp-pm_Sectors, pmp-pm_FATsecs,
+	pmp-pm_SecPerTrack, pmp-pm_Heads, pmp-pm_Media));
 	if (!(flags  MSDOSFSMNT_GEMDOSFS)) {
 		/* XXX - We should probably check more values here */
 		if (!pmp-pm_BytesPerSec || !SecPerClust
@@ -323,6 +329,8 @@ msdosfs_mount(struct vnode *devvp, int f
 		 *	2KB or larger sectors, is the fsinfo structure
 		 *	padded at the end or in the middle?
 		 */
+		DPRINTF((%s(bread %lu)\n, __func__,
+		(unsigned long)de_bn2kb(pmp, pmp-pm_fsinfo)));
 		if ((error = bread(devvp, de_bn2kb(pmp, pmp-pm_fsinfo),
 		pmp-pm_BytesPerSec, NULL, 0, bp)) != 0)
 			goto error_exit;
@@ -352,9 +360,8 @@ msdosfs_mount(struct vnode *devvp, int f
 	 * Allocate memory for the bitmap of allocated clusters, and then
 	 * fill it in.
 	 */
-	pmp-pm_inusemap = malloc(((pmp-pm_maxcluster + N_INUSEBITS)
-   / N_INUSEBITS)
-  * sizeof(*pmp-pm_inusemap));
+	pmp-pm_inusemap = calloc(sizeof(*pmp-pm_inusemap),
+	((pmp-pm_maxcluster + N_INUSEBITS) / N_INUSEBITS));
 	if (pmp-pm_inusemap == NULL)
 		goto error_exit;
 

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.6 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.7
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.6	Sun Jan 27 07:25:13 2013

CVS commit: src/usr.sbin/makefs/msdos

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 16:03:16 UTC 2013

Modified Files:
src/usr.sbin/makefs/msdos: msdosfs_vnops.c

Log Message:
the max msdos file size is less than size_t so don't bother checking against it.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/msdos/msdosfs_vnops.c
diff -u src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.7 src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.8
--- src/usr.sbin/makefs/msdos/msdosfs_vnops.c:1.7	Sun Jan 27 10:35:45 2013
+++ src/usr.sbin/makefs/msdos/msdosfs_vnops.c	Sun Jan 27 11:03:15 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdosfs_vnops.c,v 1.7 2013/01/27 15:35:45 christos Exp $ */
+/*	$NetBSD: msdosfs_vnops.c,v 1.8 2013/01/27 16:03:15 christos Exp $ */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include sys/cdefs.h
-__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.7 2013/01/27 15:35:45 christos Exp $);
+__KERNEL_RCSID(0, $NetBSD: msdosfs_vnops.c,v 1.8 2013/01/27 16:03:15 christos Exp $);
 
 #include sys/param.h
 #include sys/mman.h
@@ -423,7 +423,7 @@ msdosfs_wfile(const char *path, struct d
 		return 0;
 
 	/* Don't bother to try to write files larger than the fs limit */
-	if (st-st_size  (off_t)min(MSDOSFS_FILESIZE_MAX,__SIZE_MAX__)) {
+	if (st-st_size  MSDOSFS_FILESIZE_MAX) {
 		errno = EFBIG;
 		return -1;
 	}



CVS commit: src/usr.sbin/makefs

2013-01-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 27 20:05:47 UTC 2013

Modified Files:
src/usr.sbin/makefs: Makefile ffs.c msdos.c
src/usr.sbin/makefs/ffs: buf.c buf.h ffs_alloc.c ffs_balloc.c
src/usr.sbin/makefs/msdos: msdosfs_vfsops.c msdosfs_vnops.c

Log Message:
This works well enough to populate plain files in the root dir. creating
directories fails.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/usr.sbin/makefs/Makefile
cvs rdiff -u -r1.54 -r1.55 src/usr.sbin/makefs/ffs.c
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/makefs/msdos.c
cvs rdiff -u -r1.14 -r1.15 src/usr.sbin/makefs/ffs/buf.c
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/makefs/ffs/buf.h
cvs rdiff -u -r1.21 -r1.22 src/usr.sbin/makefs/ffs/ffs_alloc.c
cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/makefs/ffs/ffs_balloc.c
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/msdos/msdosfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/makefs/Makefile
diff -u src/usr.sbin/makefs/Makefile:1.34 src/usr.sbin/makefs/Makefile:1.35
--- src/usr.sbin/makefs/Makefile:1.34	Fri Jan 25 19:31:49 2013
+++ src/usr.sbin/makefs/Makefile	Sun Jan 27 15:05:46 2013
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.34 2013/01/26 00:31:49 christos Exp $
+#	$NetBSD: Makefile,v 1.35 2013/01/27 20:05:46 christos Exp $
 #
 
 WARNS?=	5
@@ -18,7 +18,7 @@ MKNODSRC=	${NETBSDSRCDIR}/sbin/mknod
 MTREESRC=	${NETBSDSRCDIR}/usr.sbin/mtree
 
 CPPFLAGS+=	-I${.CURDIR} -I${MKNODSRC} -I${MTREESRC} -DMAKEFS
-CPPFLAGS+=	-DMSDOSFS_DEBUG
+#CPPFLAGS+=	-DMSDOSFS_DEBUG
 .PATH:		${MKNODSRC} ${MTREESRC}
 
 .include ${.CURDIR}/cd9660/Makefile.inc

Index: src/usr.sbin/makefs/ffs.c
diff -u src/usr.sbin/makefs/ffs.c:1.54 src/usr.sbin/makefs/ffs.c:1.55
--- src/usr.sbin/makefs/ffs.c:1.54	Fri Jan 25 19:19:39 2013
+++ src/usr.sbin/makefs/ffs.c	Sun Jan 27 15:05:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: ffs.c,v 1.54 2013/01/26 00:19:39 christos Exp $	*/
+/*	$NetBSD: ffs.c,v 1.55 2013/01/27 20:05:46 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -71,7 +71,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: ffs.c,v 1.54 2013/01/26 00:19:39 christos Exp $);
+__RCSID($NetBSD: ffs.c,v 1.55 2013/01/27 20:05:46 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -945,7 +945,6 @@ ffs_write_file(union dinode *din, uint32
 		errno = bwrite(bp);
 		if (errno != 0)
 			goto bad_ffs_write_file;
-		brelse(bp, 0);
 		if (!isfile)
 			p += chunk;
 	}

Index: src/usr.sbin/makefs/msdos.c
diff -u src/usr.sbin/makefs/msdos.c:1.7 src/usr.sbin/makefs/msdos.c:1.8
--- src/usr.sbin/makefs/msdos.c:1.7	Sun Jan 27 10:35:45 2013
+++ src/usr.sbin/makefs/msdos.c	Sun Jan 27 15:05:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: msdos.c,v 1.7 2013/01/27 15:35:45 christos Exp $	*/
+/*	$NetBSD: msdos.c,v 1.8 2013/01/27 20:05:46 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: msdos.c,v 1.7 2013/01/27 15:35:45 christos Exp $);
+__RCSID($NetBSD: msdos.c,v 1.8 2013/01/27 20:05:46 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -162,7 +162,6 @@ msdos_makefs(const char *image, const ch
 
 	vp.fd = open(image, O_RDWR);
 	vp.fs = msdos_opt;
-	vp.offset = 0;
 
 	if ((pmp = msdosfs_mount(vp, 0)) == NULL)
 		err(1, msdosfs_mount);
@@ -237,7 +236,7 @@ msdos_populate_dir(const char *path, str
 			continue;
 		}
 		if (msdosfs_mkfile(pbuf, dir, cur) == NULL)
-			err(1, msdosfs_mkfile);
+			err(1, msdosfs_mkfile %s, pbuf);
 	}
 	return 0;
 }

Index: src/usr.sbin/makefs/ffs/buf.c
diff -u src/usr.sbin/makefs/ffs/buf.c:1.14 src/usr.sbin/makefs/ffs/buf.c:1.15
--- src/usr.sbin/makefs/ffs/buf.c:1.14	Sun Jan 27 09:10:03 2013
+++ src/usr.sbin/makefs/ffs/buf.c	Sun Jan 27 15:05:46 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf.c,v 1.14 2013/01/27 14:10:03 christos Exp $	*/
+/*	$NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 christos Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -41,7 +41,7 @@
 
 #include sys/cdefs.h
 #if defined(__RCSID)  !defined(__lint)
-__RCSID($NetBSD: buf.c,v 1.14 2013/01/27 14:10:03 christos Exp $);
+__RCSID($NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 christos Exp $);
 #endif	/* !__lint */
 
 #include sys/param.h
@@ -148,6 +148,7 @@ bwrite(struct buf *bp)
 	if (debug  DEBUG_BUF_BWRITE)
 		printf(bwrite: write %ld (offset %lld) returned %lld\n,
 		bp-b_bcount, (long long)offset, (long long)rv);
+	brelse(bp, 0);
 	if (rv == bp-b_bcount)
 		return (0);
 	else if (rv == -1)		/* write error */
@@ -189,7 +190,6 @@ getblk(struct vnode *vp, daddr_t blkno, 
 	int fd = vp-fd;
 	struct fs *fs = vp-fs;
 
-	// blkno += vp-offset;
 	assert (fs != NULL);
 	if (debug  DEBUG_BUF_GETBLK)
 		printf(getblk: blkno %lld size %d\n, (long long)blkno, size);


  1   2   >