Print this page
PSARC 2008/290 lofi mount
6384817 Need persistent lofi based mounts and direct mount(1m) support for lofi
*** 22,32 ****
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
! #pragma ident "@(#)zoneadm.c 1.64 08/01/14 SMI"
/*
* zoneadm is a command interpreter for zone administration. It is all in
* C (i.e., no lex/yacc), and all the argument passing is argc/argv based.
* main() calls parse_and_run() which calls cmd_match(), then invokes the
--- 22,32 ----
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
! #pragma ident "@(#)zoneadm.c 1.65 08/05/07 SMI"
/*
* zoneadm is a command interpreter for zone administration. It is all in
* C (i.e., no lex/yacc), and all the argument passing is argc/argv based.
* main() calls parse_and_run() which calls cmd_match(), then invokes the
*** 2435,2445 ****
* Verify that the special device/file system exists and is valid.
*/
static int
verify_fs_special(struct zone_fstab *fstab)
{
! struct stat st;
/*
* This validation is really intended for standard zone administration.
* If we are in a mini-root or some other upgrade situation where
* we are using the scratch zone, just by-pass this.
--- 2435,2445 ----
* Verify that the special device/file system exists and is valid.
*/
static int
verify_fs_special(struct zone_fstab *fstab)
{
! struct stat64 st;
/*
* This validation is really intended for standard zone administration.
* If we are in a mini-root or some other upgrade situation where
* we are using the scratch zone, just by-pass this.
*** 2448,2458 ****
return (Z_OK);
if (strcmp(fstab->zone_fs_type, MNTTYPE_ZFS) == 0)
return (verify_fs_zfs(fstab));
! if (stat(fstab->zone_fs_special, &st) != 0) {
(void) fprintf(stderr, gettext("could not verify fs "
"%s: could not access %s: %s\n"), fstab->zone_fs_dir,
fstab->zone_fs_special, strerror(errno));
return (Z_ERR);
}
--- 2448,2458 ----
return (Z_OK);
if (strcmp(fstab->zone_fs_type, MNTTYPE_ZFS) == 0)
return (verify_fs_zfs(fstab));
! if (stat64(fstab->zone_fs_special, &st) != 0) {
(void) fprintf(stderr, gettext("could not verify fs "
"%s: could not access %s: %s\n"), fstab->zone_fs_dir,
fstab->zone_fs_special, strerror(errno));
return (Z_ERR);
}
*** 2472,2481 ****
--- 2472,2492 ----
return (Z_OK);
}
static int
+ isregfile(const char *path)
+ {
+ struct stat64 st;
+
+ if (stat64(path, &st) == -1)
+ return (-1);
+
+ return (S_ISREG(st.st_mode));
+ }
+
+ static int
verify_filesystems(zone_dochandle_t handle)
{
int return_code = Z_OK;
struct zone_fstab fstab;
char cmdbuf[MAXPATHLEN];
*** 2527,2562 ****
fstab.zone_fs_dir, cmdbuf);
return_code = Z_ERR;
goto next_fs;
}
/*
! * Verify /usr/lib/fs/<fstype>/fsck exists iff zone_fs_raw is
! * set.
*/
if (snprintf(cmdbuf, sizeof (cmdbuf), "/usr/lib/fs/%s/fsck",
fstab.zone_fs_type) > sizeof (cmdbuf)) {
(void) fprintf(stderr, gettext("cannot verify fs %s: "
"type %s is too long.\n"), fstab.zone_fs_dir,
fstab.zone_fs_type);
return_code = Z_ERR;
goto next_fs;
}
- if (fstab.zone_fs_raw[0] == '\0' && stat(cmdbuf, &st) == 0) {
- (void) fprintf(stderr, gettext("could not verify fs "
- "%s: must specify 'raw' device for %s "
- "file systems\n"),
- fstab.zone_fs_dir, fstab.zone_fs_type);
- return_code = Z_ERR;
- goto next_fs;
- }
if (fstab.zone_fs_raw[0] != '\0' &&
(stat(cmdbuf, &st) != 0 || !S_ISREG(st.st_mode))) {
(void) fprintf(stderr, gettext("cannot verify fs %s: "
"'raw' device specified but "
"no fsck executable exists for %s\n"),
fstab.zone_fs_dir, fstab.zone_fs_type);
return_code = Z_ERR;
goto next_fs;
}
/* Verify fs_special. */
if ((return_code = verify_fs_special(&fstab)) != Z_OK)
--- 2538,2576 ----
fstab.zone_fs_dir, cmdbuf);
return_code = Z_ERR;
goto next_fs;
}
/*
! * If zone_fs_raw is set, verify that there's an fsck
! * binary for it. If zone_fs_raw is not set, and it's
! * not a regular file (lofi mount), and there's an fsck
! * binary for it, complain.
*/
if (snprintf(cmdbuf, sizeof (cmdbuf), "/usr/lib/fs/%s/fsck",
fstab.zone_fs_type) > sizeof (cmdbuf)) {
(void) fprintf(stderr, gettext("cannot verify fs %s: "
"type %s is too long.\n"), fstab.zone_fs_dir,
fstab.zone_fs_type);
return_code = Z_ERR;
goto next_fs;
}
if (fstab.zone_fs_raw[0] != '\0' &&
(stat(cmdbuf, &st) != 0 || !S_ISREG(st.st_mode))) {
(void) fprintf(stderr, gettext("cannot verify fs %s: "
"'raw' device specified but "
"no fsck executable exists for %s\n"),
fstab.zone_fs_dir, fstab.zone_fs_type);
return_code = Z_ERR;
+ goto next_fs;
+ } else if (fstab.zone_fs_raw[0] == '\0' &&
+ stat(cmdbuf, &st) == 0 &&
+ isregfile(fstab.zone_fs_special) != 1) {
+ (void) fprintf(stderr, gettext("could not verify fs "
+ "%s: must specify 'raw' device for %s "
+ "file systems\n"),
+ fstab.zone_fs_dir, fstab.zone_fs_type);
+ return_code = Z_ERR;
goto next_fs;
}
/* Verify fs_special. */
if ((return_code = verify_fs_special(&fstab)) != Z_OK)