summaryrefslogtreecommitdiff
path: root/usr/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib')
-rw-r--r--usr/src/lib/libdevinfo/devinfo_devperm.c27
-rw-r--r--usr/src/lib/lvm/libpreen/common/mdpreen.c28
-rw-r--r--usr/src/lib/lvm/libsvm/common/getdrvname.c35
-rw-r--r--usr/src/lib/lvm/libsvm/common/metaconf.c32
4 files changed, 101 insertions, 21 deletions
diff --git a/usr/src/lib/libdevinfo/devinfo_devperm.c b/usr/src/lib/libdevinfo/devinfo_devperm.c
index 5a52fc2a6c..412eb74fc8 100644
--- a/usr/src/lib/libdevinfo/devinfo_devperm.c
+++ b/usr/src/lib/libdevinfo/devinfo_devperm.c
@@ -32,6 +32,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
@@ -64,6 +65,8 @@ static int dir_dev_acc(char *, char *, uid_t, gid_t, mode_t, char *line,
static int setdevaccess(char *, uid_t, gid_t, mode_t, void (*)());
static void logerror(char *);
+static int is_blank(char *);
+
#define MAX_LINELEN 256
#define LOGINDEVPERM "/etc/logindevperm"
#define DIRWILD "/*" /* directory wildcard */
@@ -772,14 +775,21 @@ i_devfs_read_minor_perm(char *drvname, void (*errcb)(minorperm_err_t, int))
(*errcb)(MP_FOPEN_ERR, errno);
return (NULL);
}
- while (fgets(line, MAX_MINOR_PERM_LINE - 1, pfd) != NULL) {
+ while (fgets(line, MAX_MINOR_PERM_LINE, pfd) != NULL) {
ln++;
+ /* cut off comments starting with '#' */
+ if ((cp = strchr(line, '#')) != NULL)
+ *cp = '\0';
+ /* ignore comment or blank lines */
+ if (is_blank(line))
+ continue;
mp = (struct mperm *)calloc(1, sizeof (struct mperm));
if (mp == NULL) {
(*errcb)(MP_ALLOC_ERR, sizeof (struct mperm));
continue;
}
cp = line;
+ /* sanity-check */
if (getnexttoken(cp, &cp, &p, &t) == 0) {
(*errcb)(MP_IGNORING_LINE_ERR, ln);
devfs_free_minor_perm(mp);
@@ -1057,3 +1067,18 @@ devfs_rm_minor_perm(char *drv,
{
return (i_devfs_update_minor_perm(drv, MODREMMINORPERM, errcb));
}
+
+/*
+ * 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/lib/lvm/libpreen/common/mdpreen.c b/usr/src/lib/lvm/libpreen/common/mdpreen.c
index 6b659dc154..252a1b2768 100644
--- a/usr/src/lib/lvm/libpreen/common/mdpreen.c
+++ b/usr/src/lib/lvm/libpreen/common/mdpreen.c
@@ -36,6 +36,7 @@
* filesystems that are on top of metadevices.
*/
+#include <ctype.h>
#include <meta.h>
#include <limits.h>
#include <sys/types.h>
@@ -61,6 +62,23 @@ extern void preen_addunit(void *cookie, char *dname, int (*cf)(),
void *datap, uint_t unit);
extern int preen_subdev(char *name, struct dk_cinfo *dkiop, void *dp);
+static int is_blank(char *);
+
+/*
+ * 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);
+}
+
static int
get_major_from_n2m(char *modname, int *major)
{
@@ -68,7 +86,7 @@ get_major_from_n2m(char *modname, int *major)
char drv[FILENAME_MAX + 1];
int entry;
int found = 0;
- char line[MAX_N2M_ALIAS_LINE];
+ char line[MAX_N2M_ALIAS_LINE], *cp;
int status = 0;
if ((fp = fopen(NAME_TO_MAJOR, "r")) == NULL) {
@@ -77,7 +95,13 @@ get_major_from_n2m(char *modname, int *major)
while ((fgets(line, sizeof (line), fp) != NULL) &&
status == 0) {
-
+ /* cut off comments starting with '#' */
+ if ((cp = strchr(line, '#')) != NULL)
+ *cp = '\0';
+ /* ignore comment or blank lines */
+ if (is_blank(line))
+ continue;
+ /* sanity-check */
if (sscanf(line, "%" VAL2STR(FILENAME_MAX) "s %d",
drv, &entry) != 2) {
status = -1;
diff --git a/usr/src/lib/lvm/libsvm/common/getdrvname.c b/usr/src/lib/lvm/libsvm/common/getdrvname.c
index 9bef7fa115..a24b85e040 100644
--- a/usr/src/lib/lvm/libsvm/common/getdrvname.c
+++ b/usr/src/lib/lvm/libsvm/common/getdrvname.c
@@ -2,9 +2,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,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -28,6 +27,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <sys/types.h>
@@ -42,6 +42,23 @@
#define QUOTE(x) #x
#define VAL2STR(x) QUOTE(x)
+static int is_blank(char *);
+
+/*
+ * 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);
+}
+
/*
* FUNCTION:
* Return the driver name for a major number
@@ -61,7 +78,7 @@ get_drv_name(major_t major, char *mnt, char *buf)
FILE *fp;
char drv[FILENAME_MAX + 1];
char entry[FILENAME_MAX + 1];
- char line[MAX_N2M_ALIAS_LINE];
+ char line[MAX_N2M_ALIAS_LINE], *cp;
char fname[PATH_MAX];
int status = RET_NOERROR;
@@ -73,6 +90,13 @@ get_drv_name(major_t major, char *mnt, char *buf)
while ((fgets(line, sizeof (line), fp) != NULL) &&
status == RET_NOERROR) {
+ /* cut off comments starting with '#' */
+ if ((cp = strchr(line, '#')) != NULL)
+ *cp = '\0';
+ /* ignore comment or blank lines */
+ if (is_blank(line))
+ continue;
+ /* sanity-check */
if (sscanf(line,
"%" VAL2STR(FILENAME_MAX) "s %" VAL2STR(FILENAME_MAX) "s",
drv, entry) != 2) {
@@ -80,7 +104,6 @@ get_drv_name(major_t major, char *mnt, char *buf)
}
if (atoi(entry) == major)
break;
-
}
if (status == RET_NOERROR)
diff --git a/usr/src/lib/lvm/libsvm/common/metaconf.c b/usr/src/lib/lvm/libsvm/common/metaconf.c
index 504f38ba73..11bca39ed8 100644
--- a/usr/src/lib/lvm/libsvm/common/metaconf.c
+++ b/usr/src/lib/lvm/libsvm/common/metaconf.c
@@ -2,9 +2,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,7 +19,7 @@
* CDDL HEADER END
*/
/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
@@ -46,13 +45,20 @@
extern int _map_to_effective_dev();
-int
-is_blankline(char *buf)
+static int is_blank(char *);
+
+/*
+ * 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 (; *buf != 0; buf++) {
- if (!isspace(*buf))
+ for (/* nothing */; *line != '\0'; line++)
+ if (!isspace(*line))
return (0);
- }
return (1);
}
@@ -87,9 +93,11 @@ write_targ_nm_table(char *path)
while (fgets(buf, PATH_MAX, targfp) != NULL &&
(retval == RET_SUCCESS)) {
- cp = strrchr(buf, '\n');
- *cp = 0;
- if (is_blankline(buf))
+ /* cut off comments starting with '#' */
+ if ((cp = strchr(buf, '#')) != NULL)
+ *cp = 0;
+ /* ignore comment or blank lines */
+ if (is_blank(buf))
continue;
if (first_entry) {
if (fprintf(mdfp, "md_targ_nm_table=\"%s\"", buf) < 0)