Browse Source

scrub patch update

Signed-off-by: basebuilder_pel7ppc64lebuilder0 <basebuilder@powerel.org>
master
basebuilder_pel7ppc64lebuilder0 5 years ago
parent
commit
fc1c514f27
  1. 98
      SOURCES/scrub-2.5.2-extentonly.patch

98
SOURCES/scrub-2.5.2-extentonly.patch

@ -3,13 +3,13 @@ index 477c866..d88cd48 100644 @@ -3,13 +3,13 @@ index 477c866..d88cd48 100644
--- a/libscrub/Makefile.am
+++ b/libscrub/Makefile.am
@@ -13,6 +13,7 @@ libscrub_la_SOURCES = \
libscrub.c \
scrub.h \
../src/aes.c \
libscrub.c \
scrub.h \
../src/aes.c \
+ ../src/fextent_apply.c \
../src/filldentry.c \
../src/fillfile.c \
../src/genrand.c \
../src/filldentry.c \
../src/fillfile.c \
../src/genrand.c \
diff --git a/man/scrub.1.in b/man/scrub.1.in
index a1c260a..72b114f 100644
--- a/man/scrub.1.in
@ -34,13 +34,13 @@ index 0cbd8f7..5de0b68 100644 @@ -34,13 +34,13 @@ index 0cbd8f7..5de0b68 100644
+++ b/src/Makefile.am
@@ -3,6 +3,8 @@ bin_PROGRAMS = scrub
scrub_SOURCES = \
aes.c \
aes.h \
aes.c \
aes.h \
+ fextent_apply.c \
+ fextent_apply.h \
filldentry.c \
filldentry.h \
fillfile.c \
filldentry.c \
filldentry.h \
fillfile.c \
diff --git a/src/fextent_apply.c b/src/fextent_apply.c
new file mode 100644
index 0000000..31d3210
@ -56,13 +56,13 @@ index 0000000..31d3210 @@ -56,13 +56,13 @@ index 0000000..31d3210
+ * License as published by the Free Software Foundation; either
+ * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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
+ *
+ * Authors:
@ -113,7 +113,7 @@ index 0000000..31d3210 @@ -113,7 +113,7 @@ index 0000000..31d3210
+ dP("fstat(%d) failed: %s, %d.\n", fd, strerror(errno), errno);
+ goto exit_1;
+ }
+
+
+ /*
+ * fiemap => get extent count
+ */
@ -164,7 +164,7 @@ index 0000000..31d3210 @@ -164,7 +164,7 @@ index 0000000..31d3210
+ dP("FS_IOC_FIEMAP: %s, %d.\n", strerror(errno), errno);
+ goto exit_0;
+ }
+
+
+ for (i = 0; i < extent_count; ++i) {
+ // seek to extent start
+ if (lseek(fd, em->fm_extents[i].fe_logical, SEEK_SET) == (off_t)-1) {
@ -204,13 +204,13 @@ index 0000000..40a54ec @@ -204,13 +204,13 @@ index 0000000..40a54ec
+ * License as published by the Free Software Foundation; either
+ * 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
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * 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
+ *
+ * Authors:
@ -230,17 +230,17 @@ index e0f67b6..a77367f 100644 @@ -230,17 +230,17 @@ index e0f67b6..a77367f 100644
--- a/src/fillfile.c
+++ b/src/fillfile.c
@@ -42,6 +42,7 @@

#include "util.h"
#include "fillfile.h"
+#include "fextent_apply.h"

static int no_threads = 0;

@@ -57,6 +58,20 @@ struct memstruct {

extern char *prog;

+struct fillfile_args {
+ char *path;
+ off_t filesize;
@ -266,7 +266,7 @@ index e0f67b6..a77367f 100644 @@ -266,7 +266,7 @@ index e0f67b6..a77367f 100644
*/
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 extentonly)
{
@ -370,7 +370,7 @@ index e0f67b6..a77367f 100644 @@ -370,7 +370,7 @@ index e0f67b6..a77367f 100644
@@ -238,8 +278,6 @@ checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
unsigned char *buf = NULL;
int openflags = O_RDONLY;

- if (!(buf = alloc_buffer(memsize)))
- goto nomem;
if (filetype(path) != FILE_CHAR)
@ -450,7 +450,7 @@ index e0f67b6..a77367f 100644 @@ -450,7 +450,7 @@ index e0f67b6..a77367f 100644
+ progress(arg, (double)verified/filesize);
+ } while (verified < filesize);
+ }
+
+
if (close(fd) < 0)
goto error;
- free(buf);
@ -463,13 +463,13 @@ index e0f67b6..a77367f 100644 @@ -463,13 +463,13 @@ index e0f67b6..a77367f 100644
@@ -293,6 +359,63 @@ disable_threads(void)
no_threads = 1;
}

+int fillextent(int fd, struct fiemap_extent *extent, void *pa)
+{
+ off_t n;
+ off_t written = 0LL;
+ struct fillfile_args args = *(struct fillfile_args *)(pa);
+
+
+ do {
+ if (args.refill)
+ args.refill(args.mem, args.memsize);
@ -529,9 +529,9 @@ index b9ef951..2fc917d 100644 @@ -529,9 +529,9 @@ index b9ef951..2fc917d 100644
--- a/src/fillfile.h
+++ b/src/fillfile.h
@@ -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,
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 extentonly);
off_t checkfile(char *path, off_t filesize, unsigned char *mem, int memsize,
@ -550,14 +550,14 @@ index 820c898..ecfd382 100644 @@ -550,14 +550,14 @@ index 820c898..ecfd382 100644
+ return 0;
}
}

diff --git a/src/scrub.c b/src/scrub.c
index dec71f3..b0eb1f7 100644
--- a/src/scrub.c
+++ b/src/scrub.c
@@ -58,12 +58,12 @@
#define BUFSIZE (4*1024*1024) /* default blocksize */

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, bool extentonly);
@ -573,7 +573,7 @@ index dec71f3..b0eb1f7 100644 @@ -573,7 +573,7 @@ index dec71f3..b0eb1f7 100644
@@ -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,
int bufsize, bool Sopt, bool sparse);

-#define OPTIONS "p:D:Xb:s:fSrvTLRth"
+#define OPTIONS "p:D:Xb:s:fSrvTELRth"
#if HAVE_GETOPT_LONG
@ -625,7 +625,7 @@ index dec71f3..b0eb1f7 100644 @@ -625,7 +625,7 @@ index dec71f3..b0eb1f7 100644
@@ -346,14 +352,14 @@ done:
*/
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 extentonly)
{
@ -636,13 +636,13 @@ index dec71f3..b0eb1f7 100644 @@ -636,13 +636,13 @@ index dec71f3..b0eb1f7 100644
bool isfull = false;
- off_t written, checked;
+ off_t written = (off_t)-1, checked = (off_t)-1;

if (!(buf = alloc_buffer(bufsize))) {
fprintf(stderr, "%s: out of memory\n", prog);
@@ -381,7 +387,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
}
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
- (refill_t)genrand, sparse, enospc);
+ (refill_t)genrand, sparse, enospc, extentonly);
if (written == (off_t)-1) {
@ -650,8 +650,8 @@ index dec71f3..b0eb1f7 100644 @@ -650,8 +650,8 @@ index dec71f3..b0eb1f7 100644
strerror(errno));
@@ -395,7 +401,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
memset_pat(buf, seq->pat[i], bufsize);
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
- NULL, sparse, enospc);
+ NULL, sparse, enospc, extentonly);
if (written == (off_t)-1) {
@ -659,8 +659,8 @@ index dec71f3..b0eb1f7 100644 @@ -659,8 +659,8 @@ index dec71f3..b0eb1f7 100644
strerror(errno));
@@ -409,7 +415,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
memset_pat(buf, seq->pat[i], bufsize);
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
written = fillfile(path, size, buf, bufsize,
(progress_t)progress_update, p,
- NULL, sparse, enospc);
+ NULL, sparse, enospc, extentonly);
if (written == (off_t)-1) {
@ -669,7 +669,7 @@ index dec71f3..b0eb1f7 100644 @@ -669,7 +669,7 @@ index dec71f3..b0eb1f7 100644
@@ -419,7 +425,7 @@ scrub(char *path, off_t size, const sequence_t *seq, int bufsize,
printf("%s: %-8s", prog, "verify");
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, extentonly);
if (checked == (off_t)-1) {
@ -686,31 +686,31 @@ index dec71f3..b0eb1f7 100644 @@ -686,31 +686,31 @@ index dec71f3..b0eb1f7 100644
snprintf(path, sizeof(path), "%s/scrub.%.3d", dirpath, fileno);
@@ -565,7 +571,7 @@ scrub_dirent(char *path, char *newpath)
*/
static void
scrub_file(char *path, off_t size, const sequence_t *seq,
static void
scrub_file(char *path, off_t size, const sequence_t *seq,
- int bufsize, bool Sopt, bool sparse)
+ int bufsize, bool Sopt, bool sparse, bool extentonly)
{
struct stat sb;
filetype_t ftype = filetype(path);
@@ -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, extentonly);
}

/* Scrub apple resource fork component of file.
@@ -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",
prog, rpath, (int)(rsize - rsb.st_size));
printf("%s: padding %s with %d bytes to fill last fs block\n",
prog, rpath, (int)(rsize - rsb.st_size));
}
- scrub(rpath, rsize, seq, bufsize, false, false, false);
+ scrub(rpath, rsize, seq, bufsize, false, false, false, false);
}
#endif

@@ -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);
@ -718,5 +718,5 @@ index dec71f3..b0eb1f7 100644 @@ -718,5 +718,5 @@ index dec71f3..b0eb1f7 100644
- scrub(path, size, seq, bufsize, Sopt, sparse, false);
+ scrub(path, size, seq, bufsize, Sopt, sparse, false, false);
}

/*

Loading…
Cancel
Save