summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2001-11-26 21:05:36 -0500
committerTheodore Ts'o <tytso@mit.edu>2001-11-26 21:05:36 -0500
commit8880e7599ced6d047626dd45665b765d0f5eded5 (patch)
tree7989253152eed9dca302b7c7d1f8acf2dc5583e1 /lib
parentaa4a58ba2492106695951e4a4082c242ca74b06f (diff)
downloade2fsprogs-8880e7599ced6d047626dd45665b765d0f5eded5.tar.gz
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.)
Diffstat (limited to 'lib')
-rw-r--r--lib/ext2fs/ChangeLog8
-rw-r--r--lib/ext2fs/unix_io.c20
2 files changed, 28 insertions, 0 deletions
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 <tytso@valinux.com>
+
+ * 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 <tytso@valinux.com>
* 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 <sys/types.h>
#endif
+#include <sys/resource.h>
#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;