Bug 61753 - e2fsprogs-1.26 doesn't work on LFS
e2fsprogs-1.26 doesn't work on LFS
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: e2fsprogs (Show other bugs)
7.3
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Florian La Roche
Aaron Brown
:
Depends On:
Blocks: 61901
  Show dependency treegraph
 
Reported: 2002-03-24 01:10 EST by hjl
Modified: 2007-04-18 12:41 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-03-26 11:56:45 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
A patch (635 bytes, patch)
2002-03-24 01:11 EST, hjl
no flags Details | Diff
A new patch. (629 bytes, patch)
2002-03-24 13:34 EST, hjl
no flags Details | Diff

  None (edit)
Description hjl 2002-03-24 01:10:52 EST
The code in e2fsprogs-1.26/lib/ext2fs/unix_io.c looks like

#define _LARGEFILE_SOURCE
#define _LARGEFILE64_SOURCE
...
        /*
         * 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.rlim_max = ((unsigned long)(~0UL));
                setrlimit(RLIMIT_FSIZE, &rlim); 
                getrlimit(RLIMIT_FSIZE, &rlim); 
                if (((unsigned long) rlim.rlim_cur) <
                    ((unsigned long) rlim.rlim_max)) {
                        rlim.rlim_cur = rlim.rlim_max;
                        setrlimit(RLIMIT_FSIZE, &rlim); 
                }
        }

It is big no no not to use RLIM_INFINITY and assume the type of rlim.rlim_cur.
Comment 1 hjl 2002-03-24 01:11:43 EST
Created attachment 49925 [details]
A patch
Comment 2 hjl 2002-03-24 13:22:56 EST
The real problem is

# grep RLIM_INFINITY asm-*/resource.h | grep define
asm-alpha/resource.h:#define RLIM_INFINITY      0x7ffffffffffffffful
asm-arm/resource.h:#define RLIM_INFINITY        (~0UL)
asm-cris/resource.h:#define RLIM_INFINITY       (~0UL)
asm-i386/resource.h:#define RLIM_INFINITY       (~0UL)
asm-ia64/resource.h:#define RLIM_INFINITY  (~0UL)
asm-m68k/resource.h:#define RLIM_INFINITY       (~0UL)
asm-mips64/resource.h:#define RLIM_INFINITY  (~0UL)
asm-mips/resource.h:#define RLIM_INFINITY       0x7fffffffUL
asm-parisc/resource.h:#define RLIM_INFINITY   (~0UL)
asm-ppc/resource.h:#define RLIM_INFINITY        (~0UL)
asm-s390/resource.h:#define RLIM_INFINITY   (~0UL)
asm-s390x/resource.h:#define RLIM_INFINITY   (~0UL)
asm-sh/resource.h:#define RLIM_INFINITY (~0UL)
asm-sparc64/resource.h:#define RLIM_INFINITY    (~0UL)
asm-sparc/resource.h:#define RLIM_INFINITY      0x7fffffff

(~0UL) doesn't work for alpha, mips nor sparc. RLIM_INFINITY from glibc should
be used. It
should work with the old and new kernel.
Comment 3 hjl 2002-03-24 13:34:31 EST
Created attachment 49985 [details]
A new patch.
Comment 4 Florian La Roche 2002-03-24 13:43:11 EST
1.27 has some of these issues resolved. If that version works for you, I can
make an update for it.

Thanks,

Florian La Roche
Comment 5 hjl 2002-03-24 14:56:46 EST
1.27 has

       if ((flags & IO_FLAG_RW) && 
            (fstat(data->dev, &st) == 0) &&
            (S_ISBLK(st.st_mode))) {
                struct rlimit   rlim;   
        
                rlim.rlim_cur = rlim.rlim_max = (unsigned long) RLIM_INFINITY;
                setrlimit(RLIMIT_FSIZE, &rlim);
                getrlimit(RLIMIT_FSIZE, &rlim); 
                if (((unsigned long) rlim.rlim_cur) <
                    ((unsigned long) rlim.rlim_max)) {
                        rlim.rlim_cur = rlim.rlim_max;
                        setrlimit(RLIMIT_FSIZE, &rlim);
                }
        }

It is better. But it doesn't make more senses. glibc will make sure sertlimit
works correctly
under new and old kernels. There is no need to call getrlimit. Just do

                rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
                setrlimit(RLIMIT_FSIZE, &rlim);

It will work just fine. There is no need for 1.27 if my patch is applied.
Comment 6 Florian La Roche 2002-03-27 06:03:24 EST
I have updated to 1.27, so it is fixed in rawhide now. I don't want to
remove the "getrlimit()" call, it shouldn't harm.

cu,

Florian La Roche

Note You need to log in before you can comment on or make changes to this bug.