DEFINITION MODULE kshPrimitives;

FROM K32baseTypes IMPORT

	bits16, cardinal16, integer16;

FROM K32types IMPORT

	compartSet, seid;

FROM IOform IMPORT

	security;

FROM IOFform IMPORT

	slotNumber;

FROM flio IMPORT

	fileDescriptor;

FROM extio IMPORT

	extentDescriptor;

FROM kshDirs IMPORT

	path;


EXPORT QUALIFIED

	DOPT, LOPT, ROPT, AOPT,	VOPT,
	BLOCKSIZE, BUFSIZE,
	chgrp, chint, chmod, chown, chsec, ls,
	mkdir, mknod, rm, rmall,
	cpkk, cpuk, cpku, copydir, initdir, linkseid,
	makef, pathseid, fileseid, cmpseid,
	wdName,	wdExt, wdJnode;

CONST
	(* OPTIONS for 'ls' *)
	DOPT =		0;	(* directory		*)
	LOPT =		1;	(* long format		*)
	ROPT =		2;	(* resursive list	*)
	AOPT =		3;	(* show '.*' files	*)

	(* OPTIONS for 'rmall' *)
	VOPT =		4;	(* verbose		*)

	BLOCKSIZE =	512;
	BUFSIZE	= 128 (*BLOCKSIZE DIV TSIZE(WORD) *) ;



VAR
	wdName:		path;
	wdExt:		extentDescriptor;
	wdJnode:	slotNumber;


PROCEDURE chown(
	name:		ARRAY OF CHAR;
	newowner:	cardinal16
):	BOOLEAN;

PROCEDURE chgrp(
	name:		ARRAY OF CHAR;
	newgrp:		cardinal16
):	BOOLEAN;

PROCEDURE chmod(
	name:		ARRAY OF CHAR;
	newmode:	 bits16	(* passed as cardinal from Chmod *)
):	BOOLEAN;

PROCEDURE chsec(
	name:		ARRAY OF CHAR;
	newsec:		CHAR
):	BOOLEAN;

PROCEDURE chint(
	name:		ARRAY OF CHAR;
	newint:		CHAR
):	BOOLEAN;

PROCEDURE chcmprt(
	name:		ARRAY OF CHAR;
	newcmprt:		compartSet
):	BOOLEAN;

PROCEDURE ls(
	flname,
	prname:		path;
	opt:		bits16
) ;

PROCEDURE mkdir(
	name:		path
);

PROCEDURE mknod(
	name:		path;
	id:		seid
):			BOOLEAN;


PROCEDURE rm(
	name:		path
):			BOOLEAN;

PROCEDURE rmall(
	name:		path;
	opt:		bits16
) ;

PROCEDURE cpkk(
	VAR f1:                 fileDescriptor;
	VAR f2:                 fileDescriptor);

PROCEDURE cpuk(		(* copy from a UNIX file to a KSOS file *)
	f1:                     integer16;
	VAR f2:                 fileDescriptor);

PROCEDURE cpku(
	VAR f1:                 fileDescriptor;
	f2:                     integer16);

PROCEDURE copydir(
	ex1:                    extentDescriptor;
	dj1:                    slotNumber;
	VAR df1:                fileDescriptor;
	ex2:                    extentDescriptor;
	dj2:                    slotNumber;
	VAR df2:                fileDescriptor) ;

PROCEDURE initdir(
	ex:		extentDescriptor;
	jn:		slotNumber;
	VAR df:		fileDescriptor;
	pj:		slotNumber
):                      BOOLEAN;

PROCEDURE makef(
	name:		path;
	info:		security;
	VAR ex:		extentDescriptor;
	VAR jn:		slotNumber;
	VAR f:		fileDescriptor;
	VAR pj:		slotNumber
):			BOOLEAN;

PROCEDURE linkseid(
	ex:		extentDescriptor;
	id:		seid;
	VAR df:		fileDescriptor;
	name:		ARRAY OF CHAR
):                      BOOLEAN;

PROCEDURE fileseid(
	id:		seid
):			BOOLEAN;

PROCEDURE pathseid(
	name:           ARRAY OF CHAR;
	VAR ex:		extentDescriptor;
	VAR id:		seid
):			BOOLEAN;

PROCEDURE cmpseid(
	seid1,
	seid2:		seid
):			BOOLEAN;


END kshPrimitives.
