summaryrefslogtreecommitdiff
path: root/usr/src/cmd/dlmgmtd
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2014-05-08 19:00:31 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2014-05-08 19:00:31 +0000
commit754b7a58f94ec91fcde6cd0aca8005af5a9c1a18 (patch)
treed966b72c8a48261ac3bc84f5e78a1513c9b28538 /usr/src/cmd/dlmgmtd
parent767eb24810b90c47c63078228bc2b4685151cc01 (diff)
downloadillumos-joyent-754b7a58f94ec91fcde6cd0aca8005af5a9c1a18.tar.gz
OS-3007 dlmgmtd needs to work with non-native zones
Diffstat (limited to 'usr/src/cmd/dlmgmtd')
-rw-r--r--usr/src/cmd/dlmgmtd/dlmgmt_db.c14
-rw-r--r--usr/src/cmd/dlmgmtd/dlmgmt_main.c27
2 files changed, 33 insertions, 8 deletions
diff --git a/usr/src/cmd/dlmgmtd/dlmgmt_db.c b/usr/src/cmd/dlmgmtd/dlmgmt_db.c
index a2000ff3b5..a80a988213 100644
--- a/usr/src/cmd/dlmgmtd/dlmgmt_db.c
+++ b/usr/src/cmd/dlmgmtd/dlmgmt_db.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, Joyent Inc. All rights reserved.
+ * Copyright 2014, Joyent Inc. All rights reserved.
*/
#include <assert.h>
@@ -1415,7 +1415,7 @@ zone_file_exists(char *zoneroot, char *filename)
struct stat sb;
char fname[MAXPATHLEN];
- (void) snprintf(fname, sizeof (fname), "%s/%s", zoneroot, filename);
+ (void) snprintf(fname, sizeof (fname), "%s/%s", zoneroot, filename);
if (stat(fname, &sb) == -1)
return (B_FALSE);
@@ -1440,6 +1440,14 @@ dlmgmt_db_init(zoneid_t zoneid, char *zoneroot)
DATALINK_INVALID_LINKID, zoneid, DLMGMT_ACTIVE, &err)) == NULL)
return (err);
+ /* Handle running in a non-native branded zone (i.e. has /native) */
+ if (zone_file_exists(zoneroot, "/native" DLMGMT_TMPFS_DIR)) {
+ char tdir[MAXPATHLEN];
+
+ (void) snprintf(tdir, sizeof (tdir), "/native%s", cachefile);
+ (void) strlcpy(cachefile, tdir, sizeof (cachefile));
+ }
+
if (zone_file_exists(zoneroot, cachefile)) {
if ((err = dlmgmt_process_db_req(req)) != 0) {
/*
@@ -1512,7 +1520,7 @@ dlmgmt_db_fini(zoneid_t zoneid)
*/
if (onloan)
(void) dlmgmt_delete_db_entry(linkp,
- DLMGMT_ACTIVE);
+ DLMGMT_ACTIVE);
(void) dlmgmt_destroy_common(linkp,
DLMGMT_ACTIVE | DLMGMT_PERSIST);
diff --git a/usr/src/cmd/dlmgmtd/dlmgmt_main.c b/usr/src/cmd/dlmgmtd/dlmgmt_main.c
index e0c179cf5e..d8397cc0e6 100644
--- a/usr/src/cmd/dlmgmtd/dlmgmt_main.c
+++ b/usr/src/cmd/dlmgmtd/dlmgmt_main.c
@@ -22,7 +22,7 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
- * Copyright 2012 Joyent, Inc. All rights reserved.
+ * Copyright 2014 Joyent, Inc. All rights reserved.
*/
/*
@@ -132,9 +132,18 @@ dlmgmt_door_attach(zoneid_t zoneid, char *rootdir)
int fd;
int err = 0;
char doorpath[MAXPATHLEN];
+ struct stat statbuf;
- (void) snprintf(doorpath, sizeof (doorpath), "%s%s", rootdir,
- DLMGMT_DOOR);
+ /* Handle running in a non-native branded zone (i.e. has /native) */
+ (void) snprintf(doorpath, sizeof (doorpath), "%s/native%s",
+ rootdir, DLMGMT_TMPFS_DIR);
+ if (stat(doorpath, &statbuf) == 0) {
+ (void) snprintf(doorpath, sizeof (doorpath), "%s/native%s",
+ rootdir, DLMGMT_DOOR);
+ } else {
+ (void) snprintf(doorpath, sizeof (doorpath), "%s%s",
+ rootdir, DLMGMT_DOOR);
+ }
/*
* Create the door file for dlmgmtd.
@@ -193,8 +202,16 @@ dlmgmt_zone_init(zoneid_t zoneid)
(void) snprintf(tmpfsdir, sizeof (tmpfsdir), "%s%s", rootdir,
DLMGMT_TMPFS_DIR);
if (stat(tmpfsdir, &statbuf) < 0) {
- if (mkdir(tmpfsdir, (mode_t)0755) < 0)
- return (errno);
+ if (mkdir(tmpfsdir, (mode_t)0755) < 0) {
+ /*
+ * Handle running in a non-native branded zone
+ * (i.e. has /native)
+ */
+ (void) snprintf(tmpfsdir, sizeof (tmpfsdir),
+ "%s/native%s", rootdir, DLMGMT_TMPFS_DIR);
+ if (mkdir(tmpfsdir, (mode_t)0755) < 0)
+ return (errno);
+ }
} else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) {
return (ENOTDIR);
}