summaryrefslogtreecommitdiff
path: root/usr/src/ucbcmd
diff options
context:
space:
mode:
authoreota <none@none>2006-09-26 14:29:13 -0700
committereota <none@none>2006-09-26 14:29:13 -0700
commit1ca932730d3439e527d5fe4a15444600d0df7e7e (patch)
tree021f725c3677f6b8619e3ef76fb7720c121e0520 /usr/src/ucbcmd
parent23b5c241225a8ade2b6b9f06ebb891ee459e3b02 (diff)
downloadillumos-joyent-1ca932730d3439e527d5fe4a15444600d0df7e7e.tar.gz
6311701 /etc/minor_perm is ignored if it contains comments
6459253 i.nametomajor holds the obsolete shell function 6460892 add_drv and update_drv can accept the invalid names 6462571 should clean up duplicate code in update_minor_entry()
Diffstat (limited to 'usr/src/ucbcmd')
-rw-r--r--usr/src/ucbcmd/ucblinks/ucblinks.c34
-rw-r--r--usr/src/ucbcmd/ucblinks/ucblinks.sh17
2 files changed, 35 insertions, 16 deletions
diff --git a/usr/src/ucbcmd/ucblinks/ucblinks.c b/usr/src/ucbcmd/ucblinks/ucblinks.c
index 1f96a85f2b..92e3357ed3 100644
--- a/usr/src/ucbcmd/ucblinks/ucblinks.c
+++ b/usr/src/ucbcmd/ucblinks/ucblinks.c
@@ -199,6 +199,7 @@ static void set_depth(void);
static void get_devices(void);
static void get_dev_links(void);
static void call_device_rules(void);
+static int is_blank(char *);
/*
* The command-line arguments to ucblinks are:
@@ -381,8 +382,8 @@ static void
get_major_nums(void)
{
FILE *fp;
- char line[80];
- char *name, *maj, *end;
+ char line[FILENAME_MAX*2 + 1]; /* use the same size as add_drv does */
+ char *name, *maj, *end, *cp;
int majnum;
struct drvinfo *drp;
@@ -394,18 +395,18 @@ get_major_nums(void)
}
while (fgets(line, sizeof (line), fp) != NULL) {
- name = strtok(line, " \t");
- if (name == NULL)
+ /* cut off comments starting with '#' */
+ if ((cp = strchr(line, '#')) != NULL)
+ *cp = '\0';
+ /* ignore comment or blank lines */
+ if (is_blank(line))
continue;
-
- maj = strtok(NULL, "\n");
- if (maj == NULL)
+ name = strtok(line, " \t"); /* must not be NULL */
+ if ((maj = strtok(NULL, "\n")) == NULL)
continue;
-
majnum = strtol(maj, &end, 10);
if (end == maj)
continue;
-
/*
* Compare against our list and set the major
* number it it's a name we care about.
@@ -1484,3 +1485,18 @@ rule_zs(struct devices_ent *dep)
(void) closedir(dirp);
}
+
+/*
+ * is_blank() returns 1 (true) if a line specified is composed of
+ * whitespace characters only. otherwise, it returns 0 (false).
+ *
+ * Note. the argument (line) must be null-terminated.
+ */
+static int
+is_blank(char *line)
+{
+ for (/* nothing */; *line != '\0'; line++)
+ if (!isspace(*line))
+ return (0);
+ return (1);
+}
diff --git a/usr/src/ucbcmd/ucblinks/ucblinks.sh b/usr/src/ucbcmd/ucblinks/ucblinks.sh
index 974b542d82..ce5f5a88f7 100644
--- a/usr/src/ucbcmd/ucblinks/ucblinks.sh
+++ b/usr/src/ucbcmd/ucblinks/ucblinks.sh
@@ -3,9 +3,8 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
@@ -20,11 +19,11 @@
#
# CDDL HEADER END
#
-#
-# Copyright (c) 1991 by Sun Microsystems, Inc.
+
+# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
-#
PATH=/sbin:/usr/sbin:/usr/bin:/etc
export PATH
@@ -168,7 +167,11 @@ cat <<\!EOD >$GENSED
# "major number" field into its corresponding 'name'. This is so that
# the difference in major-numbers among different machines can be hidden.
#
-grep -v '^#' /etc/name_to_major | sed -e '1,$s-^\([^ ]*\)[ ][ ]*\([^ ][^ ]*\)$-/^\2 /s/^\2 /\1 /-' >>$GENSED
+nawk -v del='#' '$1 !~ /^#|^$/ { \
+ num = split($2, maj, del); \
+ if (num > 1) { printf("/^%s\t/ s/^%s\t/%s\t/\n", maj[1], maj[1], $1) } \
+ else { printf("/^%s\t/ s/^%s\t/%s\t/\n", $2, $2, $1) } \
+} ' /etc/name_to_major >> $GENSED
#
#----------------------------------------------------------------------