(*
COPYRIGHT:  1980, by Ford Aerospace and Communications Corp.
ADDRESS:    Ford Aerospace and Communications Corp.
            Western Development Laboratories
            3939 Fabian Way
            Palo Alto, California 94303
            Attention: Software Technology Dept.
            Mail Stop: V02 

CPCI:  NKSR

CPC:   UDM
TAG:   UDM

MODULE NAME:  UDM include file.
	      Include file for UDM (the directory manager) and UDMI (the
	      directory manager interface.

REFERENCES-
  A  Specs:  N/A
  B5 Specs:  N/A
  C5 Specs:  N/A

HISTORY:
  AUTHOR:   Strafford Wentworth
  VERSION:  2.15 of 9/28/80
  MODULE TYPE: 

PRIVILEGES:  
SPECIAL NOTES:  
*)

(*========================================================================*)
(*      DECLARATIONS                                                      *)
(*========================================================================*)

    CONST

	(* Temporary constants *)
	XXOK             = 0;
	not_file         = 10125;       (* XnoFile *)
	end_of_file      = 10108;       (* XendOfFile *)

	self_space       = d_space;
	self_domain      = supervisor_domain;

	SIZE_OF_DIR_NAME  = 14;
	SIZE_OF_DIR_ENTRY = SIZE_OF_DIR_NAME + 4;
	PATH_SIZE         = 512;
	NUMBER_OF_ENTRIES = 28;

#ifdef UDM_TF
	ZDIR_CREATE_MODE   = [ownerRead, ownerWrite, ownerExecute,
			     groupRead, groupWrite, groupExecute,
			     allRead,   allWrite,   allExecute];
#else
	DIR_CREATE_MODE   = [ownerRead, ownerWrite, ownerExecute,
			     groupRead,             groupExecute,
			     allRead,               allExecute];
#endif

	DIR_SUBTYPE       = seid (subtype_nsp, char(100), cardinal(0));
	ROOT              = seid (char(129), char(0), cardinal (5));
	UDM_PATH          = '/sys/sysbin/UDM';
	USER_PBB_PATH     = '/sys/sysbin/userPBB';
	SERVER_PBB_PATH   = '/sys/sysbin/serverPBB';
	UDM_OWNER         = 2;
	UDM_GROUP         = 1;


	EXCLUSIVE_USE_RETRY = 5;
	EXCLUSIVE_USE_RETRY_DELAY = 4;
	STAR_DELAY          = 20;       (* 2 seconds *)


	(* these constants should come from a common event file *)
	UDM_EVENT         = char (26);
	UDM_AUDIT         = char (1);


	(* mode normally used to open directories *)
	NORMAL_OPEN_MODE  = openModes (true, true, false, true);

	(* open mode used for path interpretation *)
	READ_OPEN_MODE    = openModes (true, false, false, false);

	(* open mode for the directory subtype *)
	SUB_OPEN_MODE     = openModes (true, true, false, false);

	(* open descriptor for file subtype *)
	file_sub_od       = null_open_descriptor;


	udm_h_WHAT    = '@(#)udm.h	2.15{0}';
	udm_h_VERSION = '%V%';


    TYPE
	(*
	 * Directory entries are 18 bytes long. This is two bytes
	 * longer than UNIX directory entries.
	 *)
        D_entry =
	    RECORD
		SEID :  seid;
		name :  ARRAY 1:SIZE_OF_DIR_NAME  OF char;
	    END;

	(*
	 * Directories are built to fit on 512 boundaries. The reason for
	 * this restriction is so that path interprets will never read
	 * corrupted information.
	 * This structure for the directory is incorporated into the
	 * dir_buf structure
	 *
	 *      dir_struct =
	 *          RECORD
	 *              dir_entry : ARRAY 1:NUMBER_OF_ENTRIES OF D_entry;
	 *              fill      : ARRAY 1:8  OF char;
	 *          END;
	 *)

	read_flag_vals = (first_read, normal_read, no_read);


	dir_buf =
	    RECORD
		od        : openDescriptor;

		(* These two entries must comprise 512 bytes *)
		dir_entry  : ARRAY 1:28 OF D_entry;
		fill       : ARRAY 1:8  OF char;

		dir_SEID   : seid;
		read_flag  : read_flag_vals;
		last       : integer;
		written    : boolean;
		removed    : boolean;
		block      : fBlockNumber;
	    END;

	(* Error values visable a the top level of the directory manager *)
	UDM_error = (UDM_no_error,
		     UDM_cannot_do,
		     UDM_cannot_link,
		     UDM_cannot_unlink,
		     UDM_entry_exists,
		     UDM_entry_does_not_exist,
		     UDM_cannot_open_directory,
		     UDM_seid_refers_to_a_directory,
		     UDM_cannot_create_directory,
		     UDM_cannot_remove_directory,
		     UDM_directory_not_empty,
		     UDM_not_directory,
		     UDM_directory_not_writable,
		     UDM_not_executable,
		     UDM_no_path,
		     UDM_not_found,
		     UDM_cannot_link_across_file_systems,
		     UDM_cannot_mount,
		     UDM_cannot_unmount,
		     UDM_entry_not_writable);


	pathOp  =   (po_mkentry,
		     po_remove,
		     po_locate,
		     po_chdir,
		     po_exec,
		     po_UNIXcreat);

	permission = (Read, Write, Execute);


	udm_entry_points =
		    (udm_mkentry,
		     udm_mkdir,
		     udm_rm,
		     udm_find,
		     udm_mount,
		     udm_unmount,
		     udm_mk_tmp_dir,
		     udm_rm_tmp_dir);


	pbb_type = (userPBB, serverPBB);



	udm_arg_block =  RECORD
	    udm_procedure  : udm_entry_points;
	    udm_seid1      : seid;
	    udm_seid2      : seid;
	    udm_path_name  : ARRAY 1 : PATH_SIZE OF char;
	    udm_path_op    : pathOp;
	END;


	(* A udm_status_block is returned in an IPC. *)
	udm_status_block = RECORD
	    udm_sender     : seid;          (* Seid of process that sent IPC *)
	    udm_event      : char;
	    udm_junk       : char;
	    udm_parent     : seid;
	    udm_entry      : seid;
	    udm_status     : UDM_error;
	END;




    VAR

	(* set by get_my_tii. Read by excuteOn *)
	process_tii : tii_struct;

	(* The following variables are only used in the UDM *)
	dummy_block    [0] : udm_arg_block;
	Arg_block      [HIGH_MEM_LOC - size (dummy_block)] : udm_arg_block;
	arg_block_size [ARG_SIZE_LOC] : cardinal;
	return_block : udm_status_block;
	My_parent    : seid;
	dummy_name   : ARRAY 1 : SIZE_OF_DIR_NAME OF char;

	    (* mkRm_tmp_dirs controls access to the tmp and users tmp *)
	    (* mk_tmp_dir and rm_tmp_dir it to true so that *)
	    (* the procedure find treat tmp directories as normal dirs *)
	mkRm_tmp_dirs     : boolean;


