summaryrefslogtreecommitdiffstats
path: root/lib/libdisk/create_chunk.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1999-12-15 08:33:56 +0000
committerjkh <jkh@FreeBSD.org>1999-12-15 08:33:56 +0000
commit19ab44d39bd7d4ec22f8b3ae1b32f2394a5b25e6 (patch)
treed5caed3caf8965d12c03559d9f7c14d3fa46a1a7 /lib/libdisk/create_chunk.c
parent0c150ca4f78e5066e775859d5d37aaa79ae95504 (diff)
downloadFreeBSD-src-19ab44d39bd7d4ec22f8b3ae1b32f2394a5b25e6.zip
FreeBSD-src-19ab44d39bd7d4ec22f8b3ae1b32f2394a5b25e6.tar.gz
Catch up to the fact that block devices are toast.
Teach about the afd driver. Teach new char dev for ad driver. Make ownerships correct. Submitted by: jhb
Diffstat (limited to 'lib/libdisk/create_chunk.c')
-rw-r--r--lib/libdisk/create_chunk.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/lib/libdisk/create_chunk.c b/lib/libdisk/create_chunk.c
index 95b10ae..47b1e41 100644
--- a/lib/libdisk/create_chunk.c
+++ b/lib/libdisk/create_chunk.c
@@ -23,6 +23,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <err.h>
+#include <grp.h>
+#include <pwd.h>
#include "libdisk.h"
/* Clone these two from sysinstall because we need our own copies
@@ -216,7 +218,7 @@ Create_Chunk_DWIM(struct disk *d, struct chunk *parent , u_long size, chunk_e ty
{
int i;
struct chunk *c1;
- u_long offset,edge;
+ u_long offset;
if (!parent)
parent = d->chunks;
@@ -242,8 +244,10 @@ int
MakeDev(struct chunk *c1, const char *path)
{
char *p = c1->name;
- u_long cmaj, bmaj, min, unit, part, slice;
+ u_long cmaj, min, unit, part, slice;
char buf[BUFSIZ], buf2[BUFSIZ];
+ struct group *grp;
+ struct passwd *pwd;
*buf2 = '\0';
if (isDebug())
@@ -252,21 +256,23 @@ MakeDev(struct chunk *c1, const char *path)
return 0;
if (!strncmp(p, "wd", 2))
- bmaj = 0, cmaj = 3, p += 2;
- else if (!strncmp(p, "ad", 2)) /* XXX change if "ad' moves */
- bmaj = 0, cmaj = 3, p += 2;
+ cmaj = 3, p += 2;
+ else if (!strncmp(p, "ad", 2))
+ cmaj = 116, p += 2;
else if (!strncmp(p, "wfd", 3))
- bmaj = 1, cmaj = 87, p += 3;
+ cmaj = 87, p += 3;
+ else if (!strncmp(p, "afd", 3))
+ cmaj = 118, p += 3;
else if (!strncmp(p, "fla", 3))
- bmaj = 28, cmaj = 102, p += 3;
+ cmaj = 102, p += 3;
else if (!strncmp(p, "ida", 3))
- bmaj = 29, cmaj = 109, p += 3;
+ cmaj = 109, p += 3;
else if (!strncmp(p, "mlxd", 4))
- bmaj = 27, cmaj = 131, p += 4;
+ cmaj = 131, p += 4;
else if (!strncmp(p, "amrd", 4))
- bmaj = 35, cmaj = 133, p += 4;
+ cmaj = 133, p += 4;
else if (!strncmp(p, "da", 2)) /* CAM support */
- bmaj = 4, cmaj = 13, p += 2;
+ cmaj = 13, p += 2;
else {
msgDebug("MakeDev: Unknown major/minor for devtype %s\n", p);
return 0;
@@ -326,6 +332,14 @@ MakeDev(struct chunk *c1, const char *path)
return 0;
if (slice > 32)
return 0;
+ if ((pwd = getpwnam("root")) == NULL) {
+ msgDebug("MakeDev: Unable to lookup user \"root\".\n");
+ return 0;
+ }
+ if ((grp = getgrnam("operator")) == NULL) {
+ msgDebug("MakeDev: Unable to lookup group \"operator\".\n");
+ return 0;
+ }
min = unit * 8 + 65536 * slice + part;
sprintf(buf, "%s/r%s", path, c1->name);
unlink(buf);
@@ -333,6 +347,10 @@ MakeDev(struct chunk *c1, const char *path)
msgDebug("mknod of %s returned failure status!\n", buf);
return 0;
}
+ if (chown(buf, pwd->pw_uid, grp->gr_gid) == -1) {
+ msgDebug("chown of %s returned failure status!\n", buf);
+ return 0;
+ }
if (*buf2) {
sprintf(buf, "%s/r%s", path, buf2);
unlink(buf);
@@ -340,13 +358,21 @@ MakeDev(struct chunk *c1, const char *path)
msgDebug("mknod of %s returned failure status!\n", buf);
return 0;
}
+ if (chown(buf, pwd->pw_uid, grp->gr_gid) == -1) {
+ msgDebug("chown of %s returned failure status!\n", buf);
+ return 0;
+ }
}
sprintf(buf, "%s/%s", path, c1->name);
unlink(buf);
- if (mknod(buf, S_IFBLK|0640, makedev(bmaj,min)) == -1) {
+ if (mknod(buf, S_IFCHR|0640, makedev(cmaj,min)) == -1) {
msgDebug("mknod of %s returned failure status!\n", buf);
return 0;
}
+ if (chown(buf, pwd->pw_uid, grp->gr_gid) == -1) {
+ msgDebug("chown of %s returned failure status!\n", buf);
+ return 0;
+ }
return 1;
}
OpenPOWER on IntegriCloud