1 /* 2 * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA 3 */ 4 5 #ifndef DI_INC_DI_H 6 #define DI_INC_DI_H 7 8 #include "config.h" 9 10 /*****************************************************/ 11 12 #include <stdio.h> 13 #if _hdr_fcntl \ 14 && ! defined (DI_INC_FCNTL_H) /* xenix */ 15 # define DI_INC_FCNTL_H 16 # include <fcntl.h> 17 #endif 18 #if _sys_file 19 # include <sys/file.h> 20 #endif 21 #if _sys_types \ 22 && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ 23 # define DI_INC_SYS_TYPES_H 24 # include <sys/types.h> 25 #endif 26 #if _hdr_limits 27 # include <limits.h> /* PATH_MAX */ 28 #endif 29 #if _sys_param 30 # include <sys/param.h> /* MAXPATHLEN */ 31 #endif 32 #if _hdr_zone 33 # include <zone.h> 34 #endif 35 36 #if ! defined (O_NOCTTY) 37 # define O_NOCTTY 0 38 #endif 39 40 #if ! defined (MAXPATHLEN) 41 # if defined (_POSIX_PATH_MAX) 42 # define MAXPATHLEN _POSIX_PATH_MAX 43 # else 44 # if defined (PATH_MAX) 45 # define MAXPATHLEN PATH_MAX 46 # endif 47 # if defined (LPNMAX) 48 # define MAXPATHLEN LPNMAX 49 # endif 50 # endif 51 #endif 52 53 #if ! defined (MAXPATHLEN) 54 # define MAXPATHLEN 255 55 #endif 56 57 #if _sys_fstyp /* HP-UX, Solaris */ 58 # include <sys/fstyp.h> /* FSTYPSZ */ 59 # if defined (FSTYPSZ) 60 # define DI_TYPE_LEN FSTYPSZ 61 # endif 62 #endif 63 #if _sys_mount \ 64 && ! defined (DI_INC_SYS_MOUNT) /* NetBSD */ 65 # define DI_INC_SYS_MOUNT 1 66 # include <sys/mount.h> /* MFSNAMELEN */ 67 # if ! defined (DI_TYPE_LEN) && defined (MFSNAMELEN) 68 # define DI_TYPE_LEN MFSNAMELEN 69 # endif 70 #endif 71 #if _sys_vfstab /* ??? */ 72 # include <sys/vfstab.h> 73 # if ! defined (DI_TYPE_LEN) && defined (FSTYPSZ) 74 # define DI_TYPE_LEN FSTYPSZ 75 # endif 76 #endif 77 78 #if ! defined (DI_TYPE_LEN) 79 # define DI_TYPE_LEN 65 80 #endif 81 82 #if ! _lib_memcpy && ! _define_memcpy 83 # if ! _lib_bcopy && ! _define_bcopy 84 #error No_memcpy/bcopy_available. 85 # else 86 # define memcpy(dst, src, cnt) (bcopy((src), (dst), (cnt)), dst) 87 # endif 88 #endif 89 90 #if ! _lib_memset && ! _define_memset 91 # if ! _lib_bzero && ! _define_bzero 92 #error No_memset/bzero_available. 93 # else 94 # define memset(s,c,n) (bzero ((s), (n)), s) 95 # endif 96 #endif 97 98 #define DI_NAME_LEN MAXPATHLEN 99 #define DI_SPEC_NAME_LEN MAXPATHLEN 100 #define DI_OPT_LEN MAXPATHLEN 101 #define DI_MNT_TIME_LEN 24 102 103 #if _siz_long_long >= 4 104 typedef unsigned long long _fs_size_t; 105 typedef long long _s_fs_size_t; 106 # define DI_LL "ll" 107 # define DI_LLu "llu" 108 #else 109 typedef unsigned long _fs_size_t; 110 typedef long _s_fs_size_t; 111 # define DI_LL "l" 112 # define DI_LLu "lu" 113 #endif 114 #if _siz_long_double >= 8 && _printf_long_double 115 typedef long double _print_size_t; 116 # define DI_Lf "Lf" 117 #else 118 typedef double _print_size_t; 119 # define DI_Lf "f" 120 #endif 121 122 typedef unsigned long __ulong; 123 124 #if ! defined (TRUE) 125 # define TRUE 1 126 #endif 127 #if ! defined (FALSE) 128 # define FALSE 0 129 #endif 130 131 #define DI_PRNT_IGNORE 0 132 #define DI_PRNT_OK 1 133 #define DI_PRNT_BAD 2 134 #define DI_PRNT_OUTOFZONE 3 135 #define DI_PRNT_EXCLUDE 4 136 #define DI_PRNT_FORCE 5 137 #define DI_PRNT_SKIP 6 138 139 #define DI_MAIN_SORT_IDX 0 140 #define DI_TOT_SORT_IDX 1 141 142 typedef struct 143 { 144 unsigned int sortIndex [2]; 145 _fs_size_t totalSpace; 146 _fs_size_t freeSpace; 147 _fs_size_t availSpace; 148 _fs_size_t totalInodes; 149 _fs_size_t freeInodes; 150 _fs_size_t availInodes; 151 __ulong st_dev; /* disk device number */ 152 __ulong sp_dev; /* special device number */ 153 __ulong sp_rdev; /* special rdev # */ 154 char doPrint; /* do we want to print */ 155 /* this entry? */ 156 char printFlag; /* print flags */ 157 char isLocal; /* is this mount point */ 158 /* local? */ 159 char isReadOnly; /* is this mount point */ 160 /* read-only? */ 161 char isLoopback; /* lofs or none fs type? */ 162 char name [DI_NAME_LEN + 1]; /* mount point */ 163 char special [DI_SPEC_NAME_LEN + 1]; /* special device name */ 164 char fsType [DI_TYPE_LEN + 1]; /* type of file system */ 165 char options [DI_OPT_LEN + 1]; 166 char mountTime [DI_MNT_TIME_LEN + 1]; 167 } diDiskInfo_t; 168 169 typedef struct 170 { 171 char *special; 172 char *name; 173 char *type; 174 Uid_t uid; 175 Gid_t gid; 176 _fs_size_t blockSize; 177 _fs_size_t limit; 178 _fs_size_t used; 179 _fs_size_t ilimit; 180 _fs_size_t iused; 181 } diQuota_t; 182 183 typedef struct 184 { 185 int count; 186 char **list; 187 } iList_t; 188 189 #if ! _lib_zone_list 190 # define zoneid_t int 191 # define ZONENAME_MAX 65 192 #endif 193 194 typedef struct { 195 zoneid_t zoneid; 196 char name [ZONENAME_MAX + 1]; 197 char rootpath [MAXPATHLEN + 1]; 198 Size_t rootpathlen; 199 } zoneSummary_t; 200 201 typedef struct { 202 Uid_t uid; 203 zoneid_t myzoneid; 204 zoneSummary_t *zones; 205 Uint_t zoneCount; 206 char zoneDisplay [MAXPATHLEN + 1]; 207 int globalIdx; 208 } zoneInfo_t; 209 210 #define DI_SORT_MAX 10 211 212 /* order from best to worst */ 213 #define DI_EXIT_NORM 0 214 #define DI_EXIT_OK 1 215 #define DI_EXIT_WARN 2 216 #define DI_EXIT_FAIL 3 217 218 typedef struct { 219 const char *formatString; 220 _print_size_t dispBlockSize; 221 _print_size_t baseDispSize; 222 unsigned int baseDispIdx; 223 char sortType [DI_SORT_MAX + 1]; 224 unsigned int posix_compat; 225 unsigned int quota_check; 226 unsigned int csv_output; 227 unsigned int csv_tabs; 228 unsigned int excludeLoopback; 229 unsigned int json_output; 230 unsigned int printTotals; 231 unsigned int printDebugHeader; 232 unsigned int printHeader; 233 unsigned int displayAll; 234 unsigned int localOnly; 235 unsigned int dontResolveSymlink; 236 unsigned int exitFlag; 237 int errorCount; 238 } diOptions_t; 239 240 typedef struct { 241 Size_t inodeWidth; 242 Size_t maxMntTimeString; 243 Size_t maxMountString; 244 Size_t maxOptString; 245 Size_t maxSpecialString; 246 Size_t maxTypeString; 247 Size_t width; 248 const char *dispBlockLabel; 249 char blockFormat [25]; 250 char blockFormatNR [25]; /* no radix */ 251 char inodeFormat [25]; 252 char inodeLabelFormat [25]; 253 char mountFormat [25]; 254 char mTimeFormat [25]; 255 char optFormat [25]; 256 char specialFormat [25]; 257 char typeFormat [25]; 258 } diOutput_t; 259 260 typedef struct { 261 int count; 262 int haspooledfs; 263 int disppooledfs; 264 int totsorted; 265 diOptions_t options; 266 diOutput_t output; 267 diDiskInfo_t *diskInfo; 268 iList_t ignoreList; 269 iList_t includeList; 270 zoneInfo_t zoneInfo; 271 } diData_t; 272 273 # if defined (__cplusplus) || defined (c_plusplus) 274 extern "C" { 275 # endif 276 277 #if ! _dcl_errno 278 extern int errno; 279 #endif 280 281 /* digetentries.c */ 282 extern int di_getDiskEntries _((diDiskInfo_t **, int *)); 283 /* digetinfo.c */ 284 extern void di_getDiskInfo _((diDiskInfo_t **, int *)); 285 /* diquota.c */ 286 extern void diquota _((diQuota_t *)); 287 /* strdup.c */ 288 # if ! _lib_strdup 289 extern char *strdup _((const char *)); 290 # endif 291 /* strstr.c */ 292 # if ! _lib_strstr 293 extern char *strstr _((const char *, const char *)); 294 # endif 295 /* trimchar.c */ 296 extern void trimChar _((char *, int)); 297 /* realloc.c */ 298 extern _pvoid di_realloc _((_pvoid, Size_t)); 299 /* didiskutil.c */ 300 extern void di_initDiskInfo _((diDiskInfo_t *)); 301 extern void di_saveBlockSizes _((diDiskInfo_t *, _fs_size_t, _fs_size_t, _fs_size_t, _fs_size_t)); 302 extern void di_saveInodeSizes _((diDiskInfo_t *, _fs_size_t, _fs_size_t, _fs_size_t)); 303 #if _lib_getmntent \ 304 && ! _lib_getmntinfo \ 305 && ! _lib_getfsstat \ 306 && ! _lib_getvfsstat \ 307 && ! _lib_mntctl \ 308 && ! _class_os__Volumes 309 extern char *chkMountOptions _((const char *, const char *)); 310 #endif 311 extern void convertMountOptions _((unsigned long, diDiskInfo_t *)); 312 extern void convertNFSMountOptions _((long, long, long, diDiskInfo_t *)); 313 extern void di_testRemoteDisk _((diDiskInfo_t *)); 314 extern int di_isPooledFs _((diDiskInfo_t *)); 315 extern int di_isLoopbackFs _((diDiskInfo_t *)); 316 extern Size_t di_mungePoolName _((char *)); 317 318 # if defined (__cplusplus) || defined (c_plusplus) 319 } 320 # endif 321 322 /* macro for gettext() */ 323 #ifndef DI_GT 324 # if _enable_nls 325 # define DI_GT(args) gettext(args) 326 # else 327 # define DI_GT(args) (args) 328 # endif 329 #endif 330 331 # if _lib_sys_dollar_device_scan && _lib_sys_dollar_getdviw 332 333 /* Thanks to Craig Berry's VMS::Device for the VMS code. */ 334 335 typedef struct { 336 short buflen; /* Length of output buffer */ 337 short itmcode; /* Item code */ 338 void *buffer; /* Buffer address */ 339 void *retlen; /* Return length address */ 340 } VMS_ITMLST; 341 342 # define DVI_IS_STRING 1 343 # define DVI_IS_LONGWORD 2 344 # define DVI_IS_QUADWORD 3 345 # define DVI_IS_WORD 4 346 # define DVI_IS_BYTE 5 347 # define DVI_IS_VMSDATE 6 348 # define DVI_IS_BITMAP 7 /* Each bit in the return value indicates something */ 349 # define DVI_IS_ENUM 8 /* Each returned value has a name, and we ought to */ 350 /* return the name instead of the value */ 351 # define DVI_IS_ODD 9 /* A catchall */ 352 353 354 # define DVI_IS_INPUT (1<<0) 355 # define DVI_IS_OUTPUT (1<<1) 356 # define DVI_ENT(a, b, c) {#a, DVI$_##a, b, c, DVI_IS_OUTPUT} 357 358 typedef struct { 359 char *name; /* Pointer to the item name */ 360 int syscallValue; /* Value to use in the getDVI item list */ 361 int bufferLen; /* Length the return va buf needs to be. (no nul */ 362 /* terminators, so must be careful with the return */ 363 /* values. */ 364 int returnType; /* Type of data the item returns */ 365 int inOut; /* Is this an input or an output item? */ 366 } genericID_t ; 367 368 /* Macro to fill in a 'traditional' item-list entry */ 369 # define init_itemlist(ile, length, code, bufaddr, retlen_addr) \ 370 { \ 371 (ile)->buflen = (length); \ 372 (ile)->itmcode = (code); \ 373 (ile)->buffer = (bufaddr); \ 374 (ile)->retlen = (retlen_addr) ;} 375 376 # endif 377 378 #endif /* DI_INC_DI_H */ 379