From f154d2f687e922f8444ef3050dc83f5d8e0e2178 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Sun, 14 Jul 2002 08:33:32 -0400 Subject: [PATCH] unix_io.c (unix_open): Only attempt the setrlimit workaround if the kernel version is 2.4.10 -- 2.4.17, since otherwise an old version of glibc (built against 2.2 headers) will interact badly with the workaround to actually cause more problems. I hate it when the glibc folks think they're being smarter than the kernel.... --- lib/ext2fs/ChangeLog | 9 +++++++++ lib/ext2fs/unix_io.c | 20 +++++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 55eae2e..e67e57d 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,12 @@ +2002-07-14 Theodore Ts'o + + * unix_io.c (unix_open): Only attempt the setrlimit workaround if + the kernel version is 2.4.10 -- 2.4.17, since otherwise an + old version of glibc (built against 2.2 headers) will + interact badly with the workaround to actually cause more + problems. I hate it when the glibc folks think they're + being smarter than the kernel.... + 2002-06-28 Andreas Dilger * ext2_fs.h: Add superblock field for reserved group descriptors. diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c index 9b3b6ab..e8cd880 100644 --- a/lib/ext2fs/unix_io.c +++ b/lib/ext2fs/unix_io.c @@ -25,6 +25,9 @@ #endif #include #include +#ifdef __linux__ +#include +#endif #if HAVE_SYS_STAT_H #include #endif @@ -296,6 +299,9 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) errcode_t retval; int open_flags; struct stat st; +#ifdef __linux__ + struct utsname ut; +#endif if (name == 0) return EXT2_ET_BAD_DEVICE_NAME; @@ -347,10 +353,18 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel) #define RLIM_INFINITY (~0UL) #endif /* - * Work around a bug in 2.4.10+ kernels where writes to block - * devices are wrongly getting hit by the filesize limit. + * Work around a bug in 2.4.10-2.4.18 kernels where writes to + * block devices are wrongly getting hit by the filesize + * limit. This workaround isn't perfect, since it won't work + * if glibc wasn't built against 2.2 header files. (Sigh.) + * */ - if ((flags & IO_FLAG_RW) && + if ((flags & IO_FLAG_RW) && + (uname(&ut) == 0) && + ((ut.release[0] == '2') && (ut.release[1] == '.') && + (ut.release[2] == '4') && (ut.release[3] == '.') && + (ut.release[4] == '1') && (ut.release[5] >= '0') && + (ut.release[5] < '8')) && (fstat(data->dev, &st) == 0) && (S_ISBLK(st.st_mode))) { struct rlimit rlim; -- 1.8.3.1