]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
unix_io.c (unix_open): Work around a bug in 2.4.10+ kernels by
authorTheodore Ts'o <tytso@mit.edu>
Tue, 27 Nov 2001 02:05:36 +0000 (21:05 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 27 Nov 2001 02:05:36 +0000 (21:05 -0500)
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
lib/ext2fs/unix_io.c

index 903b4a2fc3475d66478458db19fe7bf55893c46e..419feffaef983e77cb2a371dac78be1d15672409 100644 (file)
@@ -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
index 40bb6c2e1a4cb37f8aa890bad31c730f197e2d1e..1e01d285ebff5b0d6b8267fbc49fca0741620f0c 100644 (file)
@@ -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;