Re: max file size (again)...

From: Carsten Hoeger (no email)
Date: Mon Sep 01 2003 - 15:14:24 EDT


On Mon, Sep 01, Wietse Venema wrote:

> > > > So why not use the max size off off_t, e.g. using this code:
> > > >
> > > > #define FSIZE_MAX (off_t)1<<((sizeof(off_t)*8)-1)
> > > >
> > > > to determine the maximum size of a file?
> > >
> > > How portable is this? The standard says nothing about the representation
> > > of an off_t, and Postfix makes no assumptions about it. For all we
> > > know it could be packed decimal (BCD) or roman numerals.
> >
> > Well... no comment on this one.
>
> You mean, all the world is a PC so you don't care?

Please

1. do not take me into CC as I am subscribed to this list
2. do not interpret my statements

I might not have your programming experience, but all platforms I know (pc and
not pc) off_t is either a long or a int type. I am a down-to-earth person, so
I don't care too much for hypothetical discussions, so I'll give up here.
 
> > Why do you fall back to INT_MAX?
>
> Postfix falls UPWARDS to INT_MAX. Look at the code.

Anyway, you are using INT and not LONG for whatever reason.
If you don't want to tell me why, well, I also don't care.
 
> > > > in util/file_limit.c
> > > >
> > > > off_t get_file_limit(void)
> > > > {
> > > > off_t limit;
> > > >
> > > > [...] ifdef ULIMIT stuff removed
> > > >
> > > > struct rlimit rlim;
> > > >
> > > > if (getrlimit(RLIMIT_FSIZE, &rlim) < 0)
> > > > msg_fatal("getrlimit: %m");
> > > > limit = rlim.rlim_cur;
> > > > return (limit < 0 ? INT_MAX : rlim.rlim_cur);
> > > > }
> > > >
> > > > What is this test for?
> > >
> > > This is pampering for brain-dead Linux boxes that returned an
> > > unsigned 4GB value into a signed integer, resulting in a negative
> > > file size result.
> >
> > I've been told, that
> >
> > ... getrlimit(RLIMIT_FSIZE, &rlim) returns ULONG_MAX, the
> > limit the kernel is able to handle. and off_t is LONG_MAX + 1, the limit the
> > kernel interface is able to handle.
>
> Again, how portable is this? I know of no standard that requires
> getrlimit() to return values limited by ULONG_MAX.

Do you know a standard, that requires getrlimit() to return something which
can be assigned to a off_t type value without changing the algebraic sign?

-- 
With best regards,
Carsten Hoeger
SuSE, The Linux Experts, http://suse.com - http://unitedlinux.com









Hosted Email Solutions

Invaluement Anti-Spam DNSBLs



Powered By FreeBSD   Powered By FreeBSD