diff options
author | dholland <dholland@pkgsrc.org> | 2013-06-17 06:09:06 +0000 |
---|---|---|
committer | dholland <dholland@pkgsrc.org> | 2013-06-17 06:09:06 +0000 |
commit | 26e94eb0b6f1f184772826672e3bb5c2bf08f365 (patch) | |
tree | 0004967440f8f9766027cdae92da0828d0992ba9 /sysutils | |
parent | e2795749a8e77576bf5a82dfb30854006e6be34f (diff) | |
download | pkgsrc-26e94eb0b6f1f184772826672e3bb5c2bf08f365.tar.gz |
Use DIOCGINFO and/or DIOCGWEDGEINFO if DIOCGPART isn't defined. Fixes
build on netbsd-6 and up. Caution: while it builds, I haven't actually
tested it.
Diffstat (limited to 'sysutils')
-rw-r--r-- | sysutils/wipe/distinfo | 4 | ||||
-rw-r--r-- | sysutils/wipe/patches/patch-ah | 78 |
2 files changed, 72 insertions, 10 deletions
diff --git a/sysutils/wipe/distinfo b/sysutils/wipe/distinfo index 0b8782147ec..e27883e36ea 100644 --- a/sysutils/wipe/distinfo +++ b/sysutils/wipe/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.6 2013/06/17 05:37:22 dholland Exp $ +$NetBSD: distinfo,v 1.7 2013/06/17 06:09:06 dholland Exp $ SHA1 (wipe-2.2.0.tar.bz2) = 4dd18f260ecd91b726336b2788fa33db04d6691a RMD160 (wipe-2.2.0.tar.bz2) = 5d1861bd893e01e94205a7ac2efadb1c756da700 @@ -10,4 +10,4 @@ SHA1 (patch-ad) = 6288118d9b4a70844bbc94a8e9dc4748fc9459f8 SHA1 (patch-ae) = e1145c395a9b0999d7fbf8a4cb79f1dc89aa29e1 SHA1 (patch-af) = 23102dea6f821791d5b3bd2bb509c38ab6bf2a16 SHA1 (patch-ag) = fd61d6b065eb22cabb697f2df073a3b9efde26a9 -SHA1 (patch-ah) = 4b50f2fb8fa9b3c091ad4d1e0c8d954d3931d2b9 +SHA1 (patch-ah) = 362b9f59453baa4d8632d895a2f3a530ba9ca652 diff --git a/sysutils/wipe/patches/patch-ah b/sysutils/wipe/patches/patch-ah index c3a832ce703..2943598290a 100644 --- a/sysutils/wipe/patches/patch-ah +++ b/sysutils/wipe/patches/patch-ah @@ -1,20 +1,26 @@ -$NetBSD: patch-ah,v 1.2 2013/06/17 05:37:22 dholland Exp $ +$NetBSD: patch-ah,v 1.3 2013/06/17 06:09:06 dholland Exp $ -- DragonFly BSD's partinfo is not the standard BSD partinfo. - Don't declare own errno. +- DragonFly BSD's partinfo is not the standard BSD partinfo. +- NetBSD no longer supports the partinfo ioctl. Use the + available alternatives, which is kind of messy. --- blkdev.c.orig 2003-08-03 23:07:29.000000000 +0000 +++ blkdev.c -@@ -44,10 +44,15 @@ +@@ -44,10 +44,20 @@ # endif #endif --#ifdef HAVE_SYS_DISKLABEL_H -+#ifdef __DragonFly__ ++#if defined(__DragonFly__) +# include <sys/diskslice.h> +# define BSD_BLKDEV ++#elif defined(__NetBSD__) ++# include <sys/disklabel.h> ++# include <sys/disk.h> ++# include <sys/param.h> /* for DEV_BSIZE, XXX */ ++# define BSD_BLKDEV +#else -+#ifdef HAVE_SYS_DISKLABEL_H) + #ifdef HAVE_SYS_DISKLABEL_H # include <sys/disklabel.h> # define BSD_BLKDEV #endif @@ -22,7 +28,7 @@ $NetBSD: patch-ah,v 1.2 2013/06/17 05:37:22 dholland Exp $ #ifndef LINUX_BLKDEV # ifndef BSD_BLKDEV -@@ -63,7 +68,6 @@ +@@ -63,7 +73,6 @@ #include "wipe.h" #include "blkdev.h" @@ -30,7 +36,48 @@ $NetBSD: patch-ah,v 1.2 2013/06/17 05:37:22 dholland Exp $ extern int exit_code; extern char *argvzero; extern struct opt_s options; -@@ -182,14 +186,20 @@ public int destroy_blkdev(struct file_s +@@ -128,7 +137,13 @@ public int destroy_blkdev(struct file_s + int code; + + #ifdef BSD_BLKDEV ++#ifdef DIOCGPART + struct partinfo pinfo; ++#else ++ struct disklabel lab; ++ struct dkwedge_info dkw; ++ int use_dkw; ++#endif + #endif + + #ifdef NO_BLKDEV +@@ -160,12 +175,26 @@ public int destroy_blkdev(struct file_s + } + + #ifdef BSD_BLKDEV ++# ifdef DIOCGPART + if (ioctl(f->fd, DIOCGPART, &pinfo)) + { + fprintf(stderr, "\r%s: ioctl failed, can't get disklabel for `%s': %s\n", + argvzero, f->name, strerror(errno)); + exit_code = errno; return FAILED; + } ++# else ++ if (ioctl(f->fd, DIOCGDINFO, &lab) == 0) { ++ use_dkw = 0; ++ } ++ else if (ioctl(f->fd, DIOCGWEDGEINFO, &dkw) == 0) { ++ use_dkw = 1; ++ } ++ else { ++ fprintf(stderr, "\r%s: ioctl failed, can't get disklabel for `%s': %s\n", ++ argvzero, f->name, strerror(errno)); ++ exit_code = errno; return FAILED; ++ } ++# endif + #endif + + if (options.sectors == 0) +@@ -182,15 +211,35 @@ public int destroy_blkdev(struct file_s options.sectors = tmp; #endif @@ -39,7 +86,12 @@ $NetBSD: patch-ah,v 1.2 2013/06/17 05:37:22 dholland Exp $ +# if defined(__DragonFly__) + options.sectors = pinfo.media_blocks; +# else ++# if defined(DIOCGPART) options.sectors = pinfo.part->p_size; ++# else ++ options.sectors = use_dkw ? ++ dkw.dkw_size : lab.d_partitions[DISKPART(f->st.st_rdev)].p_size; ++# endif +# endif #endif } @@ -50,6 +102,16 @@ $NetBSD: patch-ah,v 1.2 2013/06/17 05:37:22 dholland Exp $ +#if defined(__DragonFly__) + options.sector_size = pinfo.media_blocks; +#elif defined(BSD_BLKDEV) ++# if defined(DIOCGPART) options.sector_size = pinfo.disklab->d_secsize; ++# else ++ /* ++ * XXX: we ought to use DIOCGDISKINFO to get the sector size, ++ * but that requires proplib and probably 500+ lines of code. ++ * So punt and use DEV_BSIZE... ++ */ ++ options.sector_size = use_dkw ? DEV_BSIZE : lab.d_secsize; ++# endif #else options.sector_size = SECTOR_SIZE; + #endif |