FreeBSD Bugzilla – Attachment 18439 Details for
Bug 33150
sbin/sysctl: allow setting dev_t values [patch included]
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.64 KB, created by
Thomas Quinot
on 2001-12-24 14:50:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Thomas Quinot
Created:
2001-12-24 14:50:00 UTC
Size:
1.64 KB
patch
obsolete
>--- sysctl.c.dist Mon Dec 24 15:39:37 2001 >+++ sysctl.c Mon Dec 24 15:36:18 2001 >@@ -49,6 +49,7 @@ > #include <sys/stat.h> > #include <sys/sysctl.h> > #include <sys/resource.h> >+#include <sys/param.h> > > #include <ctype.h> > #include <err.h> >@@ -66,6 +67,8 @@ > static int sysctl_all (int *oid, int len); > static int name2oid(char *, int *); > >+static void set_T_dev_t (char *, void **, int *); >+ > static void > usage(void) > { >@@ -153,7 +156,7 @@ > size_t newsize = 0; > quad_t quadval; > int mib[CTL_MAXNAME]; >- char *cp, *bufp, buf[BUFSIZ]; >+ char *cp, *bufp, buf[BUFSIZ], fmt[BUFSIZ]; > u_int kind; > > bufp = buf; >@@ -171,7 +174,7 @@ > if (len < 0) > errx(1, "unknown oid '%s'", bufp); > >- if (oidfmt(mib, len, 0, &kind)) >+ if (oidfmt(mib, len, fmt, &kind)) > err(1, "couldn't find format of oid '%s'", bufp); > > if (newval == NULL) { >@@ -217,6 +220,12 @@ > newval = &quadval; > newsize = sizeof(quadval); > break; >+ case CTLTYPE_OPAQUE: >+ if (strcmp(fmt, "T,dev_t") == 0) { >+ set_T_dev_t ((char*)newval, &newval, &newsize); >+ break; >+ } >+ /* FALLTHROUGH */ > default: > errx(1, "oid '%s' is type %d," > " cannot set that", bufp, >@@ -316,6 +325,27 @@ > major(*d), minor(*d)); > } > return (0); >+} >+ >+static void >+set_T_dev_t (char *path, void **val, int *size) >+{ >+ static struct stat statb; >+ >+ if (strcmp(path, "none") && strcmp(path, "off")) { >+ int rc = stat (path, &statb); >+ if (rc) { >+ err(1, "cannot stat %s", path); >+ } >+ >+ if (!S_ISCHR(statb.st_mode)) { >+ errx(1, "must specify a device special file."); >+ } >+ } else { >+ statb.st_rdev = NODEV; >+ } >+ *val = (char*) &statb.st_rdev; >+ *size = sizeof statb.st_rdev; > } > > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 33150
: 18439