summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-illumos/debian/patches/prtvtoc-avoid-libadm.patch515
-rw-r--r--util-illumos/debian/patches/prtvtoc-no-etc.patch13
-rw-r--r--util-illumos/debian/patches/series2
-rwxr-xr-xutil-illumos/debian/rules7
-rw-r--r--util-illumos/debian/util-illumos.install1
-rw-r--r--util-illumos/debian/util-illumos.manpages1
6 files changed, 536 insertions, 3 deletions
diff --git a/util-illumos/debian/patches/prtvtoc-avoid-libadm.patch b/util-illumos/debian/patches/prtvtoc-avoid-libadm.patch
new file mode 100644
index 0000000..38eac79
--- /dev/null
+++ b/util-illumos/debian/patches/prtvtoc-avoid-libadm.patch
@@ -0,0 +1,515 @@
+Index: util-illumos/usr/src/cmd/prtvtoc/Makefile
+===================================================================
+--- util-illumos.orig/usr/src/cmd/prtvtoc/Makefile 2012-10-08 00:25:33.000000000 +0000
++++ util-illumos/usr/src/cmd/prtvtoc/Makefile 2013-01-15 20:59:44.011425370 +0000
+@@ -30,7 +30,7 @@
+
+ RELUSRSBIN= ../usr/sbin
+ ROOTSYMLINK= $(ROOTETC)/$(PROG)
+-LDLIBS += -ladm -lefi
++LDLIBS += -lefi
+
+ CERRWARN += -_gcc=-Wno-parentheses
+ CERRWARN += -_gcc=-Wno-uninitialized
+Index: util-illumos/usr/src/cmd/prtvtoc/prtvtoc.c
+===================================================================
+--- util-illumos.orig/usr/src/cmd/prtvtoc/prtvtoc.c 2012-10-08 00:25:33.000000000 +0000
++++ util-illumos/usr/src/cmd/prtvtoc/prtvtoc.c 2013-01-15 21:11:41.997350205 +0000
+@@ -40,6 +40,7 @@
+ #include <unistd.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <strings.h>
+ #include <stdio.h>
+ #include <limits.h>
+
+@@ -50,6 +51,12 @@
+ #include <sys/mnttab.h>
+ #include <sys/vfstab.h>
+ #include <sys/mkdev.h>
++#include <sys/param.h>
++#include <sys/lofi.h>
++#include <sys/ramdisk.h>
++#include <sys/fssnap_if.h>
++
++#define GET_RAW 1
+
+ #include <sys/efi_partition.h>
+ /*
+@@ -90,10 +97,6 @@
+ static char *safe_strdup(char *);
+
+ /*
+- * External variables.
+- */
+-extern char *getfullrawname();
+-/*
+ * Static variables.
+ */
+ static short fflag; /* Print freespace shell assignments */
+@@ -103,6 +106,239 @@
+ static char *mnttab = MNTTAB; /* mnttab pathname */
+ static char *progname; /* Last qualifier of arg0 */
+
++/*
++ * getfullname() - Builds a fully qualified pathname.
++ * This handles . and .. as well.
++ * NOTE: This is different from realpath(3C) because
++ * it does not follow links.
++ */
++static char *
++getfullname(char *path)
++{
++ char cwd[MAXPATHLEN];
++ char *c;
++ char *wa;
++ size_t len;
++
++ if (*path == '/')
++ return (strdup(path));
++
++ if (getcwd(cwd, sizeof (cwd)) == NULL)
++ return (strdup(""));
++
++ /* handle . and .. */
++ if (strncmp(path, "./", 2) == 0) {
++ /* strip the ./ from the given path */
++ path += 2;
++ } else if (strncmp(path, "../", 3) == 0) {
++ /* strip the last directory component from cwd */
++ c = strrchr(cwd, '/');
++ *c = '\0';
++
++ /* strip the ../ from the given path */
++ path += 3;
++ }
++
++ /*
++ * Adding 2 takes care of slash and null terminator.
++ */
++ len = strlen(cwd) + strlen(path) + 2;
++ if ((wa = malloc(len)) == NULL)
++ return (NULL);
++
++ (void) strcpy(wa, cwd);
++ (void) strcat(wa, "/");
++ (void) strcat(wa, path);
++
++ return (wa);
++}
++
++/*
++ * test the path/fname to see if is char special
++ */
++static int
++test_if_raw(char *new_path, dev_t blk_dev)
++{
++ struct stat64 buf;
++
++ /* check if we got a char special file */
++ if (stat64(new_path, &buf) != 0)
++ return (0);
++
++ if (!S_ISCHR(buf.st_mode))
++ return (0);
++
++ if (blk_dev != buf.st_rdev)
++ return (0);
++
++ return (1);
++}
++
++/*
++ * complete getfullrawname() for raw->blk to handle volmgt devices
++ */
++
++static char *
++getrawcomplete(char *cp, struct stat64 *dat)
++{
++ char *dp;
++ char *new_path;
++ char c;
++
++ /* ok, so we either have a bad device or a floppy */
++
++ /* try the fd# form */
++ if ((dp = strstr(cp, "/fd")) != NULL) {
++ /* malloc path for new_path to hold raw */
++ if ((new_path = malloc(strlen(cp)+2)) == NULL)
++ return (NULL);
++
++ c = *++dp; /* save the 'f' */
++ *dp = '\0'; /* replace it with a null */
++ (void) strcpy(new_path, cp); /* save first part of it */
++ *dp = c; /* put the 'f' back */
++ (void) strcat(new_path, "r"); /* insert an 'r' */
++ (void) strcat(new_path, dp); /* copy the rest */
++
++ if (test_if_raw(new_path, dat->st_rdev))
++ return (new_path);
++
++ free(new_path);
++ }
++
++ /* try the diskette form */
++ if ((dp = strstr(cp, "/diskette")) != NULL) {
++ /* malloc path for new_path to hold raw */
++ if ((new_path = malloc(strlen(cp)+2)) == NULL)
++ return (NULL);
++
++ c = *++dp; /* save at 'd' */
++ *dp = '\0'; /* replace it with a null */
++ (void) strcpy(new_path, cp); /* save first part */
++ *dp = c; /* put the 'd' back */
++ (void) strcat(new_path, "r"); /* insert an 'r' */
++ (void) strcat(new_path, dp); /* copy the rest */
++
++ if (test_if_raw(new_path, dat->st_rdev))
++ return (new_path);
++
++ free(new_path);
++ return (strdup(""));
++ }
++
++ /* failed to build raw name, return null string */
++ return (strdup(""));
++
++}
++
++
++static char *
++getvfsspecial(char *path, int raw_special)
++{
++ FILE *fp;
++ struct vfstab vp;
++ struct vfstab ref_vp;
++
++ if ((fp = fopen("/etc/vfstab", "r")) == NULL)
++ return (NULL);
++
++ (void) memset(&ref_vp, 0, sizeof (struct vfstab));
++
++ if (raw_special)
++ ref_vp.vfs_special = path;
++ else
++ ref_vp.vfs_fsckdev = path;
++
++ if (getvfsany(fp, &vp, &ref_vp)) {
++ (void) fclose(fp);
++ return (NULL);
++ }
++
++ (void) fclose(fp);
++
++ if (raw_special)
++ return (vp.vfs_fsckdev);
++
++ return (vp.vfs_special);
++}
++
++/*
++ * change the device name to a raw devname
++ */
++static char *
++__getfullrawname(char *cp)
++{
++ struct stat64 buf;
++ char *dp;
++ char *new_path;
++ dev_t blk_dev;
++
++ if (cp == NULL)
++ return (strdup(""));
++
++ /*
++ * Create a fully qualified name.
++ */
++ if ((cp = getfullname(cp)) == NULL)
++ return (NULL);
++
++ if (*cp == '\0')
++ return (cp);
++
++ if (stat64(cp, &buf) != 0) {
++ free(cp);
++ return (strdup(""));
++ }
++
++ if (S_ISCHR(buf.st_mode))
++ return (cp);
++
++ if (!S_ISBLK(buf.st_mode)) {
++ free(cp);
++ return (strdup(""));
++ }
++
++ blk_dev = buf.st_rdev;
++
++ if ((dp = getvfsspecial(cp, GET_RAW)) != NULL) {
++ free(cp);
++ return (strdup(dp));
++ }
++
++ /*
++ * We have a block device name, go find the raw name.
++ */
++ if ((dp = strstr(cp, "/dsk/")) == NULL &&
++ (dp = strstr(cp, "/" LOFI_BLOCK_NAME "/")) == NULL &&
++ (dp = strstr(cp, "/" RD_BLOCK_NAME "/")) == NULL &&
++ (dp = strstr(cp, "/" SNAP_BLOCK_NAME "/")) == NULL &&
++ (dp = strrchr(cp, '/')) == NULL) {
++ /* this is not really possible */
++ free(cp);
++ return (strdup(""));
++ }
++ dp++;
++
++ if ((new_path = malloc(strlen(cp)+2)) == NULL) {
++ free(cp);
++ return (NULL);
++ }
++ (void) strncpy(new_path, cp, dp - cp);
++ /* fill in the rest of the raw name */
++ new_path[dp - cp] = 'r';
++ (void) strcpy(new_path + (dp - cp) + 1, dp);
++
++ if (test_if_raw(new_path, blk_dev)) {
++ free(cp);
++ return (new_path);
++ }
++ free(new_path);
++
++ dp = getrawcomplete(cp, &buf);
++ free(cp);
++ return (dp);
++}
++
+ int
+ main(int ac, char **av)
+ {
+@@ -373,7 +609,7 @@
+ int newvtoc = 0;
+ struct dk_gpt *efi;
+
+- name = getfullrawname(devname);
++ name = __getfullrawname(devname);
+ if (name == NULL)
+ return (warn(devname,
+ "internal administrative call (getfullrawname) failed"));
+@@ -600,6 +836,207 @@
+ }
+ return (0);
+ }
++#define libadm_vtoc_copy(vs, vd) \
++ { \
++ int i; \
++ vd->v_bootinfo[0] = (unsigned)vs->v_bootinfo[0]; \
++ vd->v_bootinfo[1] = (unsigned)vs->v_bootinfo[1]; \
++ vd->v_bootinfo[2] = (unsigned)vs->v_bootinfo[2]; \
++ vd->v_sanity = (unsigned)vs->v_sanity; \
++ vd->v_version = (unsigned)vs->v_version; \
++ bcopy(vs->v_volume, vd->v_volume, LEN_DKL_VVOL); \
++ vd->v_sectorsz = vs->v_sectorsz; \
++ vd->v_nparts = vs->v_nparts; \
++ vd->v_version = (unsigned)vs->v_version; \
++ for (i = 0; i < 10; i++) \
++ vd->v_reserved[i] = (unsigned)vs->v_reserved[i];\
++ for (i = 0; i < V_NUMPAR; i++) { \
++ vd->v_part[i].p_tag = vs->v_part[i].p_tag; \
++ vd->v_part[i].p_flag = vs->v_part[i].p_flag; \
++ vd->v_part[i].p_start = (unsigned)vs->v_part[i].p_start;\
++ vd->v_part[i].p_size = (unsigned)vs->v_part[i].p_size; \
++ } \
++ for (i = 0; i < V_NUMPAR; i++) \
++ if ((sizeof (vd->timestamp[i]) != sizeof (vs->timestamp[i])) &&\
++ (vs->timestamp[i] > INT32_MAX)) \
++ vd->timestamp[i] = INT32_MAX; \
++ else \
++ vd->timestamp[i] = (unsigned)vs->timestamp[i]; \
++ bcopy(vs->v_asciilabel, vd->v_asciilabel, LEN_DKL_ASCII); \
++ }
++/*
++ * Read VTOC - return partition number.
++ */
++static int
++__read_vtoc(int fd, struct vtoc *vtoc)
++{
++ struct dk_cinfo dki_info;
++
++ /*
++ * Read the vtoc.
++ */
++ if (ioctl(fd, DKIOCGVTOC, (caddr_t)vtoc) == -1) {
++ switch (errno) {
++ case EIO:
++ return (VT_EIO);
++ case EINVAL:
++ return (VT_EINVAL);
++ case ENOTSUP:
++ /* GPT labeled or disk > 1TB with no extvtoc support */
++ return (VT_ENOTSUP);
++ case EOVERFLOW:
++ return (VT_EOVERFLOW);
++ default:
++ return (VT_ERROR);
++ }
++ }
++
++ /*
++ * Sanity-check the vtoc.
++ */
++ if (vtoc->v_sanity != VTOC_SANE) {
++ return (VT_EINVAL);
++ }
++
++ /*
++ * Convert older-style vtoc's.
++ */
++ switch (vtoc->v_version) {
++ case 0:
++ /*
++ * No vtoc information. Install default
++ * nparts/sectorsz and version. We are
++ * assuming that the driver returns the
++ * current partition information correctly.
++ */
++
++ vtoc->v_version = V_VERSION;
++ if (vtoc->v_nparts == 0)
++ vtoc->v_nparts = V_NUMPAR;
++ if (vtoc->v_sectorsz == 0)
++ vtoc->v_sectorsz = DEV_BSIZE;
++
++ break;
++
++ case V_VERSION:
++ break;
++
++ default:
++ return (VT_EINVAL);
++ }
++
++ /*
++ * Return partition number for this file descriptor.
++ */
++ if (ioctl(fd, DKIOCINFO, (caddr_t)&dki_info) == -1) {
++ switch (errno) {
++ case EIO:
++ return (VT_EIO);
++ case EINVAL:
++ return (VT_EINVAL);
++ default:
++ return (VT_ERROR);
++ }
++ }
++ if (dki_info.dki_partition > V_NUMPAR) {
++ return (VT_EINVAL);
++ }
++ return ((int)dki_info.dki_partition);
++}
++
++static int
++__read_extvtoc(int fd, struct extvtoc *extvtoc)
++{
++ struct dk_cinfo dki_info;
++ struct vtoc oldvtoc;
++ struct vtoc *oldvtocp = &oldvtoc;
++ int ret;
++
++ /*
++ * Read the vtoc.
++ */
++ if (ioctl(fd, DKIOCGEXTVTOC, (caddr_t)extvtoc) == -1) {
++ switch (errno) {
++ case EIO:
++ return (VT_EIO);
++ case EINVAL:
++ return (VT_EINVAL);
++ /* for disks > 1TB */
++ case ENOTSUP:
++ return (VT_ENOTSUP);
++ case EOVERFLOW:
++ return (VT_EOVERFLOW);
++ case ENOTTY:
++
++ if ((ret = __read_vtoc(fd, oldvtocp)) < 0)
++ return (ret);
++
++#ifdef _LP64
++ /*
++ * 64-bit vtoc and extvtoc have the same field sizes
++ * and offsets.
++ */
++ bcopy(oldvtocp, extvtoc, sizeof (struct extvtoc));
++#else
++ bzero(extvtoc, sizeof (struct extvtoc));
++ libadm_vtoc_copy(oldvtocp, extvtoc);
++#endif
++ return (ret);
++
++
++ default:
++ return (VT_ERROR);
++ }
++ }
++
++ /*
++ * Sanity-check the vtoc.
++ */
++ if (extvtoc->v_sanity != VTOC_SANE) {
++ return (VT_EINVAL);
++ }
++
++ switch (extvtoc->v_version) {
++ case 0:
++ /*
++ * For pre-version 1 vtoc keep same functionality
++ * as read_vtoc.
++ */
++
++ extvtoc->v_version = V_VERSION;
++ if (extvtoc->v_nparts == 0)
++ extvtoc->v_nparts = V_NUMPAR;
++ if (extvtoc->v_sectorsz == 0)
++ extvtoc->v_sectorsz = DEV_BSIZE;
++
++ break;
++
++ case V_VERSION:
++ break;
++
++ default:
++ return (VT_EINVAL);
++ }
++
++ /*
++ * Return partition number for this file descriptor.
++ */
++ if (ioctl(fd, DKIOCINFO, (caddr_t)&dki_info) == -1) {
++ switch (errno) {
++ case EIO:
++ return (VT_EIO);
++ case EINVAL:
++ return (VT_EINVAL);
++ default:
++ return (VT_ERROR);
++ }
++ }
++ if (dki_info.dki_partition > V_NUMPAR) {
++ return (VT_EINVAL);
++ }
++ return ((int)dki_info.dki_partition);
++}
++
+
+ /*
+ * readvtoc(): Read a partition map.
+@@ -609,7 +1046,7 @@
+ {
+ int retval;
+
+- if ((retval = read_extvtoc(fd, vtoc)) >= 0)
++ if ((retval = __read_extvtoc(fd, vtoc)) >= 0)
+ return (0);
+
+ switch (retval) {
diff --git a/util-illumos/debian/patches/prtvtoc-no-etc.patch b/util-illumos/debian/patches/prtvtoc-no-etc.patch
new file mode 100644
index 0000000..7197e59
--- /dev/null
+++ b/util-illumos/debian/patches/prtvtoc-no-etc.patch
@@ -0,0 +1,13 @@
+Index: util-illumos/usr/src/cmd/prtvtoc/Makefile
+===================================================================
+--- util-illumos.orig/usr/src/cmd/prtvtoc/Makefile 2013-01-15 20:59:44.011425370 +0000
++++ util-illumos/usr/src/cmd/prtvtoc/Makefile 2013-01-15 21:13:36.673059751 +0000
+@@ -39,7 +39,7 @@
+
+ all: $(PROG)
+
+-install: all $(ROOTUSRSBINPROG) $(ROOTSYMLINK)
++install: all $(ROOTUSRSBINPROG)
+
+ $(ROOTSYMLINK):
+ -$(RM) $@; $(SYMLINK) $(RELUSRSBIN)/$(PROG) $@
diff --git a/util-illumos/debian/patches/series b/util-illumos/debian/patches/series
index d2468fc..db49923 100644
--- a/util-illumos/debian/patches/series
+++ b/util-illumos/debian/patches/series
@@ -1,3 +1,5 @@
prtconf-pointers.patch
fdisk-amd64.patch
fdisk-avoid-libadm.patch
+prtvtoc-avoid-libadm.patch
+prtvtoc-no-etc.patch
diff --git a/util-illumos/debian/rules b/util-illumos/debian/rules
index 50bdbf0..c396449 100755
--- a/util-illumos/debian/rules
+++ b/util-illumos/debian/rules
@@ -8,13 +8,14 @@ cmd := \
prtconf/i386 \
newtask/i386 \
swap/i386 \
+ biosdev \
devprop \
+ eeprom \
fdisk \
- biosdev \
+ prtvtoc \
+ psradm \
ramdiskadm \
- eeprom \
rtc \
- psradm \
unpack: unpack-stamp
unpack-stamp:
diff --git a/util-illumos/debian/util-illumos.install b/util-illumos/debian/util-illumos.install
index 29a9cb2..9384619 100644
--- a/util-illumos/debian/util-illumos.install
+++ b/util-illumos/debian/util-illumos.install
@@ -11,3 +11,4 @@ usr/sbin/swap
usr/sbin/eeprom
usr/sbin/rtc
usr/sbin/psradm
+usr/sbin/prtvtoc
diff --git a/util-illumos/debian/util-illumos.manpages b/util-illumos/debian/util-illumos.manpages
index 1310789..d1c5cc0 100644
--- a/util-illumos/debian/util-illumos.manpages
+++ b/util-illumos/debian/util-illumos.manpages
@@ -9,3 +9,4 @@ usr/src/man/man1m/swap.1m
usr/src/man/man1m/eeprom.1m
usr/src/man/man1m/rtc.1m
usr/src/man/man1m/psradm.1m
+usr/src/man/man1m/prtvtoc.1m