Re: >0x7fffffff blocksize filesystem reporting
From: Kirk McKusick (mckusick_at_beastie.mckusick.com)
Date: 11/07/03
- Previous message: Wes Peters: "Re: newfs and mount vs. half-baked disks"
- In reply to: Tim Robbins: "Re: >0x7fffffff blocksize filesystem reporting"
- Next in thread: Bruce Evans: "Re: >0x7fffffff blocksize filesystem reporting"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
To: Tim Robbins <tjr@freebsd.org> Date: Thu, 06 Nov 2003 16:02:01 -0800
> Date: Thu, 6 Nov 2003 17:45:28 +1100
> From: Tim Robbins <tjr@freebsd.org>
> To: Kirk McKusick <mckusick@mckusick.com>
> Cc: Peter Wemm <peter@freebsd.org>, Robert Watson <rwatson@nailabs.com>,
> arch@freebsd.org
> Subject: Re: >0x7fffffff blocksize filesystem reporting
> X-ASK-Info: Whitelist match
>
> On Wed, Nov 05, 2003 at 09:04:41PM -0800, Kirk McKusick wrote:
>
> > + /*
> > + * Convert a new format statfs structure to an old format statfs structure.
> > + */
> > + static void
> > + cvtstatfs(td, nsp, osp)
> > + struct thread *td;
> > + struct statfs *nsp;
> > + struct ostatfs *osp;
> > + {
> > +
> > + bzero(osp, sizeof(*osp));
> > + osp->f_bsize = nsp->f_bsize;
> > + osp->f_iosize = nsp->f_iosize;
> > + osp->f_blocks = nsp->f_blocks;
> > + osp->f_bfree = nsp->f_bfree;
> > + osp->f_bavail = nsp->f_bavail;
> > + osp->f_files = nsp->f_files;
> > + osp->f_ffree = nsp->f_ffree;
> > + osp->f_owner = nsp->f_owner;
> > + osp->f_type = nsp->f_type;
> > + osp->f_flags = nsp->f_flags;
> > + osp->f_syncwrites = nsp->f_syncwrites;
> > + osp->f_asyncwrites = nsp->f_asyncwrites;
> > + osp->f_syncreads = nsp->f_syncreads;
> > + osp->f_asyncreads = nsp->f_asyncreads;
>
> It may be better to return LONG_MAX for some of these members than to
> truncate the value. Alternatively, the block size could be adjusted
> to ensure that f_blocks fits in a "long" even though f_blocks * f_bsize
> may overflow it, but this is messy and can't help if f_files or
> f_{sync,async}{reads,writes} are too big.
>
> > + bcopy(nsp->f_fstypename, osp->f_fstypename, MFSNAMELEN);
> > + bcopy(nsp->f_mntonname, osp->f_mntonname, MNAMELEN);
> > + bcopy(nsp->f_mntfromname, osp->f_mntfromname, MNAMELEN);
>
> On architectures where longs are not 32 bits (amd64), OMNAMELEN != MNAMELEN,
> so this may do the wrong thing.
>
>
> Tim
You make two good points. Here is my revised diff for cvtstatfs:
+ /*
+ * Convert a new format statfs structure to an old format statfs structure.
+ */
+ static void
+ cvtstatfs(td, nsp, osp)
+ struct thread *td;
+ struct statfs *nsp;
+ struct ostatfs *osp;
+ {
+
+ bzero(osp, sizeof(*osp));
+ osp->f_bsize = MIN(nsp->f_bsize, LONG_MAX);
+ osp->f_iosize = MIN(nsp->f_iosize, LONG_MAX);
+ osp->f_blocks = MIN(nsp->f_blocks, LONG_MAX);
+ osp->f_bfree = MIN(nsp->f_bfree, LONG_MAX);
+ osp->f_bavail = MIN(nsp->f_bavail, LONG_MAX);
+ osp->f_files = MIN(nsp->f_files, LONG_MAX);
+ osp->f_ffree = MIN(nsp->f_ffree, LONG_MAX);
+ osp->f_owner = nsp->f_owner;
+ osp->f_type = nsp->f_type;
+ osp->f_flags = nsp->f_flags;
+ osp->f_syncwrites = MIN(nsp->f_syncwrites, LONG_MAX);
+ osp->f_asyncwrites = MIN(nsp->f_asyncwrites, LONG_MAX);
+ osp->f_syncreads = MIN(nsp->f_syncreads, LONG_MAX);
+ osp->f_asyncreads = MIN(nsp->f_asyncreads, LONG_MAX);
+ bcopy(nsp->f_fstypename, osp->f_fstypename,
+ MIN(MFSNAMELEN, OMNAMELEN));
+ bcopy(nsp->f_mntonname, osp->f_mntonname,
+ MIN(MFSNAMELEN, OMNAMELEN));
+ bcopy(nsp->f_mntfromname, osp->f_mntfromname,
+ MIN(MFSNAMELEN, OMNAMELEN));
_______________________________________________
freebsd-arch@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-arch
To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"
- Previous message: Wes Peters: "Re: newfs and mount vs. half-baked disks"
- In reply to: Tim Robbins: "Re: >0x7fffffff blocksize filesystem reporting"
- Next in thread: Bruce Evans: "Re: >0x7fffffff blocksize filesystem reporting"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
- Re: >0x7fffffff blocksize filesystem reporting
... > + cvtstatfs(td, nsp, osp) ... It may be better to return LONG_MAX for some
of these members than to ... truncate the value. ... (freebsd-arch) - Re: Giving truncate rights to certain users
... As BOL states the only members that can execute this are sa, ... end users (other
than developers doing development) the ability to truncate ... > application that performs
truncate table commands. ... > you have to be a member of sysadmin to do this.
... (microsoft.public.sqlserver.security)