Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Determining free disk space in VxWorks

2,714 views
Skip to first unread message

Andy Kaiser

unread,
Jan 19, 2001, 11:55:53 AM1/19/01
to
Here's a question that is probably common knowledge, but one that I
can't find the answer to anywhere - user manuals, web sites, Deja.com,
etc.

I'm working with VxWorks 5.4, trying to determine how much disk space is
left on the hard drive, to determine whether or not lower priority log
files must be deleted to make room for higher priority ones.
Unfortunately, I see no such command to do this, although I refuse to
believe VxWorks doesn't have it! Even something like the "du" command in
Unix would be acceptable, just to tell me how much space is taken up.

Feel free to tell me that I'm blind, and the command is right in the
user manual, but if anyone knows how to do this, I'd appreciate it if
you could e-mail me. Thanks in advance for any and all help!

Andy Kaiser
Software Engineer
L-3 Communication Systems - East
andy....@l-3com.com
vann...@op.net


Sent via Deja.com
http://www.deja.com/

M. Kotiaho

unread,
Jan 23, 2001, 1:33:11 PM1/23/01
to
Andy Kaiser wrote:

Andy,

My guess is that VxWorks doesn't have such a command because it
doesn't have a native file system. The closest thing I could find, if your
hard drive is mounted using dosFsLib, is an ioctl call to find the largest
contiguous free space:

status = ioctl (fd, FIONCONTIG, &maxContigBytes);

Please post if you find something better.

HTH,
Markku Kotiaho

Matthias Guelck

unread,
Jan 24, 2001, 5:19:37 AM1/24/01
to
Hi Andy,

Have a look at the statfs() function and the definition of struct statfs in
\Tornado\target\h\stat.h.

Hope this helps…

Matthias

//******************************************************************************
********************
//
*
// function name : diskFreeSpace
*
//
*
// description : find out how much space is left on disk
*
//
*
// passing param. : szDiskName: name of disk to be checked
*
//
*
// return param. : lDiskFreeSpace: -1 in case of error, else available disk
space *
//
*
//******************************************************************************
********************
// 15.04.99 MAG : created
*
//******************************************************************************
********************
// revision history:
*
// -----------------
*
// 15.04.99 XXX :
*
//******************************************************************************
********************

long diskFreeSpace(char *szDiskName)
{
long lDiskFreeSpace;
struct statfs SStatFs;

if (statfs(szDiskName,&SStatFs)==OK)
{
lDiskFreeSpace= SStatFs.f_bsize * SStatFs.f_bavail;
}
else
{
lDiskFreeSpace= -1;
}

return lDiskFreeSpace;
}

"Andy Kaiser" <vann...@op.net> wrote in message
news:949rik$m8d$1...@nnrp1.deja.com...

Bob Irwin

unread,
Jan 25, 2001, 10:55:40 AM1/25/01
to
"M. Kotiaho" wrote:
>
> Andy Kaiser wrote:
>
> > Here's a question that is probably common knowledge, but one that I
> > can't find the answer to anywhere - user manuals, web sites, Deja.com,
> > etc.
> >
> > I'm working with VxWorks 5.4, trying to determine how much disk space is
> > left on the hard drive, to determine whether or not lower priority log
> > files must be deleted to make room for higher priority ones.
> > Unfortunately, I see no such command to do this, although I refuse to
> > believe VxWorks doesn't have it! Even something like the "du" command in
> > Unix would be acceptable, just to tell me how much space is taken up.

>

> My guess is that VxWorks doesn't have such a command because it
> doesn't have a native file system. The closest thing I could find, if your
> hard drive is mounted using dosFsLib, is an ioctl call to find the largest
> contiguous free space:
>
> status = ioctl (fd, FIONCONTIG, &maxContigBytes);
>
> Please post if you find something better.

To get file system status of my dos formatted drive, I use the POSIX call
'statfs' from dirLib. i.e.

struct statfs driveStatus;

status = statfs ("/sd1/", &driveStatus);

This will likely give you what you need.

- bob

Andy Kaiser

unread,
Jan 31, 2001, 12:09:47 PM1/31/01
to
Thanks to all that replied to my problem - statfs did the trick nicely.
The only problem I'm having now is that statfs conveniently uses a long
to count the free space available on the drive, and with my 18GB
partition, it's rolling over several times. We can work around that
here, though, I think. Anyway, thanks again for the suggestions offered!

Andy

lasseki...@gmail.com

unread,
Feb 4, 2019, 3:52:00 AM2/4/19
to
You can also use statfs64. No need for any work-around then. Cheers, Lasse
0 new messages