From c5907b964e9ee1103308b42f42c991857196503b Mon Sep 17 00:00:00 2001 From: "Martin K. Petersen" Date: Fri, 9 Mar 2001 05:38:39 +0000 Subject: [PATCH] Only try to set block size when running mkfs or repair on an unmounted device. --- include/libxfs.h | 3 ++- libxfs/init.c | 17 +++++++++-------- mkfs/xfs_mkfs.c | 1 + repair/init.c | 1 + 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/libxfs.h b/include/libxfs.h index 78e597846..ba78c7746 100644 --- a/include/libxfs.h +++ b/include/libxfs.h @@ -104,6 +104,7 @@ typedef struct { int dfd; /* data subvolume file descriptor */ int logfd; /* log subvolume file descriptor */ int rtfd; /* realtime subvolume file descriptor */ + int setblksize; /* attempt to set device block size */ } libxfs_init_t; #define LIBXFS_ISREADONLY 0x0069 /* disallow all mounted filesystems */ @@ -112,7 +113,7 @@ typedef struct { extern char *progname; extern int libxfs_init (libxfs_init_t *); extern int libxfs_device_to_fd (dev_t); -extern dev_t libxfs_device_open (char *, int, int); +extern dev_t libxfs_device_open (char *, int, int, int); extern void libxfs_device_zero (dev_t, xfs_daddr_t, uint); extern void libxfs_device_close (dev_t); diff --git a/libxfs/init.c b/libxfs/init.c index b40bf31a7..baef76779 100644 --- a/libxfs/init.c +++ b/libxfs/init.c @@ -178,7 +178,7 @@ libxfs_device_to_fd(dev_t device) * open a device and return its device number */ dev_t -libxfs_device_open(char *path, int creat, int readonly) +libxfs_device_open(char *path, int creat, int readonly, int setblksize) { int fd; dev_t dev; @@ -202,7 +202,7 @@ libxfs_device_open(char *path, int creat, int readonly) } /* Set device blocksize to 512 bytes */ - if ((statb.st_mode & S_IFMT) == S_IFBLK) { + if (!readonly && setblksize && (statb.st_mode & S_IFMT) == S_IFBLK) { if (ioctl(fd, BLKBSZSET, &blocksize) < 0) { fprintf(stderr, "%s: warning - cannot set blocksize on " "block device %s: %s\n", @@ -400,7 +400,8 @@ voldone: if (dname[0] != '/' && needcd) chdir(curdir); if (a->disfile) { - a->ddev= libxfs_device_open(dname, a->dcreat, readonly); + a->ddev= libxfs_device_open(dname, a->dcreat, readonly, + a->setblksize); a->dfd = libxfs_device_to_fd(a->ddev); } else { if (stat64(dname, &stbuf) < 0) { @@ -425,7 +426,7 @@ voldone: dname, blockfile, readonly)) goto done; a->ddev = libxfs_device_open(rawfile, - a->dcreat, readonly); + a->dcreat, readonly, a->setblksize); a->dfd = libxfs_device_to_fd(a->ddev); a->dsize = findsize(rawfile); } @@ -437,7 +438,7 @@ voldone: chdir(curdir); if (a->lisfile) { a->logdev = libxfs_device_open(logname, - a->lcreat, readonly); + a->lcreat, readonly, a->setblksize); a->logfd = libxfs_device_to_fd(a->logdev); } else { if (stat64(logname, &stbuf) < 0) { @@ -462,7 +463,7 @@ voldone: logname, blockfile, readonly)) goto done; a->logdev = libxfs_device_open(rawfile, - a->lcreat, readonly); + a->lcreat, readonly, a->setblksize); a->logfd = libxfs_device_to_fd(a->logdev); a->logBBsize = findsize(rawfile); } @@ -474,7 +475,7 @@ voldone: chdir(curdir); if (a->risfile) { a->rtdev = libxfs_device_open(rtname, - a->rcreat, readonly); + a->rcreat, readonly, a->setblksize); a->rtfd = libxfs_device_to_fd(a->rtdev); } else { if (stat64(rtname, &stbuf) < 0) { @@ -499,7 +500,7 @@ voldone: rtname, blockfile, readonly)) goto done; a->rtdev = libxfs_device_open(rawfile, - a->rcreat, readonly); + a->rcreat, readonly, a->setblksize); a->rtfd = libxfs_device_to_fd(a->rtdev); a->rtsize = findsize(rawfile); } diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index 13132b979..4c2cf51cc 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -422,6 +422,7 @@ main(int argc, char **argv) iaflag = XFS_IFLAG_ALIGN; bzero(&xi, sizeof(xi)); xi.notvolok = 1; + xi.setblksize = 1; dfile = logfile = rtfile = NULL; dsize = logsize = rtsize = rtextsize = protofile = NULL; opterr = 0; diff --git a/repair/init.c b/repair/init.c index cc61650c7..491c12127 100644 --- a/repair/init.c +++ b/repair/init.c @@ -60,6 +60,7 @@ xfs_init(libxfs_init_t *args) args->notvolmsg = "you should never get this message - %s"; args->notvolok = 1; + args->setblksize = 1; if (no_modify) args->isreadonly = (LIBXFS_ISREADONLY | LIBXFS_ISINACTIVE); -- 2.47.2