From: Theodore Ts'o Date: Sun, 19 Mar 2006 01:03:47 +0000 (-0500) Subject: Change resize2fs open modes for mounted and unmounted filesystems X-Git-Tag: E2FSPROGS-1.39-WIP-0330~22 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=5d2ef12f6ed4c35c7e6baa7cb83ced738a3f1976;p=tools%2Fe2fsprogs.git Change resize2fs open modes for mounted and unmounted filesystems If the filesystem is mounted, open it in read-only mode since the userspace program should not try to modify it directly. If the filesystem is not mounted, open it in exclusive mode to avoid potential problems (such as someone trying to mount the filesystem while it is being resized). Signed-off-by: "Theodore Ts'o" --- diff --git a/resize/ChangeLog b/resize/ChangeLog index 07ca8f4..6b727e9 100644 --- a/resize/ChangeLog +++ b/resize/ChangeLog @@ -1,3 +1,12 @@ +2006-03-18 Theodore Ts'o + + * main.c (main): If the filesystem is mounted, open it in + read-only mode since the userspace program should not try + to modify it directly. If the filesystem is not mounted, + open it in exclusive mode to avoid potential problems + (such as someone trying to mount the filesystem while it + is being resized). + 2006-03-17 Theodore Ts'o * resize2fs.8.in: Update manpage to document that that resize2fs diff --git a/resize/main.c b/resize/main.c index d6ddaa7..e202c5f 100644 --- a/resize/main.c +++ b/resize/main.c @@ -102,6 +102,7 @@ int main (int argc, char ** argv) int flags = 0; int flush = 0; int force = 0; + int io_flags = 0; int fd, ret; blk_t new_size = 0; blk_t max_size = 0; @@ -234,7 +235,9 @@ int main (int argc, char ** argv) } else io_ptr = unix_io_manager; - retval = ext2fs_open2(device_name, io_options, EXT2_FLAG_RW, + if (!(mount_flags & EXT2_MF_MOUNTED)) + io_flags = EXT2_FLAG_RW | EXT2_FLAG_EXCLUSIVE; + retval = ext2fs_open2(device_name, io_options, io_flags, 0, 0, io_ptr, &fs); if (retval) { com_err (program_name, retval, _("while trying to open %s"),