aboutsummaryrefslogtreecommitdiff
path: root/sys/ki/kfsubd.x
blob: 93f2d65586a7ee1f22353000c1026625d292769d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	"ki.h"

# KFSUBD -- Compute the net pathname of a subdirectory given the net pathname
# of the parent directory and the name of the subdirectory (the logical
# subdirectory names . and .. are supported).  If the subdirectory resides on
# the local node we call the local kernel to compute the new directory pathname.
# If the directory resides on a remote node we merely append to the virtual
# pathname, leaving resolution of the final pathname to the remote kernel when
# the file is referenced at runtime.

procedure kfsubd (osdir, maxch, subdir, nchars)

char	osdir[maxch]		#RW net pathname of directory
int	maxch			#RO max chars out in osdir string
char	subdir[ARB]		#RO receives pathname
int	nchars			#WO receives length of osfn string

int	delim, op
char	alias[SZ_ALIAS]
int	ki_gnode(), gstrcat()

begin
	if (ki_gnode (osdir, alias, delim) == LOCAL) {
	    # Directory is on the local node.

	    if (osdir[delim+1] == EOS) {
		call zfgcwd (osdir[delim+1], maxch - delim, nchars)
		if (nchars == ERR)
		    return
		call strupk (osdir[delim+1], osdir[delim+1], maxch-delim)
	    }
	    call zfsubd (osdir[delim+1], maxch - delim, subdir, nchars)
	    if (nchars != ERR)
		nchars = nchars + delim

	} else {
	    # File is on a remote node.  Do not map the filename; leave that
	    # to the kernel when the file is referenced at runtime.  The OSDIR
	    # string is assumed to be a concatenatable VFN (with node prefix).

	    op = gstrcat (subdir, osdir, maxch) + 1
	    if (op > 1 && osdir[op-1] != '/') {
		osdir[op] = '/'
		op = op + 1
		osdir[op] = EOS
	    }

	    nchars = op - 1
	}
end