Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F137056871
D10780.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D10780.id.diff
View Options
Index: head/usr.sbin/makefs/ffs.c
===================================================================
--- head/usr.sbin/makefs/ffs.c
+++ head/usr.sbin/makefs/ffs.c
@@ -476,13 +476,15 @@
char *buf;
int i, bufsize;
off_t bufrem;
+ int oflags = O_RDWR | O_CREAT;
time_t tstamp;
- int oflags = O_RDWR | O_CREAT | O_TRUNC;
assert (image != NULL);
assert (fsopts != NULL);
/* create image */
+ if (fsopts->offset == 0)
+ oflags |= O_TRUNC;
if ((fsopts->fd = open(image, oflags, 0666)) == -1) {
warn("Can't open `%s' for writing", image);
return (-1);
@@ -517,6 +519,13 @@
bufsize);
buf = ecalloc(1, bufsize);
}
+
+ if (fsopts->offset != 0)
+ if (lseek(fsopts->fd, fsopts->offset, SEEK_SET) == -1) {
+ warn("can't seek");
+ return -1;
+ }
+
while (bufrem > 0) {
i = write(fsopts->fd, buf, MIN(bufsize, bufrem));
if (i == -1) {
Index: head/usr.sbin/makefs/ffs/buf.c
===================================================================
--- head/usr.sbin/makefs/ffs/buf.c
+++ head/usr.sbin/makefs/ffs/buf.c
@@ -68,7 +68,7 @@
printf("%s: blkno %lld size %d\n", __func__, (long long)blkno,
size);
*bpp = getblk(vp, blkno, size, 0, 0, 0);
- offset = (*bpp)->b_blkno * fsinfo->sectorsize;
+ offset = (*bpp)->b_blkno * fsinfo->sectorsize + fsinfo->offset;
if (debug & DEBUG_BUF_BREAD)
printf("%s: blkno %lld offset %lld bcount %ld\n", __func__,
(long long)(*bpp)->b_blkno, (long long) offset,
@@ -128,7 +128,7 @@
fsinfo_t *fs = bp->b_fs;
assert (bp != NULL);
- offset = bp->b_blkno * fs->sectorsize;
+ offset = bp->b_blkno * fs->sectorsize + fs->offset;
if (debug & DEBUG_BUF_BWRITE)
printf("bwrite: blkno %lld offset %lld bcount %ld\n",
(long long)bp->b_blkno, (long long) offset,
Index: head/usr.sbin/makefs/ffs/mkfs.c
===================================================================
--- head/usr.sbin/makefs/ffs/mkfs.c
+++ head/usr.sbin/makefs/ffs/mkfs.c
@@ -774,8 +774,7 @@
int n;
off_t offset;
- offset = bno;
- offset *= fsopts->sectorsize;
+ offset = bno * fsopts->sectorsize + fsopts->offset;
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
err(1, "%s: seek error for sector %lld", __func__,
(long long)bno);
@@ -799,11 +798,10 @@
int n;
off_t offset;
- offset = bno;
- offset *= fsopts->sectorsize;
+ offset = bno * fsopts->sectorsize + fsopts->offset;
if (lseek(fsopts->fd, offset, SEEK_SET) < 0)
err(1, "%s: seek error for sector %lld", __func__,
- (long long)bno );
+ (long long)bno);
n = write(fsopts->fd, bf, size);
if (n == -1)
err(1, "%s: write error for sector %lld", __func__,
Index: head/usr.sbin/makefs/makefs.h
===================================================================
--- head/usr.sbin/makefs/makefs.h
+++ head/usr.sbin/makefs/makefs.h
@@ -151,6 +151,7 @@
off_t maxsize; /* maximum size image can be */
off_t freefiles; /* free file entries to leave */
off_t freeblocks; /* free blocks to leave */
+ off_t offset; /* offset from start of file */
off_t roundup; /* round image size up to this value */
int freefilepc; /* free file % */
int freeblockpc; /* free block % */
Index: head/usr.sbin/makefs/makefs.8
===================================================================
--- head/usr.sbin/makefs/makefs.8
+++ head/usr.sbin/makefs/makefs.8
@@ -35,7 +35,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd May 17, 2017
+.Dd May 26, 2017
.Dt MAKEFS 8
.Os
.Sh NAME
@@ -52,6 +52,7 @@
.Op Fl M Ar minimum-size
.Op Fl m Ar maximum-size
.Op Fl N Ar userdb-dir
+.Op Fl O Ar offset
.Op Fl o Ar fs-options
.Op Fl R Ar roundup-size
.Op Fl S Ar sector-size
@@ -193,6 +194,11 @@
and
.Xr getgrnam 3
(and related) library calls.
+.It Fl O Ar offset
+Instead of creating the filesystem at the beginning of the file, start
+at offset.
+Valid only for
+.Sy ffs .
.It Fl o Ar fs-options
Set file system specific options.
.Ar fs-options
Index: head/usr.sbin/makefs/makefs.c
===================================================================
--- head/usr.sbin/makefs/makefs.c
+++ head/usr.sbin/makefs/makefs.c
@@ -124,7 +124,7 @@
err(1, "Unable to get system time");
- while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:o:pR:s:S:t:T:xZ")) != -1) {
+ while ((ch = getopt(argc, argv, "B:b:Dd:f:F:M:m:N:O:o:pR:s:S:t:T:xZ")) != -1) {
switch (ch) {
case 'B':
@@ -202,7 +202,12 @@
fsoptions.maxsize =
strsuftoll("maximum size", optarg, 1LL, LLONG_MAX);
break;
-
+
+ case 'O':
+ fsoptions.offset =
+ strsuftoll("offset", optarg, 0LL, LLONG_MAX);
+ break;
+
case 'o':
{
char *p;
@@ -479,8 +484,8 @@
fprintf(stderr,
"Usage: %s [-xZ] [-B endian] [-b free-blocks] [-d debug-mask]\n"
"\t[-F mtree-specfile] [-f free-files] [-M minimum-size] [-m maximum-size]\n"
-"\t[-N userdb-dir] [-o fs-options] [-R roundup-size] [-S sector-size]\n"
-"\t[-s image-size] [-T <timestamp/file>] [-t fs-type]\n"
+"\t[-N userdb-dir] [-O offset] [-o fs-options] [-R roundup-size]\n"
+"\t[-S sector-size] [-s image-size] [-T <timestamp/file>] [-t fs-type]\n"
"\timage-file directory | manifest [extra-directory ...]\n",
prog);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 22, 1:45 AM (1 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25863618
Default Alt Text
D10780.id.diff (4 KB)
Attached To
Mode
D10780: makefs: add -O (offset) option
Attached
Detach File
Event Timeline
Log In to Comment