check_usage man page on DigitalUNIX

Man page or keyword search:  
man Server   12896 pages
apropos Keyword Search (all sections)
Output format
DigitalUNIX logo
[printable version]

check_usage(3)							check_usage(3)

       check_usage - checks whether a disk partition is in use

       #include <sys/disklabel.h> #include <overlap.h>

       int check_usage(
	       const char *special,
	       int option );

       Filesystem Library (libfilsys.a)

       Shared Filesystem Library (

       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.

       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 option OV_CHECK_ALL is set, check_usage() also checks to	ensure
       that  the  range	 of  blocks  to	 be  used does not overlap with blocks
       already in use or marked to be in use by an overlapping partition.

       If the option 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

       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.

       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 domain
       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.

       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>
       #include <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]);
	    * Print appropriate error messages for the rest of
	    * the return values.
	   switch (ret) {

		* 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);
		   fprintf(stderr, STR_ERR_OPEN_OVERLAP, special);
	       fprintf(stderr, STR_ERR_INVALID_DEV, special);
	       fprintf(stderr, STR_WARN_INVAL_DISKLBL, special);
	       fprintf(stderr, STR_WARN_FSTYPE_OVERLAP, special);
	       fprintf(stderr, STR_WARN_MULT_OVERLAP, special);
	   return (-1); }

       Commands: disklabel(8)

       Functions: set_usage(3)


List of man pages available for DigitalUNIX

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net