CVS commit: src/sbin/mount_qemufwcfg

2020-04-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Wed Apr 29 09:54:43 UTC 2020

Modified Files:
src/sbin/mount_qemufwcfg: mount_qemufwcfg.8

Log Message:
Remove references to "special", as mount_qemufwcfg(8) does not
actually take such an argument.  Discussed with jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8

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



CVS commit: src/sbin/mount_qemufwcfg

2020-04-29 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Wed Apr 29 09:54:43 UTC 2020

Modified Files:
src/sbin/mount_qemufwcfg: mount_qemufwcfg.8

Log Message:
Remove references to "special", as mount_qemufwcfg(8) does not
actually take such an argument.  Discussed with jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8

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

Modified files:

Index: src/sbin/mount_qemufwcfg/mount_qemufwcfg.8
diff -u src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.2 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.3
--- src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.2	Tue Nov 28 11:55:30 2017
+++ src/sbin/mount_qemufwcfg/mount_qemufwcfg.8	Wed Apr 29 09:54:43 2020
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_qemufwcfg.8,v 1.2 2017/11/28 11:55:30 wiz Exp $
+.\"	$NetBSD: mount_qemufwcfg.8,v 1.3 2020/04/29 09:54:43 gson Exp $
 .\"
 .\" Copyright (c) 2017 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -24,7 +24,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd November 28, 2017
+.Dd April 29, 2020
 .Dt MOUNT_QEMUFWCFG 8
 .Os
 .Sh NAME
@@ -38,18 +38,16 @@
 .Op Fl m Ar file-mode
 .Op Fl u Ar uid
 .Op Ar fuse-options
-.Ar special node
+.Ar node
 .Sh DESCRIPTION
 The
 .Nm
 command provides the QEMU fw_cfg configuration files in a file system
 tree at point
 .Ar node .
-Both
-.Ar special
-and
+The directory specified by
 .Ar node
-are converted to absolute paths before use.
+is converted to an absolute path before use.
 .Pp
 The options are as follows:
 .Bl -tag -width Ds



CVS commit: src/sbin/mount_qemufwcfg

2018-10-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  3 13:34:45 UTC 2018

Modified Files:
src/sbin/mount_qemufwcfg: Makefile

Log Message:
Add libpuffs (fixes sun2 build)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount_qemufwcfg/Makefile

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



CVS commit: src/sbin/mount_qemufwcfg

2018-10-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  3 13:34:45 UTC 2018

Modified Files:
src/sbin/mount_qemufwcfg: Makefile

Log Message:
Add libpuffs (fixes sun2 build)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount_qemufwcfg/Makefile

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

Modified files:

Index: src/sbin/mount_qemufwcfg/Makefile
diff -u src/sbin/mount_qemufwcfg/Makefile:1.3 src/sbin/mount_qemufwcfg/Makefile:1.4
--- src/sbin/mount_qemufwcfg/Makefile:1.3	Tue Nov 28 11:59:16 2017
+++ src/sbin/mount_qemufwcfg/Makefile	Wed Oct  3 13:34:44 2018
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.3 2017/11/28 11:59:16 wiz Exp $
+# $NetBSD: Makefile,v 1.4 2018/10/03 13:34:44 jmcneill Exp $
 
 WARNS=	6
 
 PROG=	mount_qemufwcfg
 SRCS=	fwcfg.c virtdir.c
-DPADD+=	${LIBREFUSE} ${LIBUTIL}
-LDADD=	-lrefuse -lutil
+DPADD+=	${LIBREFUSE} ${LIBPUFFS} ${LIBUTIL}
+LDADD=	-lrefuse -lpuffs -lutil
 MAN=	mount_qemufwcfg.8
 
 CPPFLAGS+=	-D_KERNTYPES



CVS commit: src/sbin/mount_qemufwcfg

2017-11-30 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Nov 30 15:42:18 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: fwcfg.c

Log Message:
Sync (dead) usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/mount_qemufwcfg/fwcfg.c

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

Modified files:

Index: src/sbin/mount_qemufwcfg/fwcfg.c
diff -u src/sbin/mount_qemufwcfg/fwcfg.c:1.4 src/sbin/mount_qemufwcfg/fwcfg.c:1.5
--- src/sbin/mount_qemufwcfg/fwcfg.c:1.4	Thu Nov 30 03:31:08 2017
+++ src/sbin/mount_qemufwcfg/fwcfg.c	Thu Nov 30 15:42:18 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fwcfg.c,v 1.4 2017/11/30 03:31:08 christos Exp $ */
+/* $NetBSD: fwcfg.c,v 1.5 2017/11/30 15:42:18 wiz Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fwcfg.c,v 1.4 2017/11/30 03:31:08 christos Exp $");
+__RCSID("$NetBSD: fwcfg.c,v 1.5 2017/11/30 15:42:18 wiz Exp $");
 
 #include 
 
@@ -212,8 +212,8 @@ build_tree(virtdir_t *v)
 static __dead void
 usage(void)
 {
-	fprintf(stderr, "Usage: %s [-F ] [-g ] [-m ] "
-	"[-M ] [-u ] []", getprogname());
+	fprintf(stderr, "Usage: %s [-F path] [-g gid] [-M dir-mode] "
+	"[-m file-mode] [-u uid] [fuse-options]", getprogname());
 	exit(EXIT_FAILURE);
 }
 #endif



CVS commit: src/sbin/mount_qemufwcfg

2017-11-30 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Thu Nov 30 15:42:18 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: fwcfg.c

Log Message:
Sync (dead) usage with man page.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sbin/mount_qemufwcfg/fwcfg.c

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



CVS commit: src/sbin/mount_qemufwcfg

2017-11-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 30 03:31:08 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: fwcfg.c

Log Message:
clang does not like dead unused functions.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount_qemufwcfg/fwcfg.c

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

Modified files:

Index: src/sbin/mount_qemufwcfg/fwcfg.c
diff -u src/sbin/mount_qemufwcfg/fwcfg.c:1.3 src/sbin/mount_qemufwcfg/fwcfg.c:1.4
--- src/sbin/mount_qemufwcfg/fwcfg.c:1.3	Sun Nov 26 10:03:15 2017
+++ src/sbin/mount_qemufwcfg/fwcfg.c	Wed Nov 29 22:31:08 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fwcfg.c,v 1.3 2017/11/26 15:03:15 christos Exp $ */
+/* $NetBSD: fwcfg.c,v 1.4 2017/11/30 03:31:08 christos Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fwcfg.c,v 1.3 2017/11/26 15:03:15 christos Exp $");
+__RCSID("$NetBSD: fwcfg.c,v 1.4 2017/11/30 03:31:08 christos Exp $");
 
 #include 
 
@@ -208,6 +208,7 @@ build_tree(virtdir_t *v)
 	}
 }
 
+#if 0
 static __dead void
 usage(void)
 {
@@ -215,6 +216,7 @@ usage(void)
 	"[-M ] [-u ] []", getprogname());
 	exit(EXIT_FAILURE);
 }
+#endif
 
 int
 main(int argc, char *argv[])



CVS commit: src/sbin/mount_qemufwcfg

2017-11-29 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov 30 03:31:08 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: fwcfg.c

Log Message:
clang does not like dead unused functions.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sbin/mount_qemufwcfg/fwcfg.c

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



CVS commit: src/sbin/mount_qemufwcfg

2017-11-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Nov 28 11:55:30 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: mount_qemufwcfg.8

Log Message:
Fix typo found by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8

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

Modified files:

Index: src/sbin/mount_qemufwcfg/mount_qemufwcfg.8
diff -u src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.1 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.2
--- src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.1	Tue Nov 28 11:10:31 2017
+++ src/sbin/mount_qemufwcfg/mount_qemufwcfg.8	Tue Nov 28 11:55:30 2017
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_qemufwcfg.8,v 1.1 2017/11/28 11:10:31 wiz Exp $
+.\"	$NetBSD: mount_qemufwcfg.8,v 1.2 2017/11/28 11:55:30 wiz Exp $
 .\"
 .\" Copyright (c) 2017 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -42,7 +42,7 @@
 .Sh DESCRIPTION
 The
 .Nm
-command provdes the QEMU fw_cfg configuration files in a file system
+command provides the QEMU fw_cfg configuration files in a file system
 tree at point
 .Ar node .
 Both



CVS commit: src/sbin/mount_qemufwcfg

2017-11-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Nov 28 11:55:30 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: mount_qemufwcfg.8

Log Message:
Fix typo found by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8

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



CVS commit: src/sbin/mount_qemufwcfg

2017-11-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Nov 28 11:10:31 UTC 2017

Added Files:
src/sbin/mount_qemufwcfg: mount_qemufwcfg.8

Log Message:
Add mount_qemufwcfg man page for review.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8

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



CVS commit: src/sbin/mount_qemufwcfg

2017-11-28 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Tue Nov 28 11:10:31 UTC 2017

Added Files:
src/sbin/mount_qemufwcfg: mount_qemufwcfg.8

Log Message:
Add mount_qemufwcfg man page for review.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sbin/mount_qemufwcfg/mount_qemufwcfg.8

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

Added files:

Index: src/sbin/mount_qemufwcfg/mount_qemufwcfg.8
diff -u /dev/null src/sbin/mount_qemufwcfg/mount_qemufwcfg.8:1.1
--- /dev/null	Tue Nov 28 11:10:31 2017
+++ src/sbin/mount_qemufwcfg/mount_qemufwcfg.8	Tue Nov 28 11:10:31 2017
@@ -0,0 +1,89 @@
+.\"	$NetBSD: mount_qemufwcfg.8,v 1.1 2017/11/28 11:10:31 wiz Exp $
+.\"
+.\" Copyright (c) 2017 The NetBSD Foundation, Inc.
+.\" 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``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 FOUNDATION OR CONTRIBUTORS
+.\" 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 THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd November 28, 2017
+.Dt MOUNT_QEMUFWCFG 8
+.Os
+.Sh NAME
+.Nm mount_qemufwcfg
+.Nd provide QEMU fw_cfg data as a file system
+.Sh SYNOPSIS
+.Nm
+.Op Fl F Ar path
+.Op Fl g Ar gid
+.Op Fl M Ar dir-mode
+.Op Fl m Ar file-mode
+.Op Fl u Ar uid
+.Op Ar fuse-options
+.Ar special node
+.Sh DESCRIPTION
+The
+.Nm
+command provdes the QEMU fw_cfg configuration files in a file system
+tree at point
+.Ar node .
+Both
+.Ar special
+and
+.Ar node
+are converted to absolute paths before use.
+.Pp
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl F Ar path
+Use
+.Ar path
+instead of
+.Pa /dev/qemufwcfg
+for the QEMU device.
+.It Fl g Ar gid
+Use
+.Ar gid
+as group for files in the file system instead of the active group id.
+.It Fl M Ar dir-mode
+Use
+.Ar dir-mode
+as permissions for directories instead of the default
+.Ar 0555 .
+.It Fl m Ar file-mode
+Use
+.Ar file-mode
+as permissions for files instead of the default
+.Ar 0444 .
+.It Fl u Ar uid
+Use
+.Ar uid
+as user for files in the file system instead of the active user id.
+.El
+.Sh SEE ALSO
+.Xr qemufwcfg 4
+.Sh HISTORY
+A
+.Nm
+command first appeared in
+.Nx 9.0 .
+.Sh AUTHORS
+.An Jared McNeill Aq Mt jmcne...@invisible.ca



CVS commit: src/sbin/mount_qemufwcfg

2017-11-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 26 15:03:15 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: fwcfg.c

Log Message:
don't error on unknown options.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_qemufwcfg/fwcfg.c

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

Modified files:

Index: src/sbin/mount_qemufwcfg/fwcfg.c
diff -u src/sbin/mount_qemufwcfg/fwcfg.c:1.2 src/sbin/mount_qemufwcfg/fwcfg.c:1.3
--- src/sbin/mount_qemufwcfg/fwcfg.c:1.2	Sat Nov 25 22:06:24 2017
+++ src/sbin/mount_qemufwcfg/fwcfg.c	Sun Nov 26 10:03:15 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fwcfg.c,v 1.2 2017/11/26 03:06:24 christos Exp $ */
+/* $NetBSD: fwcfg.c,v 1.3 2017/11/26 15:03:15 christos Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fwcfg.c,v 1.2 2017/11/26 03:06:24 christos Exp $");
+__RCSID("$NetBSD: fwcfg.c,v 1.3 2017/11/26 15:03:15 christos Exp $");
 
 #include 
 
@@ -252,8 +252,10 @@ main(int argc, char *argv[])
 		case 'u':
 			fwcfg_uid = (uid_t)atoi(optarg);
 			break;
+#ifdef notyet
 		default:
 			usage();
+#endif
 		}
 	}
 



CVS commit: src/sbin/mount_qemufwcfg

2017-11-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 26 15:03:15 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: fwcfg.c

Log Message:
don't error on unknown options.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_qemufwcfg/fwcfg.c

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



Re: CVS commit: src/sbin/mount_qemufwcfg

2017-11-26 Thread Jared McNeill
The addition of a default case to the getopt loop means refuse will not 
have a chance to process built-in options.



On Sat, 25 Nov 2017, Christos Zoulas wrote:


Module Name:src
Committed By:   christos
Date:   Sun Nov 26 03:06:24 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: Makefile fwcfg.c virtdir.c virtdir.h
Removed Files:
src/sbin/mount_qemufwcfg: defs.h

Log Message:
cleanup, knf, remove debugging printf, homebrew alloc macros, types.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_qemufwcfg/Makefile \
   src/sbin/mount_qemufwcfg/fwcfg.c src/sbin/mount_qemufwcfg/virtdir.c \
   src/sbin/mount_qemufwcfg/virtdir.h
cvs rdiff -u -r1.1 -r0 src/sbin/mount_qemufwcfg/defs.h

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




CVS commit: src/sbin/mount_qemufwcfg

2017-11-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 26 03:51:45 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: virtdir.c virtdir.h

Log Message:
more cleanups, const


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_qemufwcfg/virtdir.c \
src/sbin/mount_qemufwcfg/virtdir.h

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



CVS commit: src/sbin/mount_qemufwcfg

2017-11-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 26 03:51:45 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: virtdir.c virtdir.h

Log Message:
more cleanups, const


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sbin/mount_qemufwcfg/virtdir.c \
src/sbin/mount_qemufwcfg/virtdir.h

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

Modified files:

Index: src/sbin/mount_qemufwcfg/virtdir.c
diff -u src/sbin/mount_qemufwcfg/virtdir.c:1.2 src/sbin/mount_qemufwcfg/virtdir.c:1.3
--- src/sbin/mount_qemufwcfg/virtdir.c:1.2	Sat Nov 25 22:06:24 2017
+++ src/sbin/mount_qemufwcfg/virtdir.c	Sat Nov 25 22:51:45 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: virtdir.c,v 1.2 2017/11/26 03:06:24 christos Exp $ */
+/* $NetBSD: virtdir.c,v 1.3 2017/11/26 03:51:45 christos Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -44,8 +44,8 @@
 static int
 compare(const void *vp1, const void *vp2)
 {
-	const virt_dirent_t *tp1 = (const virt_dirent_t *) vp1;
-	const virt_dirent_t *tp2 = (const virt_dirent_t *) vp2;
+	const virt_dirent_t *tp1 = vp1;
+	const virt_dirent_t *tp2 = vp2;
 
 	return strcmp(tp1->name, tp2->name);
 }
@@ -60,7 +60,7 @@ mkdirs(virtdir_t *tp, const char *path, 
 
 	(void) strlcpy(name, path, sizeof(name));
 	for (slash = name + 1 ; (slash = strchr(slash + 1, '/')) != NULL ; ) {
-		*slash = 0x0;
+		*slash = '\0';
 		if ((ep = virtdir_find(tp, name, strlen(name))) == NULL) {
 			virtdir_add(tp, name, strlen(name), 'd', NULL, 0, 0);
 		}
@@ -101,7 +101,8 @@ normalise(const char *name, size_t namel
 
 /* initialise the tree */
 int
-virtdir_init(virtdir_t *tp, const char *rootdir, struct stat *d, struct stat *f, struct stat *l)
+virtdir_init(virtdir_t *tp, const char *rootdir, const struct stat *d,
+const struct stat *f, const struct stat *l)
 {
 	tp->dir = *d;
 	tp->dir.st_mode = S_IFDIR | 0755;
@@ -120,7 +121,8 @@ virtdir_init(virtdir_t *tp, const char *
 
 /* add an entry to the tree */
 int
-virtdir_add(virtdir_t *tp, const char *name, size_t size, uint8_t type, const char *tgt, size_t tgtlen, uint16_t select)
+virtdir_add(virtdir_t *tp, const char *name, size_t size, uint8_t type,
+const char *tgt, size_t tgtlen, uint16_t select)
 {
 	char		path[MAXPATHLEN];
 	size_t		pathlen;
@@ -131,13 +133,11 @@ virtdir_add(virtdir_t *tp, const char *n
 		return 0;
 	}
 	if (tp->c == tp->size || tp->size == 0) {
-		tp->size += 10,
+		tp->size += 10;
 		tp->v = erealloc(tp->v, tp->size * sizeof(*tp->v));
 	}
 	tp->v[tp->c].namelen = pathlen;
-	if ((tp->v[tp->c].name = estrndup(path, pathlen)) == NULL) {
-		return 0;
-	}
+	tp->v[tp->c].name = estrndup(path, pathlen);
 	tp->v[tp->c].d_name = strrchr(tp->v[tp->c].name, '/') + 1;
 	tp->v[tp->c].type = type;
 	tp->v[tp->c].ino = (ino_t) random() & 0xf;
@@ -159,7 +159,7 @@ virtdir_find(virtdir_t *tp, const char *
 	virt_dirent_t	e;
 	char		path[MAXPATHLEN];
 
-	(void) memset(, 0x0, sizeof(e));
+	(void) memset(, 0, sizeof(e));
 	e.namelen = normalise(name, namelen, path, sizeof(path));
 	e.name = path;
 	return bsearch(, tp->v, tp->c, sizeof(tp->v[0]), compare);
@@ -167,7 +167,7 @@ virtdir_find(virtdir_t *tp, const char *
 
 /* return the virtual offset in the tree */
 off_t
-virtdir_offset(virtdir_t *tp, virt_dirent_t *dp)
+virtdir_offset(const virtdir_t *tp, const virt_dirent_t *dp)
 {
 	return dp - tp->v;
 }
@@ -194,7 +194,7 @@ readvirtdir(VIRTDIR *dirp)
 {
 	char	*from;
 
-	for ( ; dirp->i < dirp->tp->c ; dirp->i++) {
+	for ( ; dirp->i < dirp->tp->c; dirp->i++) {
 		from = (strcmp(dirp->dirname, "/") == 0) ?
 		>tp->v[dirp->i].name[1] :
 		>tp->v[dirp->i].name[dirp->dirnamelen + 1];
Index: src/sbin/mount_qemufwcfg/virtdir.h
diff -u src/sbin/mount_qemufwcfg/virtdir.h:1.2 src/sbin/mount_qemufwcfg/virtdir.h:1.3
--- src/sbin/mount_qemufwcfg/virtdir.h:1.2	Sat Nov 25 22:06:24 2017
+++ src/sbin/mount_qemufwcfg/virtdir.h	Sat Nov 25 22:51:45 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: virtdir.h,v 1.2 2017/11/26 03:06:24 christos Exp $ */
+/* $NetBSD: virtdir.h,v 1.3 2017/11/26 03:51:45 christos Exp $ */
 
 /*
  * Copyright © 2007 Alistair Crooks.  All rights reserved.
@@ -66,14 +66,16 @@ typedef struct VIRTDIR {
 	size_t		 i;		/* current offset in dir tree */
 } VIRTDIR;
 
-int virtdir_init(virtdir_t *, const char *, struct stat *, struct stat *, struct stat *);
-int virtdir_add(virtdir_t *, const char *, size_t, uint8_t, const char *, size_t, uint16_t);
+int virtdir_init(virtdir_t *, const char *, const struct stat *,
+const struct stat *, const struct stat *);
+int virtdir_add(virtdir_t *, const char *, size_t, uint8_t, const char *,
+size_t, uint16_t);
 virt_dirent_t *virtdir_find(virtdir_t *, const char *, size_t);
 
 VIRTDIR *openvirtdir(virtdir_t *, const char *);
 virt_dirent_t *readvirtdir(VIRTDIR *);
 void closevirtdir(VIRTDIR *);
 
-off_t virtdir_offset(virtdir_t *, virt_dirent_t *);
+off_t virtdir_offset(const virtdir_t *, const 

CVS commit: src/sbin/mount_qemufwcfg

2017-11-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 26 03:06:24 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: Makefile fwcfg.c virtdir.c virtdir.h
Removed Files:
src/sbin/mount_qemufwcfg: defs.h

Log Message:
cleanup, knf, remove debugging printf, homebrew alloc macros, types.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_qemufwcfg/Makefile \
src/sbin/mount_qemufwcfg/fwcfg.c src/sbin/mount_qemufwcfg/virtdir.c \
src/sbin/mount_qemufwcfg/virtdir.h
cvs rdiff -u -r1.1 -r0 src/sbin/mount_qemufwcfg/defs.h

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

Modified files:

Index: src/sbin/mount_qemufwcfg/Makefile
diff -u src/sbin/mount_qemufwcfg/Makefile:1.1 src/sbin/mount_qemufwcfg/Makefile:1.2
--- src/sbin/mount_qemufwcfg/Makefile:1.1	Sat Nov 25 18:23:39 2017
+++ src/sbin/mount_qemufwcfg/Makefile	Sat Nov 25 22:06:24 2017
@@ -1,11 +1,12 @@
-# $NetBSD: Makefile,v 1.1 2017/11/25 23:23:39 jmcneill Exp $
+# $NetBSD: Makefile,v 1.2 2017/11/26 03:06:24 christos Exp $
+
+WARNS=	6
 
 PROG=	mount_qemufwcfg
 SRCS=	fwcfg.c virtdir.c
-DPADD+=	${LIBREFUSE}
-LDADD=	-lrefuse
+DPADD+=	${LIBREFUSE} ${LIBUTIL}
+LDADD=	-lrefuse -lutil
 NOMAN=	# defined
-WARNS=	3
 
 CPPFLAGS+=	-D_KERNTYPES
 
Index: src/sbin/mount_qemufwcfg/fwcfg.c
diff -u src/sbin/mount_qemufwcfg/fwcfg.c:1.1 src/sbin/mount_qemufwcfg/fwcfg.c:1.2
--- src/sbin/mount_qemufwcfg/fwcfg.c:1.1	Sat Nov 25 18:23:39 2017
+++ src/sbin/mount_qemufwcfg/fwcfg.c	Sat Nov 25 22:06:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: fwcfg.c,v 1.1 2017/11/25 23:23:39 jmcneill Exp $ */
+/* $NetBSD: fwcfg.c,v 1.2 2017/11/26 03:06:24 christos Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: fwcfg.c,v 1.1 2017/11/25 23:23:39 jmcneill Exp $");
+__RCSID("$NetBSD: fwcfg.c,v 1.2 2017/11/26 03:06:24 christos Exp $");
 
 #include 
 
@@ -93,7 +93,7 @@ fwcfg_getattr(const char *path, struct s
 	switch (ep->type) {
 	case 'f':
 		memcpy(st, _virtdir.file, sizeof(*st));
-		st->st_size = ep->tgtlen;
+		st->st_size = (off_t)ep->tgtlen;
 		st->st_mode = S_IFREG | fwcfg_file_mask;
 		break;
 	case 'd':
@@ -101,7 +101,7 @@ fwcfg_getattr(const char *path, struct s
 		st->st_mode = S_IFDIR | fwcfg_dir_mask;
 		break;
 	}
-	st->st_ino = virtdir_offset(_virtdir, ep) + 10;
+	st->st_ino = (ino_t)virtdir_offset(_virtdir, ep) + 10;
 
 	return 0;
 }
@@ -152,15 +152,15 @@ fwcfg_read(const char *path, char *buf, 
 
 	/* Seek to correct offset */
 	while (offset > 0) {
-		const int len = MIN(sizeof(tmp), (size_t)offset);
+		const size_t len = MIN(sizeof(tmp), (size_t)offset);
 		read_data(tmp, len);
-		offset -= len;
+		offset -= (off_t)len;
 	}
 
 	/* Read the data */
 	read_data(buf, size);
 
-	return size;
+	return (int)size;
 }
 
 static int
@@ -198,8 +198,6 @@ build_tree(virtdir_t *v)
 	st.st_gid = fwcfg_gid;
 	virtdir_init(v, NULL, , , );
 
-printf("init with uid = %d, gid = %d\n", st.st_uid, st.st_gid);
-
 	set_index(FW_CFG_FILE_DIR);
 	read_data(, sizeof(count));
 	for (n = 0; n < be32toh(count); n++) {
@@ -210,11 +208,20 @@ printf("init with uid = %d, gid = %d\n",
 	}
 }
 
+static __dead void
+usage(void)
+{
+	fprintf(stderr, "Usage: %s [-F ] [-g ] [-m ] "
+	"[-M ] [-u ] []", getprogname());
+	exit(EXIT_FAILURE);
+}
+
 int
 main(int argc, char *argv[])
 {
 	const char *path = _PATH_FWCFG;
-	int ch, m;
+	int ch;
+	long m;
 	char *ep;
 
 	fwcfg_uid = geteuid();
@@ -226,23 +233,27 @@ main(int argc, char *argv[])
 			path = optarg;
 			break;
 		case 'g':
-			fwcfg_gid = atoi(optarg);
+			fwcfg_gid = (gid_t)atoi(optarg);
 			break;
 		case 'm':
 			m = strtol(optarg, , 8);
 			if (optarg == ep || *ep || m < 0)
-errx(1, "invalid file mode: %s", optarg);
-			fwcfg_file_mask = m;
+errx(EXIT_FAILURE, "invalid file mode: %s",
+optarg);
+			fwcfg_file_mask = (mode_t)m;
 			break;
 		case 'M':
 			m = strtol(optarg, , 8);
 			if (optarg == ep || *ep || m < 0)
-errx(1, "invalid file mode: %s", optarg);
-			fwcfg_dir_mask = m;
+errx(EXIT_FAILURE, "invalid directory mode: %s",
+optarg);
+			fwcfg_dir_mask = (mode_t)m;
 			break;
 		case 'u':
-			fwcfg_uid = atoi(optarg);
+			fwcfg_uid = (uid_t)atoi(optarg);
 			break;
+		default:
+			usage();
 		}
 	}
 
@@ -252,8 +263,5 @@ main(int argc, char *argv[])
 
 	build_tree(_virtdir);
 
-	for (int i = 0; i < argc; i++)
-		printf("argv[%d] = \"%s\"\n", i, argv[i]);
-
 	return fuse_main(argc, argv, _ops, NULL);
 }
Index: src/sbin/mount_qemufwcfg/virtdir.c
diff -u src/sbin/mount_qemufwcfg/virtdir.c:1.1 src/sbin/mount_qemufwcfg/virtdir.c:1.2
--- src/sbin/mount_qemufwcfg/virtdir.c:1.1	Sat Nov 25 18:23:39 2017
+++ src/sbin/mount_qemufwcfg/virtdir.c	Sat Nov 25 22:06:24 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: virtdir.c,v 1.1 2017/11/25 23:23:39 jmcneill Exp $ */
+/* $NetBSD: virtdir.c,v 1.2 2017/11/26 03:06:24 christos Exp $ */
 
 /*
  * Copyright © 

CVS commit: src/sbin/mount_qemufwcfg

2017-11-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Nov 26 03:06:24 UTC 2017

Modified Files:
src/sbin/mount_qemufwcfg: Makefile fwcfg.c virtdir.c virtdir.h
Removed Files:
src/sbin/mount_qemufwcfg: defs.h

Log Message:
cleanup, knf, remove debugging printf, homebrew alloc macros, types.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/mount_qemufwcfg/Makefile \
src/sbin/mount_qemufwcfg/fwcfg.c src/sbin/mount_qemufwcfg/virtdir.c \
src/sbin/mount_qemufwcfg/virtdir.h
cvs rdiff -u -r1.1 -r0 src/sbin/mount_qemufwcfg/defs.h

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



CVS commit: src/sbin/mount_qemufwcfg

2017-11-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 25 23:23:39 UTC 2017

Added Files:
src/sbin/mount_qemufwcfg: Makefile defs.h fwcfg.c virtdir.c virtdir.h

Log Message:
Add virtual filesystem for QEMU Firmware Configuration interface.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sbin/mount_qemufwcfg/Makefile \
src/sbin/mount_qemufwcfg/defs.h src/sbin/mount_qemufwcfg/fwcfg.c \
src/sbin/mount_qemufwcfg/virtdir.c src/sbin/mount_qemufwcfg/virtdir.h

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

Added files:

Index: src/sbin/mount_qemufwcfg/Makefile
diff -u /dev/null src/sbin/mount_qemufwcfg/Makefile:1.1
--- /dev/null	Sat Nov 25 23:23:39 2017
+++ src/sbin/mount_qemufwcfg/Makefile	Sat Nov 25 23:23:39 2017
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1 2017/11/25 23:23:39 jmcneill Exp $
+
+PROG=	mount_qemufwcfg
+SRCS=	fwcfg.c virtdir.c
+DPADD+=	${LIBREFUSE}
+LDADD=	-lrefuse
+NOMAN=	# defined
+WARNS=	3
+
+CPPFLAGS+=	-D_KERNTYPES
+
+.include 
Index: src/sbin/mount_qemufwcfg/defs.h
diff -u /dev/null src/sbin/mount_qemufwcfg/defs.h:1.1
--- /dev/null	Sat Nov 25 23:23:39 2017
+++ src/sbin/mount_qemufwcfg/defs.h	Sat Nov 25 23:23:39 2017
@@ -0,0 +1,88 @@
+/* $NetBSD: defs.h,v 1.1 2017/11/25 23:23:39 jmcneill Exp $ */
+
+/*
+ * Copyright (c) 1999-2005 Alistair Crooks.  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.
+ * 3. The name of the author may not be used to endorse or promote
+ *products derived from this software without specific prior written
+ *permission.
+ *
+ * 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 THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+#ifndef DEFS_H_
+#define DEFS_H_
+
+#include 
+#include 
+
+#ifdef HAVE_STDINT_H
+#include 
+#endif
+
+#include 
+#include 
+#include 
+
+#define NEWARRAY(type,ptr,size,where,action) do {			\
+	if ((ptr = (type *) calloc(sizeof(type), (unsigned)(size))) == NULL) { \
+		(void) fprintf(stderr, "%s: can't allocate %lu bytes\n", \
+			where, (unsigned long)(size * sizeof(type)));	\
+		action;			\
+	}\
+} while( /* CONSTCOND */ 0)
+
+#define RENEW(type,ptr,size,where,action) do {\
+	type *_newptr;			\
+	if ((_newptr = (type *) realloc(ptr, sizeof(type) * (size))) == NULL) { \
+		(void) fprintf(stderr, "%s: can't realloc %lu bytes\n",	\
+			where, (unsigned long)(size * sizeof(type)));	\
+		action;			\
+	} else {			\
+		ptr = _newptr;		\
+	}\
+} while( /* CONSTCOND */ 0)
+
+#define NEW(type, ptr, where, action)	NEWARRAY(type, ptr, 1, where, action)
+
+#define FREE(ptr)	(void) free(ptr)
+
+#define ALLOC(type, v, size, c, init, incr, where, action) do {		\
+	uint32_t	_newsize = size;\
+	if (size == 0) {		\
+		_newsize = init;	\
+		NEWARRAY(type, v, _newsize, where ": new", action);	\
+	} else if (c == size) {		\
+		_newsize = size + incr;	\
+		RENEW(type, v, _newsize, where ": renew", action);	\
+	}\
+	size = _newsize;		\
+} while( /* CONSTCOND */ 0)
+
+/*		(void) memset([size], 0x0, sizeof(type) * incr);	\*/
+
+#define DEFINE_ARRAY(name, type)	\
+typedef struct name {			\
+	uint32_t	c;		\
+	uint32_t	size;		\
+	type	   *v;		\
+} name
+
+#endif /* !DEFS_H_ */
Index: src/sbin/mount_qemufwcfg/fwcfg.c
diff -u /dev/null src/sbin/mount_qemufwcfg/fwcfg.c:1.1
--- /dev/null	Sat Nov 25 23:23:39 2017
+++ src/sbin/mount_qemufwcfg/fwcfg.c	Sat Nov 25 23:23:39 2017
@@ -0,0 +1,259 @@
+/* $NetBSD: fwcfg.c,v 1.1 2017/11/25 23:23:39 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2017 Jared McNeill 
+ * 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 

CVS commit: src/sbin/mount_qemufwcfg

2017-11-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 25 23:23:39 UTC 2017

Added Files:
src/sbin/mount_qemufwcfg: Makefile defs.h fwcfg.c virtdir.c virtdir.h

Log Message:
Add virtual filesystem for QEMU Firmware Configuration interface.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sbin/mount_qemufwcfg/Makefile \
src/sbin/mount_qemufwcfg/defs.h src/sbin/mount_qemufwcfg/fwcfg.c \
src/sbin/mount_qemufwcfg/virtdir.c src/sbin/mount_qemufwcfg/virtdir.h

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