- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - OpenVMS
- >
- Re: OpenVMS API to check free space in a disk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2019 09:08 AM
тАО06-12-2019 09:08 AM
Hi there,
Is there an API to check the remaining free space in disk / mounted device (preferrably in bytes)?
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2019 11:29 AM
тАО06-12-2019 11:29 AM
Re: OpenVMS API to check free space in a disk
> Is there an API to check the remaining free space in disk / mounted
> device (preferrably in bytes)?
For information about a device or volume, (assuming C) I'd look at
sys$getdvi(). In <dvidef.h>, I see:
#define DVI$_FREEBLOCKS 42 /* Number of free blocks on the volume (disk) - VALUE - 4 bytes */
So far as I know, VMS tracks disk space only in 512-byte blocks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2019 03:22 PM - edited тАО06-12-2019 03:24 PM
тАО06-12-2019 03:22 PM - edited тАО06-12-2019 03:24 PM
SolutionLook what I found lying around (df.c):
#include <unistd.h>
#include <stdio.h>
#include <descrip.h>
#include <dvidef.h>
#include <starlet.h>
/* GETDVI item descriptor structure. */
typedef struct
{
short buf_len;
short itm_cod;
void *buf;
int *ret_len;
} dvi_item_t;
int main( int argc, char **argv)
{
int sts;
$DESCRIPTOR( sys_disk_descr, "SYS$DISK");
/* DVI item buffers. */
static unsigned freeblocks;
static unsigned maxblocks;
/* GETDVI item lengths. */
static int freeblocks_len; /* Should come back 4. */
static int maxblocks_len; /* Should come back 4. */
/* GETJPI item descriptor set. */
struct
{
dvi_item_t freeblocks_itm;
dvi_item_t maxblocks_itm;
int term;
} dvi_itm_lst =
{ { 4, DVI$_FREEBLOCKS, &freeblocks, &freeblocks_len },
{ 4, DVI$_MAXBLOCK, &maxblocks, &maxblocks_len },
0
};
sts = sys$getdviw( 0, 0, &sys_disk_descr, &dvi_itm_lst, 0, 0, 0);
printf( " dvi sts = %%%08x .\n", sts);
printf( " freeblocks = %d (len = %d).\n", freeblocks, freeblocks_len);
printf( " maxblocks = %d (len = %d).\n", maxblocks, maxblocks_len);
return sts;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2019 03:30 PM - edited тАО06-12-2019 03:32 PM
тАО06-12-2019 03:30 PM - edited тАО06-12-2019 03:32 PM
Re: OpenVMS API to check free space in a disk
Note that the space will be allocated and reported in an integer multiple of the cluster size which will likely be larger than 512 bytes. Most, if not all, disks still in use today will have cluster sizes greater than 1, usually at least 3.
Also, the space reported here will reflect only the available clusters/blocks. The actual amount of space used by a file may be less than calculated here since this level of data only looks at allocated blocks/clusters. There is no direct way to view an entire disk and know the number of available "bytes" without looking at each file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-12-2019 04:34 PM
тАО06-12-2019 04:34 PM
Re: OpenVMS API to check free space in a disk
> Note that the space will be allocated and reported in an integer
> multiple of the cluster size which will likely be larger than 512 bytes.
> [...]
Yes, but $GETDVI returns (512-byte) block counts, not disk cluster
counts.
> Also, the space reported here will reflect only the available
> clusters/blocks. [...]
Huh? Are FREEBLOCKS not FREEBLOCKS?
> [...] The actual amount of space used by a file [...]
As I read the original question, it involved "free space", not "space
used by a file" (or any number of files).
> There is no direct way to view an entire disk and know the number of
> available "bytes" without looking at each file.
Is this some new meaning for "available"? "Not occupied by useful
data" and "available" are spelled differently for a reason. I'd say
that a disk cluster ceases to be "available" when it's allocated to a
file, regardless of how much of that disk cluster is occupied by useful
data. Who else could use that unoccupied space? To whom is it
"available"?
For "used space", you might have an argument, but that was not
requested.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2019 12:08 PM
тАО06-14-2019 12:08 PM
Re: OpenVMS API to check free space in a disk
> Yes, but $GETDVI returns (512-byte) block counts, not disk cluster
>counts.
Agreed, but this will be a multiple of the cluster size (the point I was trying to make as noted below.)
>> Also, the space reported here will reflect only the available
>> clusters/blocks. [...]
> Huh? Are FREEBLOCKS not FREEBLOCKS?
Yes they are. However, since the OP was looking for bytes, that suggests familiarity with the dreaded Windows systems which do not suffer from the block/cluster restrictions (at least not in the same way). Also, I have run across folks that use the FREE stats to determine the amount of USED space. Yes, an allocated block is technically "used", but again Windows based systems report the number of used bytes for a file rather than the allocated space for the file by default. Perhaps, I was anticipating that since the OP requested a byte count, he/she was looking to compare to a Windows box.
Sorry if I struck a nerve.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-14-2019 06:02 PM
тАО06-14-2019 06:02 PM
Re: OpenVMS API to check free space in a disk
> [...] suggests familiarity with the dreaded Windows systems [...]
Not mentioned.
> [...] Perhaps, I was anticipating [...]
And I was trying to answer the question which was asked, not some
other question which I made up myself.
> Sorry if I struck a nerve.
Free advice: If you want to answer your own questions instead of the
original question, then say so, and say what your questions are.
Otherwise risk causing unnecessary confusion.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-21-2019 05:31 AM
тАО06-21-2019 05:31 AM
Re: OpenVMS API to check free space in a disk
Dear Steve,
<<< +++++
And I was trying to answer the question which was asked, not some other question which I made up myself.
Free advice: If you want to answer your own questions instead of the
original question, then say so, and say what your questions are.
Otherwise risk causing unnecessary confusion.
+++++ >>>>
It is always interesting and happy reading your responses since I joined in ITRC in 2004 I guess or may be before that.
I had a big struggle, almost few years recovering my old ITRC ID and joining with you all again and I am extremely happy coming back and seeing my friends Steven, abvsrc, etc. here.
Thanks
Archie