Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 01 Aug 2001 22:29:39 -0500
From:      Jim Bryant <kc5vdj@yahoo.com>
To:        kstewart@urx.com
Cc:        Joseph Gleason <clash@tasam.com>, Alex Zepeda <jazepeda@pacbell.net>, hackers@FreeBSD.ORG
Subject:   Re: Finding filesizes in C++ for files greater than 4gb
Message-ID:  <3B68C923.9C175779@yahoo.com>
References:  <00b201c11af3$4fef1c10$0a2d2d0a@battleship> <20010801184531.A7725@zippy.mybox.zip> <003c01c11afb$3cdc7980$0a2d2d0a@battleship> <3B68C175.E8E8D444@yahoo.com> <3B68C244.20A4E2C9@urx.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Kent Stewart wrote:
> 
> Jim Bryant wrote:
> >
> > Joseph Gleason wrote:
> > >
> > > ----- Original Message -----
> > > From: "Alex Zepeda" <jazepeda@pacbell.net>
> > > To: "Joseph Gleason" <clash@tasam.com>; <hackers@FreeBSD.ORG>
> > > Sent: Wednesday, August 01, 2001 21:45
> > > Subject: Re: Finding filesizes in C++ for files greater than 4gb
> > >
> > > > On Wed, Aug 01, 2001 at 09:34:43PM -0400, Joseph Gleason wrote:
> > > >
> > > > > In FreeBSD, how can I determine the size of a file in C++ when the file
> > > is
> > > > > greater than 4gb?
> > > > >
> > > > > Currently, I use stat() and use st_size.  That is limited to 4gb (32bit
> > > > > unsigned int)
> > > >
> > > > You're wrong.  Read the man page.  No soup for you!  Next!
> > > >
> > > > - alex
> > >
> > > Alright, I made a mistake.  But I did read the man page.  Where does it say
> > > off_t is 64bits?
> > >
> > > My mistake was not digging through the include files enough to see what was
> > > going on.
> >
> > I think you got him on that, but [cut and paste of two consecutive lines from the manpage]...
> >
> >          off_t     st_size;              /* file size, in bytes */
> >          int64_t   st_blocks;            /* blocks allocated for file */
> >
> > If the manpage specifies int64_t for the blocks, even though off_t isn't specified in the manpage, what does it lead you to assume?
> >
> > Although 64-bit file sizes have been part of FreeBSD since 2.0-RELEASE back in 1994 [as I recall], maybe the manpages should reflect
> > this fact by means other than the deductive reasoning outlined above.  Joseph has made a good point.
> 
> Just so someone can see it.
> 
> coral# grep BSD_OFF *.h
> ansi.h:#define  _BSD_OFF_T_     __int64_t               /* file offset */
> coral# pwd
> /usr/include/machine
> 
> Kent

Kent, my point is that the manual page should specify this.  I think that's the point the original poster was trying to make once he
was told.

You should not have to grep ansi.h to determine the type for off_t, if anything, maybe adding BSD_OFF_T to types(5).  types(5)
states the following for off_t:

     typedef _BSD_OFF_T_     off_t;          /* file offset */

Where does that say 64 bits?  Let's see what the references are:

SEE ALSO
     gdb(1), lseek(2), time(3), fs(5)

hmmm...  maybe lseek?

Nope..  The only reference to off_t there is:

SYNOPSIS
     #include <unistd.h>

     off_t
     lseek(int fildes, off_t offset, int whence);

IMHO, the definition of BSD_* belongs in types(5), where it is referenced.

But, in fs(5), I see a bit of a deviation from FreeBSD coding practice...

             u_int64_t fs_maxfilesize;/* maximum representable file size */

Why isn't that defined as off_t or BSD_OFF_T?

Bottom line, he went to stat(2) to find this info.  stat(2) gives this:

SEE ALSO
     access(2), chmod(2), chown(2), utimes(2), symlink(7)

In other words, I went on a hunch that it would be in types(5), but someone not knowing the manpage for types(5) was there would
have never found this, nor would it have answered his question, as types(5) only lists BSD_OFF_T as the size, and for the life of
me, I'm not sure which manpage specifies that, of course, I'm only an amateur, only having had running FBSD systems since
1.1.5.1-RELEASE.

To go off on another tangent...  In fs(5), I find this, which directly conflicts with the stat structure listed in stat(2) [quoted
from my last post]:

             int32_t  fs_size;       /* number of blocks in fs */

So....  Which is it?

I can see how someone could get confused, especially the newly initiated.

jim
-- 
ET has one helluva sense of humor!
He's always anal-probing right-wing schizos!

_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3B68C923.9C175779>