scrub patch update
Signed-off-by: basebuilder_pel7ppc64lebuilder0 <basebuilder@powerel.org>master
parent
9e51dd5cc9
commit
fc1c514f27
|
@ -3,13 +3,13 @@ index 477c866..d88cd48 100644
|
||||||
--- a/libscrub/Makefile.am
|
--- a/libscrub/Makefile.am
|
||||||
+++ b/libscrub/Makefile.am
|
+++ b/libscrub/Makefile.am
|
||||||
@@ -13,6 +13,7 @@ libscrub_la_SOURCES = \
|
@@ -13,6 +13,7 @@ libscrub_la_SOURCES = \
|
||||||
libscrub.c \
|
libscrub.c \
|
||||||
scrub.h \
|
scrub.h \
|
||||||
../src/aes.c \
|
../src/aes.c \
|
||||||
+ ../src/fextent_apply.c \
|
+ ../src/fextent_apply.c \
|
||||||
../src/filldentry.c \
|
../src/filldentry.c \
|
||||||
../src/fillfile.c \
|
../src/fillfile.c \
|
||||||
../src/genrand.c \
|
../src/genrand.c \
|
||||||
diff --git a/man/scrub.1.in b/man/scrub.1.in
|
diff --git a/man/scrub.1.in b/man/scrub.1.in
|
||||||
index a1c260a..72b114f 100644
|
index a1c260a..72b114f 100644
|
||||||
--- a/man/scrub.1.in
|
--- a/man/scrub.1.in
|
||||||
|
@ -34,13 +34,13 @@ index 0cbd8f7..5de0b68 100644
|
||||||
+++ b/src/Makefile.am
|
+++ b/src/Makefile.am
|
||||||
@@ -3,6 +3,8 @@ bin_PROGRAMS = scrub
|
@@ -3,6 +3,8 @@ bin_PROGRAMS = scrub
|
||||||
scrub_SOURCES = \
|
scrub_SOURCES = \
|
||||||
aes.c \
|
aes.c \
|
||||||
aes.h \
|
aes.h \
|
||||||
+ fextent_apply.c \
|
+ fextent_apply.c \
|
||||||
+ fextent_apply.h \
|
+ fextent_apply.h \
|
||||||
filldentry.c \
|
filldentry.c \
|
||||||
filldentry.h \
|
filldentry.h \
|
||||||
fillfile.c \
|
fillfile.c \
|
||||||
diff --git a/src/fextent_apply.c b/src/fextent_apply.c
|
diff --git a/src/fextent_apply.c b/src/fextent_apply.c
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..31d3210
|
index 0000000..31d3210
|
||||||
|
@ -56,13 +56,13 @@ index 0000000..31d3210
|
||||||
+ * License as published by the Free Software Foundation; either
|
+ * License as published by the Free Software Foundation; either
|
||||||
+ * version 2.1 of the License, or (at your option) any later version.
|
+ * version 2.1 of the License, or (at your option) any later version.
|
||||||
+ *
|
+ *
|
||||||
+ * This library is distributed in the hope that it will be useful,
|
+ * This library is distributed in the hope that it will be useful,
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
+ * Lesser General Public License for more details.
|
+ * Lesser General Public License for more details.
|
||||||
+ *
|
+ *
|
||||||
+ * You should have received a copy of the GNU Lesser General Public
|
+ * You should have received a copy of the GNU Lesser General Public
|
||||||
+ * License along with this library; if not, write to the Free Software
|
+ * License along with this library; if not, write to the Free Software
|
||||||
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
+ *
|
+ *
|
||||||
+ * Authors:
|
+ * Authors:
|
||||||
|
@ -113,7 +113,7 @@ index 0000000..31d3210
|
||||||
+ dP("fstat(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
|
+ dP("fstat(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
|
||||||
+ goto exit_1;
|
+ goto exit_1;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ /*
|
+ /*
|
||||||
+ * fiemap => get extent count
|
+ * fiemap => get extent count
|
||||||
+ */
|
+ */
|
||||||
|
@ -164,7 +164,7 @@ index 0000000..31d3210
|
||||||
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
|
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
|
||||||
+ goto exit_0;
|
+ goto exit_0;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ for (i = 0; i < extent_count; ++i) {
|
+ for (i = 0; i < extent_count; ++i) {
|
||||||
+ // seek to extent start
|
+ // seek to extent start
|
||||||
+ if (lseek(fd, em->fm_extents[i].fe_logical, SEEK_SET) == (off_t)-1) {
|
+ if (lseek(fd, em->fm_extents[i].fe_logical, SEEK_SET) == (off_t)-1) {
|
||||||
|
@ -204,13 +204,13 @@ index 0000000..40a54ec
|
||||||
+ * License as published by the Free Software Foundation; either
|
+ * License as published by the Free Software Foundation; either
|
||||||
+ * version 2.1 of the License, or (at your option) any later version.
|
+ * version 2.1 of the License, or (at your option) any later version.
|
||||||
+ *
|
+ *
|
||||||
+ * This library is distributed in the hope that it will be useful,
|
+ * This library is distributed in the hope that it will be useful,
|
||||||
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
+ * Lesser General Public License for more details.
|
+ * Lesser General Public License for more details.
|
||||||
+ *
|
+ *
|
||||||
+ * You should have received a copy of the GNU Lesser General Public
|
+ * You should have received a copy of the GNU Lesser General Public
|
||||||
+ * License along with this library; if not, write to the Free Software
|
+ * License along with this library; if not, write to the Free Software
|
||||||
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
+ *
|
+ *
|
||||||
+ * Authors:
|
+ * Authors:
|
||||||
|
@ -230,17 +230,17 @@ index e0f67b6..a77367f 100644
|
||||||
--- a/src/fillfile.c
|
--- a/src/fillfile.c
|
||||||
+++ b/src/fillfile.c
|
+++ b/src/fillfile.c
|
||||||
@@ -42,6 +42,7 @@
|
@@ -42,6 +42,7 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "fillfile.h"
|
#include "fillfile.h"
|
||||||
+#include "fextent_apply.h"
|
+#include "fextent_apply.h"
|
||||||
|
|
||||||
static int no_threads = 0;
|
static int no_threads = 0;
|
||||||
|
|
||||||
@@ -57,6 +58,20 @@ struct memstruct {
|
@@ -57,6 +58,20 @@ struct memstruct {
|
||||||
|
|
||||||
extern char *prog;
|
extern char *prog;
|
||||||
|
|
||||||
+struct fillfile_args {
|
+struct fillfile_args {
|
||||||
+ char *path;
|
+ char *path;
|
||||||
+ off_t filesize;
|
+ off_t filesize;
|
||||||
|
@ -266,7 +266,7 @@ index e0f67b6..a77367f 100644
|
||||||
*/
|
*/
|
||||||
off_t
|
off_t
|
||||||
fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
||||||
progress_t progress, void *arg, refill_t refill,
|
progress_t progress, void *arg, refill_t refill,
|
||||||
- bool sparse, bool creat)
|
- bool sparse, bool creat)
|
||||||
+ bool sparse, bool creat, bool extentonly)
|
+ bool sparse, bool creat, bool extentonly)
|
||||||
{
|
{
|
||||||
|
@ -370,7 +370,7 @@ index e0f67b6..a77367f 100644
|
||||||
@@ -238,8 +278,6 @@ checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
@@ -238,8 +278,6 @@ checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
||||||
unsigned char *buf = NULL;
|
unsigned char *buf = NULL;
|
||||||
int openflags = O_RDONLY;
|
int openflags = O_RDONLY;
|
||||||
|
|
||||||
- if (!(buf = alloc_buffer(memsize)))
|
- if (!(buf = alloc_buffer(memsize)))
|
||||||
- goto nomem;
|
- goto nomem;
|
||||||
if (filetype(path) != FILE_CHAR)
|
if (filetype(path) != FILE_CHAR)
|
||||||
|
@ -450,7 +450,7 @@ index e0f67b6..a77367f 100644
|
||||||
+ progress(arg, (double)verified/filesize);
|
+ progress(arg, (double)verified/filesize);
|
||||||
+ } while (verified < filesize);
|
+ } while (verified < filesize);
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
if (close(fd) < 0)
|
if (close(fd) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
- free(buf);
|
- free(buf);
|
||||||
|
@ -463,13 +463,13 @@ index e0f67b6..a77367f 100644
|
||||||
@@ -293,6 +359,63 @@ disable_threads(void)
|
@@ -293,6 +359,63 @@ disable_threads(void)
|
||||||
no_threads = 1;
|
no_threads = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
+int fillextent(int fd, struct fiemap_extent *extent, void *pa)
|
+int fillextent(int fd, struct fiemap_extent *extent, void *pa)
|
||||||
+{
|
+{
|
||||||
+ off_t n;
|
+ off_t n;
|
||||||
+ off_t written = 0LL;
|
+ off_t written = 0LL;
|
||||||
+ struct fillfile_args args = *(struct fillfile_args *)(pa);
|
+ struct fillfile_args args = *(struct fillfile_args *)(pa);
|
||||||
+
|
+
|
||||||
+ do {
|
+ do {
|
||||||
+ if (args.refill)
|
+ if (args.refill)
|
||||||
+ args.refill(args.mem, args.memsize);
|
+ args.refill(args.mem, args.memsize);
|
||||||
|
@ -529,9 +529,9 @@ index b9ef951..2fc917d 100644
|
||||||
--- a/src/fillfile.h
|
--- a/src/fillfile.h
|
||||||
+++ b/src/fillfile.h
|
+++ b/src/fillfile.h
|
||||||
@@ -29,7 +29,7 @@ typedef void (*refill_t) (unsigned char *mem, int memsize);
|
@@ -29,7 +29,7 @@ typedef void (*refill_t) (unsigned char *mem, int memsize);
|
||||||
|
|
||||||
off_t fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
off_t fillfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
||||||
progress_t progress, void *arg, refill_t refill,
|
progress_t progress, void *arg, refill_t refill,
|
||||||
- bool sparse, bool creat);
|
- bool sparse, bool creat);
|
||||||
+ bool sparse, bool creat, bool extentonly);
|
+ bool sparse, bool creat, bool extentonly);
|
||||||
off_t checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
off_t checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
|
||||||
|
@ -550,14 +550,14 @@ index 820c898..ecfd382 100644
|
||||||
+ return 0;
|
+ return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
diff --git a/src/scrub.c b/src/scrub.c
|
diff --git a/src/scrub.c b/src/scrub.c
|
||||||
index dec71f3..b0eb1f7 100644
|
index dec71f3..b0eb1f7 100644
|
||||||
--- a/src/scrub.c
|
--- a/src/scrub.c
|
||||||
+++ b/src/scrub.c
|
+++ b/src/scrub.c
|
||||||
@@ -58,12 +58,12 @@
|
@@ -58,12 +58,12 @@
|
||||||
#define BUFSIZE (4*1024*1024) /* default blocksize */
|
#define BUFSIZE (4*1024*1024) /* default blocksize */
|
||||||
|
|
||||||
static bool scrub(char *path, off_t size, const sequence_t *seq,
|
static bool scrub(char *path, off_t size, const sequence_t *seq,
|
||||||
- int bufsize, bool Sopt, bool sparse, bool enospc);
|
- int bufsize, bool Sopt, bool sparse, bool enospc);
|
||||||
+ int bufsize, bool Sopt, bool sparse, bool enospc, bool extentonly);
|
+ int bufsize, bool Sopt, bool sparse, bool enospc, bool extentonly);
|
||||||
|
@ -573,7 +573,7 @@ index dec71f3..b0eb1f7 100644
|
||||||
@@ -71,7 +71,7 @@ static void scrub_resfork(char *path, const sequence_t *seq,
|
@@ -71,7 +71,7 @@ static void scrub_resfork(char *path, const sequence_t *seq,
|
||||||
static void scrub_disk(char *path, off_t size, const sequence_t *seq,
|
static void scrub_disk(char *path, off_t size, const sequence_t *seq,
|
||||||
int bufsize, bool Sopt, bool sparse);
|
int bufsize, bool Sopt, bool sparse);
|
||||||
|
|
||||||
-#define OPTIONS "p:D:Xb:s:fSrvTLRth"
|
-#define OPTIONS "p:D:Xb:s:fSrvTLRth"
|
||||||
+#define OPTIONS "p:D:Xb:s:fSrvTELRth"
|
+#define OPTIONS "p:D:Xb:s:fSrvTELRth"
|
||||||
#if HAVE_GETOPT_LONG
|
#if HAVE_GETOPT_LONG
|
||||||
|
@ -625,7 +625,7 @@ index dec71f3..b0eb1f7 100644
|
||||||
@@ -346,14 +352,14 @@ done:
|
@@ -346,14 +352,14 @@ done:
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
||||||
- bool Sopt, bool sparse, bool enospc)
|
- bool Sopt, bool sparse, bool enospc)
|
||||||
+ bool Sopt, bool sparse, bool enospc, bool extentonly)
|
+ bool Sopt, bool sparse, bool enospc, bool extentonly)
|
||||||
{
|
{
|
||||||
|
@ -636,13 +636,13 @@ index dec71f3..b0eb1f7 100644
|
||||||
bool isfull = false;
|
bool isfull = false;
|
||||||
- off_t written, checked;
|
- off_t written, checked;
|
||||||
+ off_t written = (off_t)-1, checked = (off_t)-1;
|
+ off_t written = (off_t)-1, checked = (off_t)-1;
|
||||||
|
|
||||||
if (!(buf = alloc_buffer(bufsize))) {
|
if (!(buf = alloc_buffer(bufsize))) {
|
||||||
fprintf(stderr, "%s: out of memory\n", prog);
|
fprintf(stderr, "%s: out of memory\n", prog);
|
||||||
@@ -381,7 +387,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
@@ -381,7 +387,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
||||||
}
|
}
|
||||||
written = fillfile(path, size, buf, bufsize,
|
written = fillfile(path, size, buf, bufsize,
|
||||||
(progress_t)progress_update, p,
|
(progress_t)progress_update, p,
|
||||||
- (refill_t)genrand, sparse, enospc);
|
- (refill_t)genrand, sparse, enospc);
|
||||||
+ (refill_t)genrand, sparse, enospc, extentonly);
|
+ (refill_t)genrand, sparse, enospc, extentonly);
|
||||||
if (written == (off_t)-1) {
|
if (written == (off_t)-1) {
|
||||||
|
@ -650,8 +650,8 @@ index dec71f3..b0eb1f7 100644
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@@ -395,7 +401,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
@@ -395,7 +401,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
||||||
memset_pat(buf, seq->pat[i], bufsize);
|
memset_pat(buf, seq->pat[i], bufsize);
|
||||||
written = fillfile(path, size, buf, bufsize,
|
written = fillfile(path, size, buf, bufsize,
|
||||||
(progress_t)progress_update, p,
|
(progress_t)progress_update, p,
|
||||||
- NULL, sparse, enospc);
|
- NULL, sparse, enospc);
|
||||||
+ NULL, sparse, enospc, extentonly);
|
+ NULL, sparse, enospc, extentonly);
|
||||||
if (written == (off_t)-1) {
|
if (written == (off_t)-1) {
|
||||||
|
@ -659,8 +659,8 @@ index dec71f3..b0eb1f7 100644
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
@@ -409,7 +415,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
@@ -409,7 +415,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
||||||
memset_pat(buf, seq->pat[i], bufsize);
|
memset_pat(buf, seq->pat[i], bufsize);
|
||||||
written = fillfile(path, size, buf, bufsize,
|
written = fillfile(path, size, buf, bufsize,
|
||||||
(progress_t)progress_update, p,
|
(progress_t)progress_update, p,
|
||||||
- NULL, sparse, enospc);
|
- NULL, sparse, enospc);
|
||||||
+ NULL, sparse, enospc, extentonly);
|
+ NULL, sparse, enospc, extentonly);
|
||||||
if (written == (off_t)-1) {
|
if (written == (off_t)-1) {
|
||||||
|
@ -669,7 +669,7 @@ index dec71f3..b0eb1f7 100644
|
||||||
@@ -419,7 +425,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
@@ -419,7 +425,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
|
||||||
printf("%s: %-8s", prog, "verify");
|
printf("%s: %-8s", prog, "verify");
|
||||||
progress_create(&p, 50);
|
progress_create(&p, 50);
|
||||||
checked = checkfile(path, written, buf, bufsize,
|
checked = checkfile(path, written, buf, bufsize,
|
||||||
- (progress_t)progress_update, p, sparse);
|
- (progress_t)progress_update, p, sparse);
|
||||||
+ (progress_t)progress_update, p, sparse, extentonly);
|
+ (progress_t)progress_update, p, sparse, extentonly);
|
||||||
if (checked == (off_t)-1) {
|
if (checked == (off_t)-1) {
|
||||||
|
@ -686,31 +686,31 @@ index dec71f3..b0eb1f7 100644
|
||||||
snprintf(path, sizeof(path), "%s/scrub.%.3d", dirpath, fileno);
|
snprintf(path, sizeof(path), "%s/scrub.%.3d", dirpath, fileno);
|
||||||
@@ -565,7 +571,7 @@ scrub_dirent(char *path, char *newpath)
|
@@ -565,7 +571,7 @@ scrub_dirent(char *path, char *newpath)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
scrub_file(char *path, off_t size, const sequence_t *seq,
|
scrub_file(char *path, off_t size, const sequence_t *seq,
|
||||||
- int bufsize, bool Sopt, bool sparse)
|
- int bufsize, bool Sopt, bool sparse)
|
||||||
+ int bufsize, bool Sopt, bool sparse, bool extentonly)
|
+ int bufsize, bool Sopt, bool sparse, bool extentonly)
|
||||||
{
|
{
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
filetype_t ftype = filetype(path);
|
filetype_t ftype = filetype(path);
|
||||||
@@ -590,7 +596,7 @@ scrub_file(char *path, off_t size, const sequence_t *seq,
|
@@ -590,7 +596,7 @@ scrub_file(char *path, off_t size, const sequence_t *seq,
|
||||||
prog, path, (int)(size - sb.st_size));
|
prog, path, (int)(size - sb.st_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
|
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
|
||||||
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, extentonly);
|
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, extentonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Scrub apple resource fork component of file.
|
/* Scrub apple resource fork component of file.
|
||||||
@@ -618,7 +624,7 @@ scrub_resfork(char *path, const sequence_t *seq, int bufsize)
|
@@ -618,7 +624,7 @@ scrub_resfork(char *path, const sequence_t *seq, int bufsize)
|
||||||
printf("%s: padding %s with %d bytes to fill last fs block\n",
|
printf("%s: padding %s with %d bytes to fill last fs block\n",
|
||||||
prog, rpath, (int)(rsize - rsb.st_size));
|
prog, rpath, (int)(rsize - rsb.st_size));
|
||||||
}
|
}
|
||||||
- scrub(rpath, rsize, seq, bufsize, false, false, false);
|
- scrub(rpath, rsize, seq, bufsize, false, false, false);
|
||||||
+ scrub(rpath, rsize, seq, bufsize, false, false, false, false);
|
+ scrub(rpath, rsize, seq, bufsize, false, false, false, false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -639,7 +645,7 @@ scrub_disk(char *path, off_t size, const sequence_t *seq, int bufsize,
|
@@ -639,7 +645,7 @@ scrub_disk(char *path, off_t size, const sequence_t *seq, int bufsize,
|
||||||
}
|
}
|
||||||
printf("%s: please verify that device size below is correct!\n", prog);
|
printf("%s: please verify that device size below is correct!\n", prog);
|
||||||
|
@ -718,5 +718,5 @@ index dec71f3..b0eb1f7 100644
|
||||||
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
|
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
|
||||||
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, false);
|
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue