*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: check_usage | Section: 3 | Source: Digital UNIX | File: check_usage.3.gz
check_usage(3) Library Functions Manual check_usage(3) NAME check_usage - Checks whether a disk partition is in use LIBRARY Filesystem Library (libfilsys.a) Shared Filesystem Library (libfilsys.so) SYNOPSIS #include <sys/disklabel.h> #include <overlap.h> int check_usage( const char *special, int flag); PARAMETERS Points to a special device file. Specifies the scope of usage check- ing. Valid values are: Checks the usage of the specified partition and all overlapping partitions. Checks the usage of the specified parti- tion only. DESCRIPTION The check_usage function checks whether the special device file is in use, that is, whether it contains a valid file system, is part of LSM, or is being used by a database or for swap space. If the flag OV_CHECK_ALL is set, check_usage() also checks to ensure that the range of blocks to be used does not overlap with blocks al- ready in use or marked to be in use by an overlapping partition. If the flag OV_CHECK_EXACT is set, usage checking is limited to the specified partition only. The check_usage function checks whether the special device file is in use by comparing it with all mounted file systems (both UFS and AdvFS), swap devices, and LSM disks. It also reads the disk label to check the fstype field of the specified partition and any overlapping partitions. If any partition is marked as being in use, the appropriate error is returned. Before allocating a partition, an application should check that none of the overlapping partitions is in use. When an application uses a parti- tion, it should mark its use by setting the fstype field in the parti- tion map in the disk label. See <sys/disklabel.h> for a list of the supported file system types that can be set using the set_usage() function. EXAMPLES The following function illustrates the use of check_usage() and possi- ble error messages that could be printed based on the return values from check_usage(). #define DKTYPENAMES #include <stdio.h> #include <sys/disklabel.h> #in- clude <overlap.h> #define STR_ERR_OPEN \ "Error: %s is open and in use.\n" #define STR_ERR_OPEN_OVERLAP \ "Error: Partition overlapping %s is open and in use.\n" #define STR_ERR_INVALID_DEV \ "Error: %s is an invalid device or cannot be opened.\n" #define STR_ERR_DEFAULT_FSTYPE \ "Error: %s is marked in the disk label as in use by %s.\n" #define STR_WARN_FSTYPE_OVERLAP \ "Warning: partition(s) which overlaps %s are marked in use.\n" #define STR_WARN_MULT_OVERLAP \ "Warning: %s and overlapping partition(s) are marked in use.\n" #define STR_WARN_INVAL_DISKLBL \ "Warning: the disklabel for %s does not exist or is corrupted.\n" int get_usage(char *special) { int ret; /* * Check if the specific partition and any * overlapping partition is in use. */ ret = check_usage(special, OV_CHECK_ALL); if (ret == 0) { /* * Specified partition is available for use. */ return (0); } else { /* * Specified partition has a valid fstype. */ if ( (ret > 0) && (ret <= FSMAXTYPES) ) { fprintf(stderr, STR_ERR_DEFAULT_FSTYPE, special, fstypenames[ret]); return(-1); } } /* * Print appropriate error messages for the rest of * the return values. */ switch (ret) { case OV_ERR_OPEN_OVERLAP: /* * Check if the specified partition is open. */ ret = check_usage(special, OV_CHECK_EXACT); if (ret == OV_ERR_OPEN_OVERLAP) fprintf(stderr, STR_ERR_OPEN, special); else fprintf(stderr, STR_ERR_OPEN_OVERLAP, special); break; case OV_ERR_INVALID_DEV: fprintf(stderr, STR_ERR_INVALID_DEV, special); break; case OV_ERR_INVALID_DSKLBL: fprintf(stderr, STR_WARN_INVAL_DISKLBL, special); break; case OV_ERR_FSTYPE_OVERLAP: fprintf(stderr, STR_WARN_FSTYPE_OVERLAP, special); break; case OV_ERR_MULT_FSTYPE_OVERLAP: fprintf(stderr, STR_WARN_MULT_OVERLAP, special); break; } return (-1); } RETURN VALUES The check_usage function returns the values described here. Logical names for the return values are listed in parentheses. Checks suc- ceeded. The range of blocks is not open or marked for use. Note that for the mount command, you get a warning message if the fstype is set to FS_UNUSED; it should be set to FS_BSDFFS. Either the specified spe- cial device file or an overlapping partition is open or marked for use. Either the special device file name is invalid or the device cannot be opened. Overlapping partitions are marked for use, that is, they have a value set for fstype. Note that the command disklabel -s can be used to unset any partitions that should not be marked for use. The speci- fied partition and overlapping partitions have the fstype field set. The disk label is not present or is corrupted. You should install a disk label and set the fstype field of any partitions that are in use. You should correct any changes to the partition layout before trying to use the newfs command on a partition. An error was encountered during the checks. Either /etc/fdmns or /etc/fdmns/domain for an in-use do- main does not exist or is corrupted. An error was encountered during the checks. The special device file for an in-use swap device does not exist. This indicates a failure in updating the disk label. The spec- ified partition is set to an fstype, which is the return value. Refer to <sys/disklabel.h> for information on valid fstype values. RELATED INFORMATION Commands: disklabel(8) Functions: set_usage(3) delim off check_usage(3)

Navigation Options