diff options
author | cy <cy@FreeBSD.org> | 2007-05-02 05:44:12 +0800 |
---|---|---|
committer | cy <cy@FreeBSD.org> | 2007-05-02 05:44:12 +0800 |
commit | 043944bca6a28cc3cd001036364658bbd4c55c7a (patch) | |
tree | e52ff005321b6565e1c1b296bd16a14f8d3309d5 | |
parent | 1ca6645617eae5fa1a14e85a7834d6486a3e1625 (diff) | |
download | freebsd-ports-gnome-043944bca6a28cc3cd001036364658bbd4c55c7a.tar.gz freebsd-ports-gnome-043944bca6a28cc3cd001036364658bbd4c55c7a.tar.zst freebsd-ports-gnome-043944bca6a28cc3cd001036364658bbd4c55c7a.zip |
Properly support wiping of raw devices under FreeBSD.
-rw-r--r-- | security/bcwipe/Makefile | 1 | ||||
-rw-r--r-- | security/bcwipe/files/patch-wipe.c | 68 |
2 files changed, 69 insertions, 0 deletions
diff --git a/security/bcwipe/Makefile b/security/bcwipe/Makefile index 1ffec9e9fdbb..b80578130cba 100644 --- a/security/bcwipe/Makefile +++ b/security/bcwipe/Makefile @@ -7,6 +7,7 @@ PORTNAME= bcwipe PORTVERSION= 1.6.5 +PORTREVISION= 1 CATEGORIES= security MASTER_SITES= http://www.jetico.com/linux/ \ http://bsd.desa-hosting.de/distfiles/security/ diff --git a/security/bcwipe/files/patch-wipe.c b/security/bcwipe/files/patch-wipe.c new file mode 100644 index 000000000000..079ca0fce034 --- /dev/null +++ b/security/bcwipe/files/patch-wipe.c @@ -0,0 +1,68 @@ +--- wipe.c.orig Tue Mar 6 10:24:24 2007 ++++ wipe.c Fri Mar 9 09:43:00 2007 +@@ -17,6 +17,9 @@ + + char wipe_c[]="$Id: wipe.c,v 1.96 2006/10/31 11:03:31 pav Rev 1.6-5 $"; + ++#ifndef SOLARIS ++#define SOLARIS (defined(sun) && (defined(__svr4__) || defined(__SVR4))) ++#endif + + #include <stdio.h> + #include <limits.h> +@@ -909,9 +912,17 @@ + /*size on success */ + long long int find_size_by_reading(int fd) + { ++ struct stat st; + off_t limit,pos,prev,b_pos=0; +- char buf[64]; +- int i; ++ char buf[512]; ++ int i, j; ++ ++ if ( OK != fstat(fd,&st) ) ++ { ++ fprintf (stderr, "Skipping fd=%d, %s\n",fd,strerror(errno)); ++ return ERROR; ++ } ++ j = !(S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) ? 1 : sizeof(buf); + + for ( limit=0x7f,i=sizeof(limit);--i; ) + limit = (limit <<8)|0xff; +@@ -925,7 +936,7 @@ + fprintf(stderr,"lseek error: %s\n",strerror(errno)); + return 0; + } +- if ( 1 != read(fd,buf,1) ) ++ if ( j != read(fd,buf,j) ) + { + prev=pos; + pos=(pos+b_pos)>>1; +@@ -1172,6 +1183,9 @@ + + if ( S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode) ) + { ++#if defined(__FreeBSD__) || defined(SOLARIS) ++ size = ~((long long int)1 << (sizeof(size)*8-1)); ++#else + size = 0; + + #ifdef BLKGETSIZE +@@ -1191,6 +1205,7 @@ + if ( 0 == size || ERROR == size ) + for ( size=0x7f,i=sizeof(size);--i; ) + size = (size <<8)|0xff; ++#endif + } + + for ( i=0, op=0 ; i < o_pas_num; i++ ) +@@ -1202,7 +1217,7 @@ + lseek64(fd,0,SEEK_SET); + while ( s < size ) + { +- j = size - s < BUFFSIZE ? size - s : BUFFSIZE; ++ j = size - s < BUFFSIZE && !(S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) ? size - s : BUFFSIZE; + fill_buff(buff, j, i,s); + + if ( ERROR == (j=write(fd,(const void *)buff,j)) ) |