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" <tytso@mit.edu>
+2006-03-18 Theodore Ts'o <tytso@mit.edu>
+
+ * 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 <tytso@mit.edu>
* resize2fs.8.in: Update manpage to document that that resize2fs
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;
} 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"),