From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/fio/fsymlink.x | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 sys/fio/fsymlink.x (limited to 'sys/fio/fsymlink.x') diff --git a/sys/fio/fsymlink.x b/sys/fio/fsymlink.x new file mode 100644 index 00000000..c742baa7 --- /dev/null +++ b/sys/fio/fsymlink.x @@ -0,0 +1,53 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include + +# FSYMLINK -- Remove a symlink. + +procedure fsymlink (link, target) + +char link[ARB] # link name +char target[ARB] # target file + +int status +pointer sp, oslnk, ostgt, lname, tname +int access() +errchk syserrs + +begin + call smark (sp) + call salloc (lname, SZ_PATHNAME, TY_CHAR) + call salloc (tname, SZ_PATHNAME, TY_CHAR) + call salloc (oslnk, SZ_PATHNAME, TY_CHAR) + call salloc (ostgt, SZ_PATHNAME, TY_CHAR) + + # It is an error if the link file already exists. + if (access (link, 0, 0) == YES) + call syserrs (SYS_FSYMLINK, link) + + # Always present ZFLINK with a full pathname (rather than an + # absolute or cwd relative filename), in case the kernel procedure + # is not smart enough to handle all these possibilities. + call aclrc (Memc[oslnk], SZ_PATHNAME) + iferr (call fmapfn (link, Memc[oslnk], SZ_PATHNAME)) + call syserrs (SYS_FSYMLINK, link) + +# call strupk (Memc[oslnk], Memc[oslnk], SZ_PATHNAME) +# call strpak (Memc[oslnk], Memc[oslnk], SZ_PATHNAME) + + + call aclrc (Memc[ostgt], SZ_PATHNAME) + iferr (call fmapfn (target, Memc[ostgt], SZ_PATHNAME)) + call syserrs (SYS_FSYMLINK, target) + +# call strupk (Memc[ostgt], Memc[ostgt], SZ_PATHNAME) +# call strpak (Memc[ostgt], Memc[ostgt], SZ_PATHNAME) + + # Try to create the symlink. + call zflink (Memc[ostgt], Memc[oslnk], status) + if (status == ERR) + call syserrs (SYS_FSYMLINK, link) + + call sfree (sp) +end -- cgit