-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcmsfsvol.c
More file actions
81 lines (68 loc) · 2.28 KB
/
cmsfsvol.c
File metadata and controls
81 lines (68 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
*
* Name: cmsfsvol.c (C source)
* report CMS FS volume information like 'Q DISK'
*
*/
#include <time.h>
/* the following is a cheezy way to get ssize_t def'd */
#include <fcntl.h>
#include <stdio.h>
#include "cmsfs.h"
#define USAGE "Usage: %s [ -d ] cmsvol [cmsvol ...]\n"
/* ------------------------------------------------------------------ */
int main(int argc,char*argv[])
{
int i, percent;
struct CMSSUPER *tempvols;
struct CMSINODE dirinode, tmpinode;
struct tm *ftime;
/* process options */
for (i = 1 ; i < argc && argv[i][0] == '-' ; i++)
{
switch (argv[i][1])
{
case '?': case 'h': case 'H': /* quickie help */
(void) fprintf(stderr,"%s %s\n",CMSFS_DESCRIPTION,CMSFS_VERSION);
(void) fprintf(stderr,
"Report CMS volume info in CMS 'Q DISK' format.\n");
(void) fprintf(stderr,USAGE,argv[0]);
return 0;
case 'd':
case 'f': /* devname = argv[++i]; */
/* (see loop below; handled differently now) */
break;
default:
break;
}
}
/* sanity check: specify a volume to list */
if (i >= argc)
{
(void) fprintf(stderr,"Please specify a CMS volume to report.\n");
(void) fprintf(stderr,USAGE,argv[0]);
return 24;
}
/* print a header; looks like CMS */
(void) printf("LABEL VDEV M STAT CYL TYPE \
BLKSZ FILES BLKS USED-(%) BLKS LEFT BLK TOTAL\n");
for ( ; i < argc ; i++)
{
/* open the volume */
tempvols = cmsfs_vopen(argv[i]);
if (tempvols == NULL)
{
(void) fprintf(stderr,"'%s' is not a CMS volume.\n",argv[i]);
return -1;
}
/* report on the volume */
percent = ( tempvols->bkused * 100 ) / tempvols->blocks;
(void) printf("%-6s .... ... R/O %5d .... %4d %8d %10d-%02d %10d \
%10d\n",tempvols->volid,tempvols->ncyls,tempvols->blksz,tempvols->files,
tempvols->bkused,percent,tempvols->bkfree,tempvols->blocks);
/* close the volume */
(void) cmsfs_vclose(tempvols);
}
/* exit */
return 0;
}