]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
Only try to set block size when running mkfs or repair on an unmounted device.
authorMartin K. Petersen <mkp@linuxcare.com>
Fri, 9 Mar 2001 05:38:39 +0000 (05:38 +0000)
committerMartin K. Petersen <mkp@linuxcare.com>
Fri, 9 Mar 2001 05:38:39 +0000 (05:38 +0000)
include/libxfs.h
libxfs/init.c
mkfs/xfs_mkfs.c
repair/init.c

index 78e5978461e1b550ce8a881b37c3ad04462a1bf0..ba78c774660e9992c65fa740442c5fcce3f98886 100644 (file)
@@ -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);
 
index b40bf31a7620982b799ed1e4c9d33fda1654fb3c..baef767795b0d302a9723a2970538321e63ba301 100644 (file)
@@ -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);
                }
index 13132b979b7d7d431507ba68c2741fa39b592f50..4c2cf51cca3cfe297b11c58d12a8a43a0f1afeee 100644 (file)
@@ -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;
index cc61650c70f17c9f1810e4cfd596f006950a7813..491c12127a28299c5881a9e15d67c2cbdf348b3f 100644 (file)
@@ -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);