.th udm_lib III 4/21/86
.sh FILE
udm_lib.mod
.sh DEFINES
.nf
MODULE udm_lib;
.s3
TYPE pbb_type = (
	userPBB,
	serverPBB);
.s3
TYPE 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);
.s3
TYPE pathOp = (
	po_mkentry,
	po_remove,
	po_locate,
	po_chdir,
	po_exec,
	po_UNIXcreat);
.s3
CONST SIZE_OF_DIR_NAME =	14;
.s3
PROCEDURE set_PBB_type(
	newPBB:			pbb_type);
.s3
PROCEDURE UDM_status:		UDM_error;
.s3
PROCEDURE PBB_invoke(
	pbb_seid:		seid;
	super_image_name:	ARRAY integer OF char;
	super_arg_block:	cardinal;
	super_arg_size:		cardinal
	):			K_err_num;
.s3
PROCEDURE PBB_spawn(
	pbb_seid:		seid;
	super_image_name:	ARRAY integer OF char;
	super_arg_block:	cardinal;
	super_arg_size:		cardinal;
	VAR child:		seid
	):			K_err_num;
.s3
PROCEDURE UDM_mkentry(
	SEID_of_dir:		seid;
	SEID_of_entry:		seid;
	file_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_PBBmkentry(
	PBB_seid:		seid;
	SEID_of_dir:		seid;
	SEID_of_entry:		seid;
	file_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_mkdir(
	SEID_of_Parent_dir:	seid;
	dir_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_mk_tmp_dir(
	SEID_of_Parent_dir:	seid;
	dir_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_rm(
	SEID_of_Parent_Dir:	seid;
	entry_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_PBBrm(
	PBB_seid:		seid;
	SEID_of_Parent_Dir:	seid;
	entry_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_rm_tmp_dir(
	SEID_of_Parent_Dir:	seid;
	entry_name:		ARRAY integer OF char;
	wait_flag:		boolean
	):			UDM_error;
.s3
PROCEDURE UDM_find(
	Starting_Dir_seid:	seid;
	full_path_name:		ARRAY integer OF char;
	operation:		pathOp;
	VAR Parent_Dir_seid:	seid;
	VAR entry_seid:		seid;
	VAR Entry_name:		ARRAY integer Of char
	):			UDM_error;
.s3
PROCEDURE UDM_lookup(
	Starting_Dir_seid:	seid;
	full_path_name:		ARRAY integer OF char;
	VAR entry_seid:		seid
	):			UDM_error;
.s3
PROCEDURE UDM_mount(
	SEID_of_dir:		seid;
	new_fsn:		nsp_type;
	entry_name:		ARRAY integer OF char;
	VAR seid_of_entry:	seid
	):			UDM_error;
.s3
PROCEDURE UDM_unmount(
	SEID_of_dir:		seid;
	entry_name:		ARRAY integer OF char
	):			UDM_error;
.s3
PROCEDURE invoke(
	super_image_name:	ARRAY integer OF char;
	super_arg_block:	cardinal;
	super_arg_size:		cardinal
	):			K_err_num;
.s3
PROCEDURE spawn(
	super_image_name:	ARRAY integer OF char;
	super_arg_block:	cardinal;
	super_arg_size:		cardinal;
	VAR child:		seid
	):			K_err_num;
.fi
.sh "DESCRIPTION"
The procedures defined by udm_lib provide the NKSR processes with
access to the Unix Directory Manager (UDM).  Functions which require no
special privileges are performed directly by the code in udm_lib.
Other functions, such as writing directories and reading execute-only
directories are performed by spawning the UDM process.  Also included
in this module are procedures which provide an interface to the Process
Bootstrap process.
.s3
.lp 10 5
pbb_type
is an enumeration whose values correspond to the two types
of Process Bootstraps.
The argument to set_PBB_type has this type.
.s3
.lp 10 5
UDM_error
is an enumeration type which is returned by many of the
UDM interface procedures.
.s3
.lp 10 5
pathOp
is an enumeration type which is used in conjunction with
the
UDM_find
operation.
Its values correspond to the action for which the
UDM_find
procedure call is the preparation.
.s3
.lp 10 5
set_PBB_type
sets the type, user or server, of the Process Bootstrap that will
be used for subsequent PBB operations.
.s3
.lp 10 5
UDM_status
returns the status received in the IPC message sent back from
the UDM process.
.s3
.lp 10 5
PBB_invoke
executes a process given the executable image file and the seid of the
process bootstrap.
pbb_seid
is the seid of the segment which contains the process bootstrap to be invoked.
super_image_name
is the path name of the file containing the image of the process to be
executed.
super_arg_block
and
super_arg_size
are the address and size, respectively, of the argument block
to be passed to the process ultimately invoked.
.s3
.lp 10 5
PBB_spawn
is like
PBB_invoke,
except that the process is spawned rather than invoked.
The seid of the child process is returned in
child.
.s3
.lp 10 5
UDM_mkentry
spawns the UDM process to make an entry in the directory
whose seid is
SEID_of_dir.
The newly created directory entry has name
file_name
and seid
SEID_of_entry.
If
wait_flag
is true, the procedure returns only after the completion IPC has
been received from the UDM process.
Otherwise, the procedure returns immediately.
.s3
.lp 10 5
UDM_PBBmkentry
is like
UDM_mkentry,
except that the seid of the process bootstrap segment to be used
when spawning the UDM process is specified.
.s3
.lp 10 5
UDM_mkdir
spawns the UDM process in order to create  and initialize a new directory.
A new directory with name
dir_name
is created in the parent directory whose seid is
SEID_of_Parent_dir.
This procedure waits for the completion IPC from the UDM process
if and only if
wait_flag
is true.
.s3
.lp 10 5
UDM_mk_tmp_dir
is like
UDM_mk_dir.
The difference is that
UDM_mk_tmp_dir
must be used to create a user's directory in /tmp.
.s3
.lp 10 5
UDM_rm
is used to remove a directory entry, which can point to a file
or another directory.
SEID_of_Parent_Dir
is the seid of the parent directory,
and
entry_name
is the name of the entry to be removed from it.
If the entry points to a directory and that directory is empty
(except for '.' and '..'),
the directory file is unlinked and the entry removed from the parent
directory.
If the entry points to a plain file, it is unlinked and the entry
removed from the parent directory.
If the entry points to something other than a file, it is simply
removed.
.s3
.lp 10 5
UDM_PBBrm
is like
UDM_rm,
with the addition of the
PBB_seid
parameter, which allows the caller to specify
the seid of the process bootstrap to be used
when spawning the UDM process.
.s3
.lp 10 5
UDM_rm_tmp_dir
is like
UDM_rm,
but must be used when deleting users' directories in /tmp.
.s3
.lp 10 5
UDM_find
serves the dual purpose of performing full path name interpretation for,
and checking the validity of, some subsequent UDM function.
Starting_Dir_seid
is the seid of the directory with which to start the search for
the file whose full or partial path name is in
full_path_name.
If, however,
full_path_name
begins with a slash, the directory search is started at the root directory.
The
operation
parameter determines the value returned by
UDM_find.
Assuming that each component of the path name, except the last, corresponds
to a directory, and each directory is searchable, the following are
the conditions for the successful return value from
UDM_find.
.s3
.lp 20 10
mkentry	The parent directory must be writable and the entry must not exist.
.sp
.lp 20 10
remove	The parent directory must be writable and the entry must exist.
.sp
.lp 20 10
locate	The entry must exist.
.sp
.lp 20 10
chdir	The entry must be a searchable directory.
.sp
.lp 20 10
exec	The entry must correspond to a file that has the
correct discretionary access bit and magic number for execution
(ala UNIX).
.sp
.lp 20 10
create	If the entry exists, then it must be writable.
Otherwise, the parent directory must be writable.
.s3
.lp 10 0
The seid of the parent directory is returned in
Parent_Dir_seid,
the seid of the entry in
entry_seid
(if found),
and the name of the entry in
Entry_name.
.s3
.lp 10 5
UDM_lookup
is used to find the seid corresponding to a path name.
It is equivalent to calling
UDM_find
with the operation
po_locate
specified.
Only the seid of the entry is returned.
.s3
.lp 10 5
UDM_mount
causes the seid portion of the directory entry specified by
SEID_of_dir
and
entry_name
to be rewritten with the name space parameter
new_fsn.
.s3
.lp 10 5
UDM_unmount
causes the seid portion of the directory entry specified by
SEID_of_dir
and
entry_name
to be rewritten with
.it
same_nsp.
.s3
.lp 10 5
invoke
is used to execute (UNIX style) another process, given the path
name of the executable image.
The seid of the current process bootstrap segment
(whatever was last specified by
set_PBB_type)
is looked up.
The arguments are then passed to
PBB_invoke.
.s3
.lp 10 5
spawn
is used to spawn another process, given the path name of the
executable image.
The current process bootstrap segment is looked up, and the
resultant arguments are passed to
PBB_spawn.
The seid of the child process is returned in
child.
.i0
.sh USES
.nf
NKcalls.mod
Nlib.mod
c32Arith.mod
npi.mod        (ipc_on must be defined)
.fi
.sh INCLUDES
.nf
udm.h
udm_comm.mod
.fi
.sh "INCLUDED BY"
.ta 20,40
ACP.mod	ACP_OP.mod	MNT.mod
SIP.mod	SSP.mod	UMT.mod
btcp.mod	dcp.mod	fam.mod
init.mod	lpc.mod	mk_immdb.mod
pce.mod	test_lib.mod	udm_f.mod
.dt
