Module Name:    src
Committed By:   jmcneill
Date:           Sat Aug  6 12:29:39 UTC 2011

Modified Files:
        src/etc: MAKEDEV.tmpl

Log Message:
add -u flag that causes the MAKEDEV script to only create a device node if it
doesn't exist


To generate a diff of this commit:
cvs rdiff -u -r1.139 -r1.140 src/etc/MAKEDEV.tmpl

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

Modified files:

Index: src/etc/MAKEDEV.tmpl
diff -u src/etc/MAKEDEV.tmpl:1.139 src/etc/MAKEDEV.tmpl:1.140
--- src/etc/MAKEDEV.tmpl:1.139	Sat Jul  9 14:49:28 2011
+++ src/etc/MAKEDEV.tmpl	Sat Aug  6 12:29:39 2011
@@ -1,5 +1,5 @@
 #!/bin/sh -
-#	$NetBSD: MAKEDEV.tmpl,v 1.139 2011/07/09 14:49:28 jmcneill Exp $
+#	$NetBSD: MAKEDEV.tmpl,v 1.140 2011/08/06 12:29:39 jmcneill Exp $
 #
 # Copyright (c) 2003,2007,2008 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -310,7 +310,7 @@
 usage()
 {
 	cat 1>&2 << _USAGE_
-Usage: ${0##*/} [-fMs] [-m mknod] [-p pax] [-t mtree] special [...]
+Usage: ${0##*/} [-fMsu] [-m mknod] [-p pax] [-t mtree] special [...]
 	Create listed special devices.  Options:
 	-f		Force permissions to be updated on existing devices.
 	-M		Create memory file system.
@@ -318,6 +318,7 @@
 	-p pax  	Name of pax(1) program.  [\$TOOL_PAX or pax]
 	-s		Generate mtree(8) specfile instead of creating devices.
 	-t mtree	Name of mtree(8) program.  [\$TOOL_MTREE or mtree]
+	-u		Don't re-create devices that already exist.
 
 _USAGE_
 	exit 1
@@ -425,8 +426,9 @@
 	do_mtree=false
 	do_redirect=false
 	do_specfile=false
+	do_update=false
 	opts=
-	while getopts Mfm:p:st: ch; do
+	while getopts Mfm:p:st:u ch; do
 		# Note that $opts is only for options pased through to
 		# MAKEDEV.local, not for all options.
 		case ${ch} in
@@ -468,6 +470,10 @@
 				do_mknod=true
 			fi
 			;;
+		u)
+			do_update=true
+			opts="${opts} -u"
+			;;
 		*)	usage ;;
 		esac
 	done
@@ -524,6 +530,11 @@
 		do_mknod=true
 	fi
 
+	# do_force and do_update do not work together
+	if $do_force && $do_update; then
+		die "-f and -u options do not work together"
+	fi
+
 	# If no explicit method was specified on the command line or
 	# forced above, then use one of mtree, pax, or mknod, in that
 	# order of preference.
@@ -663,6 +674,9 @@
 		count_nodes=$((count_nodes + 1))
 		return
 	fi
+	if $do_update && test -e $1; then
+		return
+	fi
 	if $do_specfile; then
 		case $2 in
 		b)	type=block ;;
@@ -680,6 +694,9 @@
 		count_nodes=$((count_nodes + 1))
 		return
 	fi
+	if $do_update && test -e $2; then
+		return
+	fi
 	if $do_specfile; then
 		echo "./$2 type=link link=$1 mode=0700 gid=$g_wheel uid=$u_root"
 	else
@@ -693,6 +710,9 @@
 		count_nodes=$((count_nodes + 1))
 		return
 	fi
+	if $do_update && test -e $1; then
+		return
+	fi
 	if $do_specfile; then
 		echo "./$1 type=dir mode=$2 gid=$g_wheel uid=$u_root"
 	else

Reply via email to