summaryrefslogtreecommitdiff
path: root/lib/ext2fs/unix_io.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2002-02-23 18:50:32 -0500
committerTheodore Ts'o <tytso@mit.edu>2002-02-23 18:50:32 -0500
commit64e1b274edc48553c76511ff9b30f85c52aff046 (patch)
tree6b683f57a8852c12f04ac360a976ef8a333b30c9 /lib/ext2fs/unix_io.c
parentd1a2182a1878b1dc6c0996ed1a6c5b108f6626f9 (diff)
downloade2fsprogs-64e1b274edc48553c76511ff9b30f85c52aff046.tar.gz
unix_io.c (unix_open): Fix 2.4 resource limit workaround so that
it doesn't break things on mis32, sparc32, and alpha platforms.
Diffstat (limited to 'lib/ext2fs/unix_io.c')
-rw-r--r--lib/ext2fs/unix_io.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 0f993e49..9b3b6ab2 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -3,7 +3,8 @@
*
* Implements a one-block write-through cache.
*
- * Copyright (C) 1993, 1994, 1995 Theodore Ts'o.
+ * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+ * 2002 by Theodore Ts'o.
*
* %Begin-Header%
* This file may be redistributed under the terms of the GNU Public
@@ -337,6 +338,14 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
retval = errno;
goto cleanup;
}
+
+#ifdef __linux__
+#undef RLIM_INFINITY
+#if (defined(__alpha__) || ((defined(__sparc__) || defined(__mips__)) && (SIZEOF_LONG == 4)))
+#define RLIM_INFINITY ((unsigned long)(~0UL>>1))
+#else
+#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.
@@ -346,7 +355,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
(S_ISBLK(st.st_mode))) {
struct rlimit rlim;
- rlim.rlim_cur = rlim.rlim_max = ((unsigned long)(~0UL));
+ rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY;
setrlimit(RLIMIT_FSIZE, &rlim);
getrlimit(RLIMIT_FSIZE, &rlim);
if (((unsigned long) rlim.rlim_cur) <
@@ -355,6 +364,7 @@ static errcode_t unix_open(const char *name, int flags, io_channel *channel)
setrlimit(RLIMIT_FSIZE, &rlim);
}
}
+#endif
*channel = io;
return 0;