From 8880e7599ced6d047626dd45665b765d0f5eded5 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 26 Nov 2001 21:05:36 -0500 Subject: unix_io.c (unix_open): Work around a bug in 2.4.10+ kernels by trying to unset the filesize limit if at all possible, if a block device is getting opened. (The filesize limit shouldn't be applied against writes to a block device, but starting in 2.4.10, the kernel is doing this.) --- lib/ext2fs/ChangeLog | 8 ++++++++ lib/ext2fs/unix_io.c | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'lib/ext2fs') diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 903b4a2f..419feffa 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,11 @@ +2001-11-26 Theodore Tso + + * unix_io.c (unix_open): Work around a bug in 2.4.10+ kernels by + trying to unset the filesize limit if at all possible, + if a block device is getting opened. (The filesize limit + shouldn't be applied against writes to a block device, but + starting in 2.4.10, the kernel is doing this.) + 2001-11-05 Theodore Tso * mkjournal.c (ext2fs_add_journal_inode): When creating a .journal diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 40bb6c2e..1e01d285 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -30,6 +30,7 @@ #if HAVE_SYS_TYPES_H #include #endif +#include #include "ext2_fs.h" #include "ext2fs.h" @@ -293,6 +294,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) struct unix_private_data *data = NULL; errcode_t retval; int open_flags; + struct stat st; if (name == 0) return EXT2_ET_BAD_DEVICE_NAME; @@ -335,6 +337,24 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) retval = errno; goto cleanup; } + /* + * Work around a bug in 2.4.10+ kernels where writes to block + * devices are wrongly getting hit by the filesize limit. + */ + if ((flags & IO_FLAG_RW) && + (fstat(data->dev, &st) == 0) && + (S_ISBLK(st.st_mode))) { + struct rlimit rlim; + + rlim.rlim_cur = RLIM_INFINITY; + rlim.rlim_max = RLIM_INFINITY; + setrlimit(RLIMIT_FSIZE, &rlim); + getrlimit(RLIMIT_FSIZE, &rlim); + if (rlim.rlim_cur != rlim.rlim_max) { + rlim.rlim_cur = rlim.rlim_max; + setrlimit(RLIMIT_FSIZE, &rlim); + } + } *channel = io; return 0; -- cgit v1.2.3