mirror of
				git://git.code.sf.net/p/cdesktopenv/code
				synced 2025-03-09 15:50:02 +00:00 
			
		
		
		
	Rebooting 93u+m
This commit reboots ksh 93u+m development with a new fork based off the archived official AT&T ast repo, master branch. README: - Removed. Having two READMEs is a botch. README.md: - Imported and edited from the archived fork, https://github.com/modernish/ksh -- the newer instructions will become applicable as I cherry-pick all the changes from there :) - Copy-edits. - Added policy and rationale for this 93u+m fork. - Incorporated info from old README that is still relevant. .gitignore: - Added. bin/execrate: - Removed. This one keeps changing its license header, causing git to show an uncommitted file. It's always re-copied anyway, and not for direct invocation, so, exclude and add to .gitignore. The source file is: src/cmd/INIT/execrate.sh src/cmd/*, src/lib/*: - Remove historical baggage: everything except ksh93 and dependencies. This is the same stuff the ksh-community fork removed. I wouldn't mind keeping it, but some of this stuff causes build failures on macOS (and probably other systems), and I need to get on with fixing ksh93. Hopefully, we can figure out how to re-add stuff we can use later -- particularly the pty command (pseudo-terminal utility for scripting interactive sessions) which is needed for regression-testing the interactive shell.
This commit is contained in:
		
							parent
							
								
									cc1f2bf81d
								
							
						
					
					
						commit
						2940b3f536
					
				
					 2271 changed files with 93 additions and 1162987 deletions
				
			
		
							
								
								
									
										25
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.gitignore
									
										
									
									
										vendored
									
									
										Normal file
									
								
							|  | @ -0,0 +1,25 @@ | |||
| # Project-specific files | ||||
| = | ||||
| arch | ||||
| tgz | ||||
| lcl | ||||
| 
 | ||||
| # This one keeps changing its license header, causing git to show an | ||||
| # uncommitted file. It's always re-copied anyway, and not for direct | ||||
| # invocation, so exclude. The source file is: src/cmd/INIT/execrate.sh | ||||
| bin/execrate | ||||
| 
 | ||||
| # Miscellaneous artefacts | ||||
| *.bak | ||||
| *.sav | ||||
| *.old | ||||
| *.orig | ||||
| .*.swp | ||||
| *.DS_Store | ||||
| *~ | ||||
| .nfs* | ||||
| *.tmp | ||||
| *.rej | ||||
| *.project | ||||
| *.core | ||||
| core | ||||
							
								
								
									
										29
									
								
								README
									
										
									
									
									
								
							
							
						
						
									
										29
									
								
								README
									
										
									
									
									
								
							|  | @ -1,29 +0,0 @@ | |||
| This is a package root directory $PACKAGEROOT. Source and binary | ||||
| packages in this directory tree are controlled by the command | ||||
| 
 | ||||
| 	bin/package | ||||
| 
 | ||||
| Binary files may be in this directory or in the install root directory | ||||
| 
 | ||||
| 	INSTALLROOT=$PACKAGEROOT/arch/`bin/package` | ||||
| 
 | ||||
| For more information run | ||||
| 
 | ||||
| 	bin/package help | ||||
| 
 | ||||
| Many of the packaged commands self-document via the --man and --html | ||||
| options; those that do have no separate man page. | ||||
| 
 | ||||
| Each package is covered by one of the license files | ||||
| 
 | ||||
| 	lib/package/LICENSES/<license> | ||||
| 
 | ||||
| where <license> is the license type for the package.  At the top | ||||
| of each license file is a URL; the license covers all software that | ||||
| refers to this URL. For details run | ||||
| 
 | ||||
| 	bin/package license [<package>] | ||||
| 
 | ||||
| Any archives, distributions or packages made from source or | ||||
| binaries covered by license(s) must contain the corresponding | ||||
| license file(s). | ||||
							
								
								
									
										92
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										92
									
								
								README.md
									
										
									
									
									
								
							|  | @ -1,36 +1,78 @@ | |||
| # AST | ||||
| # KornShell 93u+m | ||||
| 
 | ||||
| This is the AT&T Software Technology (AST) toolkit from AT&T Research. | ||||
| It includes many tools and libraries, like KSH, NMAKE, SFIO, VMALLOC, VCODEX, | ||||
| etc. It also includes more efficient replacements for a lot of the POSIX tools. | ||||
| It was designed to be portable across many UNIX systems and also works | ||||
| under UWIN on Microsoft Windows (see UWIN repo on GitHub under att/uwin). | ||||
| This repository is used to develop bugfixes | ||||
| to the last stable release (93u+ 2012-08-01) of | ||||
| [ksh93](http://www.kornshell.com/), | ||||
| formerly developed by AT&T Software Technology (AST). | ||||
| The sources in this repository were forked from the | ||||
| Github [AST repository](https://github.com/att/ast) | ||||
| which is no longer under active development. | ||||
| 
 | ||||
| ## ksh93u+ and v- | ||||
| To see what's fixed, see [NEWS](https://github.com/modernish/ast/blame/master/NEWS) | ||||
| and click on commit messages for full details. | ||||
| 
 | ||||
| This repo contains the **ksh93u+** and **ksh93v-** versions of KSH. | ||||
| To see what's left to fix, see [TODO](./TODO). | ||||
| 
 | ||||
| * **ksh93u+**, the master branch, was the last version released by the main AST | ||||
|   authors in 2012, while they were at AT&T. It also has some later build | ||||
|   fixes but it is not actively maintained. | ||||
| * ksh93v-, [ksh93v tag](https://github.com/att/ast/tree/ksh93v), contains | ||||
|   contributions from the main authors through 2014 (after they left) and is | ||||
|   considered less stable | ||||
| ## Policy | ||||
| 
 | ||||
| Please search the web for forks of this repo (or check the | ||||
| [Network graph](https://github.com/att/ast/network) on GitHub) if you are | ||||
| looking for an actively maintained version of ksh. | ||||
| 1. No new features. Bug fixes only. | ||||
| 2. No major rewrites. No refactoring code that is not fully understood. | ||||
| 3. No changes in documented behaviour, except if required for compliance with the | ||||
|    [POSIX shell language standard](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html) | ||||
|    which David Korn [intended](http://www.kornshell.com/info/) for ksh to follow. | ||||
| 4. No 100% bug compatibility. Broken and undocumented behaviour gets fixed. | ||||
| 5. No bureaucracy, no formalities. Just fix it, or report it: create issues, | ||||
|    send pull requests. Every interested party is invited to contribute. | ||||
| 6. To help increase everyone's understanding of this code base, fixes and | ||||
|    significant changes should be fully documented in commit messages. | ||||
| 
 | ||||
| ## Why? | ||||
| 
 | ||||
| Between 2017 and 2020 there was an ultimately unsuccessful | ||||
| [attempt](https://github.com/att/ast/tree/2020.0.1) | ||||
| to breathe new life into the KornShell by extensively refactoring the last | ||||
| unstable AST beta version (93v-). | ||||
| While that ksh2020 branch is now abandoned and still has many critical bugs, | ||||
| it also had a lot of bugs fixed. More importantly, the AST issue tracker | ||||
| now contains a lot of documentation on how to fix those bugs, which makes | ||||
| it possible to backport many of them to the last stable release instead. | ||||
| 
 | ||||
| In February 2020, having concluded the AST 93v- beta was too broken to | ||||
| base new work on, others decided to start a new fork based on the last stable | ||||
| 93u+ 2012-08-01 release. Unfortunately, as of June 2020, the new | ||||
| [ksh-community](https://github.com/ksh-community/ksh/) | ||||
| organisation is yet to see any significant activity four months after its | ||||
| bootstrapping. I hope that will change; I am ready to join efforts with them | ||||
| at any time, as well as anyone else who wants to contribute. | ||||
| 
 | ||||
| The last stable ksh93 release from 2012 is the least buggy release currently | ||||
| available, but it still has many serious bugs. So it is well past time to | ||||
| start fixing those bugs, leave the rest of the code alone, and get an | ||||
| improved release out there. | ||||
| 
 | ||||
| ## Build | ||||
| 
 | ||||
| This software is used to build itself, using NMAKE.  After cloning this repo, cd | ||||
| to the top directory of it and run: | ||||
| 
 | ||||
| After cloning this repo, cd to the top directory of it and run: | ||||
| ```sh | ||||
| ./bin/package make | ||||
| ``` | ||||
| If you have trouble or want to tune the binaries, you may pass additional | ||||
| compiler and linker flags by appending it to the command shown above. E.g.: | ||||
| ```sh | ||||
| ./bin/package make \ | ||||
|     SHELL=/bin/bash CCFLAGS="-xc99 -D_XPG6 -m64 -xO4" LDFLAGS="-m64" | ||||
| ``` | ||||
| For more information run | ||||
| ```sh | ||||
|         bin/package help | ||||
| ``` | ||||
| Many other commands in this repo self-document via the `--help`, `--man` and | ||||
| `--html` options; those that do have no separate manual page. | ||||
| 
 | ||||
| Almost all the tools in this package (including the bin/package script are | ||||
| self-documenting; run <tool> --man (or --html) for the man page for the tool. | ||||
| ## Test | ||||
| 
 | ||||
| (If you were used to the old AST packaging mechanism, on www.research.att.com, | ||||
| this repo is equivalent to downloading the INIT and ast-open packages and | ||||
| running: ./bin/package read on them). | ||||
| After compiling, you can run the regression tests. | ||||
| Start by reading the information printed by: | ||||
| ```sh | ||||
| ./bin/shtests --man | ||||
| ``` | ||||
|  |  | |||
							
								
								
									
										180
									
								
								bin/execrate
									
										
									
									
									
								
							
							
						
						
									
										180
									
								
								bin/execrate
									
										
									
									
									
								
							|  | @ -1,180 +0,0 @@ | |||
| USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 2002-2020 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]" | ||||
| ######################################################################## | ||||
| #                                                                      # | ||||
| #               This software is part of the ast package               # | ||||
| #          Copyright (c) 1994-2011 AT&T Intellectual Property          # | ||||
| #                      and is licensed under the                       # | ||||
| #                 Eclipse Public License, Version 1.0                  # | ||||
| #                    by AT&T Intellectual Property                     # | ||||
| #                                                                      # | ||||
| #                A copy of the License is available at                 # | ||||
| #          http://www.eclipse.org/org/documents/epl-v10.html           # | ||||
| #         (with md5 checksum b35adb5213ca9657e911e9befb180842)         # | ||||
| #                                                                      # | ||||
| #              Information and Software Systems Research               # | ||||
| #                            AT&T Research                             # | ||||
| #                           Florham Park NJ                            # | ||||
| #                                                                      # | ||||
| #                 Glenn Fowler <gsf@research.att.com>                  # | ||||
| #                                                                      # | ||||
| ######################################################################## | ||||
| : wrapper for .exe challenged win32 systems/commands | ||||
| 
 | ||||
| command=execrate | ||||
| 
 | ||||
| bins='/bin /usr/bin /usr/sbin' | ||||
| 
 | ||||
| case `(getopts '[-][123:xyz]' opt --xyz; echo 0$opt) 2>/dev/null` in | ||||
| 0123)	ARGV0="-a $command" | ||||
| 	USAGE=$' | ||||
| [-? | ||||
| @(#)$Id: execrate (AT&T Labs Research) 2002-02-02 $ | ||||
| ] | ||||
| '$USAGE_LICENSE$' | ||||
| [+NAME?execrate - wrapper for .exe challenged commands] | ||||
| [+DESCRIPTION?\bexecrate\b runs \acommand\a after checking the \afile\a | ||||
| 	operands for standard semantics with respect to \bwin32\b \b.exe\b | ||||
| 	suffix conventions. This command is only needed on \bwin32\b | ||||
| 	systems that inconsistently handle \b.exe\b across library and | ||||
| 	command interfaces. \acommand\a may be one of \bcat\b(1), \bchmod\b(1), | ||||
| 	\bcmp\b(1), \bcp\b(1), \bln\b(1), \bmv\b(1), or \brm\b(1). | ||||
| 	Only the 2 argument forms of \bcp\b, \bln\b and \bmv\b are handled. | ||||
| 	Unsupported commands and commands requiring no change are | ||||
| 	silently executed.] | ||||
| [+?With no arguments \bexecrate\b exits with status 0 if the current system | ||||
| 	is \b.exe\b challenged, 1 if the current system is normal.] | ||||
| [n:show?Show the underlying commands but do not execute.] | ||||
| 
 | ||||
| command [ option ... ] file ... | ||||
| 
 | ||||
| [+SEE ALSO?\bwebster\b(1)] | ||||
| ' | ||||
| 	usage() | ||||
| 	{ | ||||
| 		OPTIND=0 | ||||
| 		getopts $ARGV0 "$USAGE" OPT '-?' | ||||
| 		exit 2 | ||||
| 	} | ||||
| 	exec=1 | ||||
| 	while	getopts $ARGV0 "$USAGE" OPT | ||||
| 	do	case $OPT in | ||||
| 		n)	exec=0 ;; | ||||
| 		*)	usage ;; | ||||
| 		esac | ||||
| 	done | ||||
| 	shift `expr $OPTIND - 1` | ||||
| 	;; | ||||
| *)	usage() | ||||
| 	{ | ||||
| 		echo "Usage: execrate [ -n ] [ command [ option ... ] file ... ]" >&2 | ||||
| 		exit 2 | ||||
| 	} | ||||
| 	exec=1 | ||||
| 	while	: | ||||
| 	do	case $1 in | ||||
| 		-n)	exec=0 ;; | ||||
| 		-*)	usage ;; | ||||
| 		*)	break ;; | ||||
| 		esac | ||||
| 		shift | ||||
| 	done | ||||
| 	;; | ||||
| esac | ||||
| case $# in | ||||
| 0)	if	test ! -x /bin/cat.exe | ||||
| 	then	exit 1 # normal | ||||
| 	fi | ||||
| 	if	/bin/cat /bin/cat >/dev/null 2>&1 | ||||
| 	then	exit 1 # normal | ||||
| 	fi | ||||
| 	exit 0 # challenged | ||||
| 	;; | ||||
| 1)	usage | ||||
| 	;; | ||||
| esac | ||||
| case $1 in | ||||
| *cat|*rm) | ||||
| 	NUM=0 | ||||
| 	;; | ||||
| *chgrp|*chmod) | ||||
| 	NUM=1 | ||||
| 	;; | ||||
| *cmp|*cp|*ln|*mv) | ||||
| 	NUM=2 | ||||
| 	;; | ||||
| *)	case $exec in | ||||
| 	0)	echo "$@" ;; | ||||
| 	*)	"$@" ;; | ||||
| 	esac | ||||
| 	exit | ||||
| 	;; | ||||
| esac | ||||
| CMD=$1 | ||||
| shift | ||||
| case $CMD in | ||||
| */*)	;; | ||||
| *)	for d in $bins | ||||
| 	do	if	test -x $d/$1 -o -x $d/$1.exe | ||||
| 		then	CMD=$d/$1 | ||||
| 			break | ||||
| 		fi | ||||
| 	done | ||||
| 	;; | ||||
| esac | ||||
| while	: | ||||
| do	case $1 in | ||||
| 	-*)	CMD="$CMD $1" ;; | ||||
| 	*)	break ;; | ||||
| 	esac | ||||
| 	shift | ||||
| done | ||||
| case $exec in | ||||
| 0)	CMD="echo $CMD" ;; | ||||
| esac | ||||
| case $NUM:$# in | ||||
| *:0)	;; | ||||
| 1:*)	CMD="$CMD $1" | ||||
| 	NUM=0 | ||||
| 	shift | ||||
| 	;; | ||||
| esac | ||||
| case $NUM:$# in | ||||
| 0:*)	status=0 | ||||
| 	for f | ||||
| 	do	if	test "$f" -ef "$f".exe | ||||
| 		then	f=$f.exe | ||||
| 		fi | ||||
| 		$CMD "$f" | ||||
| 		case $? in | ||||
| 		0)	;; | ||||
| 		*)	status=$? ;; | ||||
| 		esac | ||||
| 	done | ||||
| 	exit $status | ||||
| 	;; | ||||
| 2:2)	f=$1 | ||||
| 	case $f in | ||||
| 	*.exe)	;; | ||||
| 	*)	if	test "$f" -ef "$f".exe | ||||
| 		then	f=$f.exe | ||||
| 		fi | ||||
| 		;; | ||||
| 	esac | ||||
| 	case $f in | ||||
| 	*.exe)	if	test -d "$2" | ||||
| 		then	t=$2/$f | ||||
| 		else	t=$2 | ||||
| 		fi | ||||
| 		case $t in | ||||
| 		*/*)	b=`basename "$t"` ;; | ||||
| 		*)	b=$t ;; | ||||
| 		esac | ||||
| 		case $b in | ||||
| 		*.*)	$CMD "$f" "$t"; exit ;; | ||||
| 		*)	$CMD "$f" "$t".exe; exit ;; | ||||
| 		esac | ||||
| 		;; | ||||
| 	esac | ||||
| 	;; | ||||
| esac | ||||
| $CMD "$@" | ||||
|  | @ -1,4 +1,4 @@ | |||
| USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2020 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]" | ||||
| USAGE_LICENSE="[-author?Glenn Fowler <gsf@research.att.com>][-copyright?Copyright (c) 1994-2012 AT&T Intellectual Property][-license?http://www.eclipse.org/org/documents/epl-v10.html]" | ||||
| ######################################################################## | ||||
| #                                                                      # | ||||
| #               This software is part of the ast package               # | ||||
|  |  | |||
							
								
								
									
										609
									
								
								src/cmd/3d/3d.h
									
										
									
									
									
								
							
							
						
						
									
										609
									
								
								src/cmd/3d/3d.h
									
										
									
									
									
								
							|  | @ -1,609 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * Glenn Fowler | ||||
|  * David Korn | ||||
|  * Eduardo Krell | ||||
|  * | ||||
|  * AT&T Research | ||||
|  * | ||||
|  * 3d file system implementation interface | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _3D_H | ||||
| #define _3D_H | ||||
| 
 | ||||
| #undef	_BLD_DEBUG | ||||
| 
 | ||||
| #define _def_map_ast	1 | ||||
| #define _std_strtol	1 | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide fchown ftruncate mount readlink sbrk strmode truncate utimes __utimes | ||||
| #else | ||||
| #undef	fchown | ||||
| #define fchown		______fchown | ||||
| #undef	ftruncate | ||||
| #define ftruncate	______ftruncate | ||||
| #undef	mount | ||||
| #define mount		______mount | ||||
| #undef	readlink | ||||
| #define readlink	______readlink | ||||
| #undef	sbrk | ||||
| #define sbrk		______sbrk | ||||
| #undef	strmode | ||||
| #define strmode		______strmode | ||||
| #undef	truncate | ||||
| #define truncate	______truncate | ||||
| #undef	utimes | ||||
| #define utimes		______utimes | ||||
| #undef	__utimes | ||||
| #define __utimes	________utimes | ||||
| #endif | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__note) | ||||
| __STDPP__directive pragma pp:note off64_t | ||||
| #endif | ||||
| 
 | ||||
| #include <ast_std.h> | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide strmode | ||||
| #else | ||||
| #undef	strmode | ||||
| #endif | ||||
| 
 | ||||
| #include "lib_3d.h" | ||||
| 
 | ||||
| #include <ls.h> | ||||
| #include <sig.h> | ||||
| #include <times.h> | ||||
| #include <error.h> | ||||
| #include <debug.h> | ||||
| #include <hashkey.h> | ||||
| #include <dlldefs.h> | ||||
| 
 | ||||
| #if _lib_strerror && defined(strerror) | ||||
| #undef	strerror | ||||
| extern char*		strerror(); | ||||
| #endif | ||||
| 
 | ||||
| #undef	mount | ||||
| #define mount		______mount | ||||
| #include <fs3d.h> | ||||
| #undef	mount | ||||
| 
 | ||||
| #include "msg.h" | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide fchown ftruncate mount readlink sbrk strmode truncate utimes __utimes | ||||
| #else | ||||
| #undef	fchown | ||||
| #undef	ftruncate | ||||
| #undef	mount | ||||
| #undef	readlink | ||||
| #undef	sbrk | ||||
| #undef	strmode | ||||
| #undef	truncate | ||||
| #undef	utimes | ||||
| #undef	__utimes | ||||
| #endif | ||||
| 
 | ||||
| #if FS && defined(MIX) | ||||
| #define LICENSED	1 | ||||
| #endif | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__note) | ||||
| #if !_typ_off64_t && !noticed(off64_t) | ||||
| #undef	off64_t | ||||
| #if _typ_int64_t | ||||
| #define off64_t		int64_t | ||||
| #else | ||||
| #define off64_t		long | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| struct stat64; | ||||
| 
 | ||||
| #undef	fcntl | ||||
| #undef	open | ||||
| #undef	stat | ||||
| #undef	strtol | ||||
| #undef	strtoul | ||||
| #undef	strtoll | ||||
| #undef	strtoull | ||||
| 
 | ||||
| #define MSG_read3d	(MSG_read|MSG_EXT(MSG_ARG_number,4)) | ||||
| #define MSG_write3d	(MSG_write|MSG_EXT(MSG_ARG_number,4)) | ||||
| 
 | ||||
| struct Fs; | ||||
| 
 | ||||
| typedef long (*Sysfunc_t)(); | ||||
| 
 | ||||
| typedef int (*Fs_get_t)(struct Fs*, char*, const char*, int); | ||||
| 
 | ||||
| typedef int (*Fs_set_t)(struct Fs*, const char*, int, const char*, int); | ||||
| 
 | ||||
| #define _3D_LINK_MAX	999		/* for nice ls -l */ | ||||
| 
 | ||||
| #ifndef _3D_LINK_MAX | ||||
| #ifdef LINK_MAX | ||||
| #define _3D_LINK_MAX	LINK_MAX | ||||
| #else | ||||
| #define _3D_LINK_MAX	30000 | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #define ATTR_MAX	121 | ||||
| 
 | ||||
| #include "FEATURE/peek" | ||||
| #include "FEATURE/syscall" | ||||
| #include "FEATURE/syslib" | ||||
| 
 | ||||
| typedef struct Fs | ||||
| { | ||||
| 	long		flags; | ||||
| 	short		fd; | ||||
| 	short		retry; | ||||
| 	short		specialsize; | ||||
| 	Fs_get_t	get; | ||||
| 	Fs_set_t	set; | ||||
| 	unsigned long	key; | ||||
| 	unsigned long	ack; | ||||
| 	unsigned long	call; | ||||
| 	unsigned long	terse; | ||||
| 	char		special[10]; | ||||
| 	char		attr[ATTR_MAX]; | ||||
| 	struct stat	st; | ||||
| 	char*		match; | ||||
| 	char*		service; | ||||
| 	short		matchsize; | ||||
| 	short		servicesize; | ||||
| } Fs_t; | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| typedef struct Mount | ||||
| { | ||||
| 	long		channel; | ||||
| 	Fs_t*		fs; | ||||
| 	struct Mount*	global; | ||||
| 	char*		logical; | ||||
| 	char*		physical; | ||||
| 	char		attr[ATTR_MAX]; | ||||
| 	short		logicalsize; | ||||
| 	short		physicalsize; | ||||
| 	short		flags; | ||||
| } Mount_t; | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	dev_t		dev; | ||||
| 	ino_t		ino; | ||||
| 	char		path[1]; | ||||
| } Dir_t; | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mount; | ||||
| 	Dir_t*		dir; | ||||
| #endif | ||||
| 	short*		reserved; | ||||
| 	Msg_file_t	id; | ||||
| 	unsigned long	open; | ||||
| 	unsigned char	flags; | ||||
| 	unsigned char	oflag; | ||||
| } File_t; | ||||
| 
 | ||||
| #if VCS | ||||
| #include "vcs_3d.h" | ||||
| #endif | ||||
| 
 | ||||
| #define NOSYS		nosys | ||||
| 
 | ||||
| #define TABLE_FD	(OPEN_MAX>22?22:(OPEN_MAX-1))	/* 0 for env	*/ | ||||
| #define TABLE_MAX	(1<<(TABBITS+7))/* max 3d table image size	*/ | ||||
| #define TABLE_PREFIX	"vpath "	/* for external consistency	*/ | ||||
| #define TABLE_VERSION	1		/* to verify TABLE_FD		*/ | ||||
| 
 | ||||
| #define TABBITS		5	/* max vpath,vmap table index bits (<6)	*/ | ||||
| #define TABSIZE		(1<<TABBITS)			/* v* tab size	*/ | ||||
| #define	VERMODE		(S_IRWXU|S_IRWXG|S_IRWXO)	/* ver dir mode	*/ | ||||
| #define INSTANCE	TABSIZE				/* under ver	*/ | ||||
| 
 | ||||
| #define INTERCEPT_MAX	8		/* max # call intercept layers	*/ | ||||
| 
 | ||||
| #define LICENSE_ALL	'+'		/* everything licensed		*/ | ||||
| #define LICENSE_NONE	'-'		/* nothing licensed		*/ | ||||
| #define LICENSE_SEP	','		/* feature separator		*/ | ||||
| 
 | ||||
| /*
 | ||||
|  * File_t flags | ||||
|  */ | ||||
| 
 | ||||
| #define RESERVED_FD	10		/* reserved fds >= this		*/ | ||||
| 
 | ||||
| #define FILE_CLOEXEC	(1<<0) | ||||
| #define FILE_ERROR	(1<<1) | ||||
| #define FILE_LOCK	(1<<2) | ||||
| #define FILE_OPEN	(1<<3) | ||||
| #define FILE_REGULAR	(1<<4) | ||||
| #define FILE_WRITE	(1<<5) | ||||
| #define FILE_VIRTUAL	(1<<6) | ||||
| 
 | ||||
| #define FILE_LOCAL	(1<<8) | ||||
| 
 | ||||
| /*
 | ||||
|  * map flags | ||||
|  */ | ||||
| 
 | ||||
| #define MAP_EXEC	(1<<0)		/* get info for exec		*/ | ||||
| #define MAP_INIT	(1<<1)		/* get info for init		*/ | ||||
| 
 | ||||
| /*
 | ||||
|  * Mount_t flags | ||||
|  */ | ||||
| 
 | ||||
| #define MOUNT_PRIMARY	(1<<0) | ||||
| 
 | ||||
| /*
 | ||||
|  * pathreal() flags | ||||
|  */ | ||||
| 
 | ||||
| #define P_ABSOLUTE	(1<<0)		/* no relative conversion	*/ | ||||
| #define P_DOTDOT	(1<<1)		/* add /.. to end of path	*/ | ||||
| #define P_LSTAT		(1<<2)		/* lstat() calling		*/ | ||||
| #define P_NOOPAQUE	(1<<3)		/* remove if opaque object	*/ | ||||
| #define P_NOSLASH	(1<<4)		/* remove trailing /'s		*/ | ||||
| #define P_PATHONLY	(1<<5)		/* just canonicalize path	*/ | ||||
| #define P_READLINK	(1<<6)		/* readlink() calling		*/ | ||||
| #define P_SAFE		(1<<7)		/* must be in safe tree		*/ | ||||
| #define P_SLASH		(1<<8)		/* add trailing /		*/ | ||||
| #define P_TOP		(1<<9)		/* copy to top level		*/ | ||||
| 
 | ||||
| #ifndef ENOTEMPTY | ||||
| #define ENOTEMPTY	EEXIST | ||||
| #endif | ||||
| 
 | ||||
| #define T_ALLOCATE	(1<<15) | ||||
| #define T_PREFIX	(1<<14) | ||||
| #define T_DELETE	(T_ALLOCATE|T_PREFIX) | ||||
| #define T_SIZE		(T_PREFIX-1) | ||||
| 
 | ||||
| #define T_VALSIZE(p)	(((p)->valsize&T_SIZE)?((p)->valsize&T_SIZE):strlen((p)->val)) | ||||
| 
 | ||||
| #define T_MOUNT		(T_SIZE-0) | ||||
| 
 | ||||
| #define FS_null		0 | ||||
| #define FS_option	1 | ||||
| #define FS_view		2 | ||||
| #define FS_pwd		3 | ||||
| #define FS_fs		4 | ||||
| #define FS_map		5 | ||||
| #define FS_safe		6 | ||||
| #define FS_fd		7 | ||||
| #define FS_intercept	8 | ||||
| 
 | ||||
| #define FS_ACTIVE	(1<<0) | ||||
| #define FS_BOUND	(1<<1) | ||||
| #define FS_CLOSE	(1<<2) | ||||
| #define FS_ERROR	(1<<3) | ||||
| #define FS_FLUSH	(1<<4) | ||||
| #define FS_FORK		(1<<5) | ||||
| #define FS_FS		(1<<6) | ||||
| #define FS_GLOBAL	(1<<7) | ||||
| #define FS_INIT		(1<<8) | ||||
| #define FS_INTERACTIVE	(1<<9) | ||||
| #define FS_INTERNAL	(1<<10) | ||||
| #define FS_LICENSED	(1<<11) | ||||
| #define FS_LOAD		(1<<12) | ||||
| #define FS_LOCK		(1<<13) | ||||
| #define FS_MAGIC	(1<<14) | ||||
| #define FS_MONITOR	(1L<<15) | ||||
| #define FS_NAME		(1L<<16) | ||||
| #define FS_ON		(1L<<17) | ||||
| #define FS_OPEN		(1L<<18) | ||||
| #define FS_RAW		(1L<<19) | ||||
| #define FS_RECEIVE	(1L<<20) | ||||
| #define FS_REFERENCED	(1L<<21) | ||||
| #define FS_REGULAR	(1L<<22) | ||||
| #define FS_UNIQUE	(1L<<23) | ||||
| #define FS_VALIDATED	(1L<<24) | ||||
| #define FS_WRITE	(1L<<25) | ||||
| 
 | ||||
| #define FS_LOCAL	(1L<<26) | ||||
| 
 | ||||
| #define cancel(p)	(*(p)>=RESERVED_FD?(state.file[*(p)].reserved=0,CLOSE(*(p)),*(p)=0):(-1)) | ||||
| #define fsfd(p)		((((p)->flags&(FS_ERROR|FS_ON|FS_OPEN))==(FS_ON|FS_OPEN))?(p)->fd:((((p)->flags&(FS_BOUND|FS_ERROR|FS_INIT|FS_ON))==(FS_BOUND|FS_ON))?fsinit(p,-1):-1)) | ||||
| #define fson(p)		(((p)->flags&(FS_BOUND|FS_ERROR|FS_ON))==(FS_BOUND|FS_ON)) | ||||
| #define initialize()	do { if (!state.pid) init(0,0,0); else if (state.control.note) control(); } while(0) | ||||
| #define monitored()	((state.path.monitor&&!state.path.mount)?state.path.monitor:(Mount_t*)0) | ||||
| #define mounted()	((state.path.monitor&&state.path.mount)?state.path.monitor:(Mount_t*)0) | ||||
| #if _hdr_alloca | ||||
| #define reclaim() | ||||
| #else | ||||
| #define reclaim()	do { if (state.brk.beg) fix(); } while (0) | ||||
| #endif | ||||
| #define reserve(p)	((state.file[*(p)].flags|=FILE_LOCK,*(state.file[*(p)].reserved=(p)))<RESERVED_FD?close(*(p)):0) | ||||
| 
 | ||||
| #if FS | ||||
| #define fgetmount(f)	((f)>=0&&(f)<=state.cache?state.file[f].mount:(Mount_t*)0) | ||||
| #define fsmonitored(p)	((state.path.monitor=getmount((p),NiL))&&(state.path.monitor->fs->flags&(FS_ERROR|FS_MONITOR|FS_ON))==(FS_MONITOR|FS_ON)) | ||||
| #define fsmount(p)	(((p)->channel&&(p)->fs->fd)?((p)->channel==-1?-1:(p)->fs->fd):fschannel(p)) | ||||
| #define fssys(p,c)	(fson((p)->fs)&&(((p)->fs->call&MSG_MASK(c))||((p)->fs->flags&FS_GLOBAL)&&(fsmount(p),0))) | ||||
| #endif | ||||
| 
 | ||||
| #define var_3d		"__=" | ||||
| #define var_pwd		"PWD=" | ||||
| #define var_shell	"SHELL=" | ||||
| #define var_view	"VPATH=" | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	char*		key; | ||||
| 	char*		val; | ||||
| 	unsigned short	keysize; | ||||
| 	unsigned short	valsize; | ||||
| } Map_t; | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	unsigned int	size; | ||||
| 	Map_t		table[TABSIZE]; | ||||
| } Table_t; | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	int		level; | ||||
| 	int		open_level; | ||||
| 	int		synthesize; | ||||
| 	int		nlinks; | ||||
| 	char*		linkname; | ||||
| 	int		linksize; | ||||
| #if FS | ||||
| 	Mount_t*	monitor; | ||||
| #endif | ||||
| 	char*		mount; | ||||
| 	Table_t*	table; | ||||
| #if VCS && defined(VCS_PATH_STATE) | ||||
| 	VCS_PATH_STATE; | ||||
| #endif | ||||
| 	struct stat	st; | ||||
| 	char		name[4 * PATH_MAX]; | ||||
| } Path_t; | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	Fs_t*		fs; | ||||
| 	char*		prefix; | ||||
| 	int		prelen; | ||||
| } Visit_t; | ||||
| 
 | ||||
| struct Intercept_s; typedef struct Intercept_s Intercept_t; | ||||
| 
 | ||||
| typedef long (*Intercept_f)(Intercept_t*, int, int, void*, void*, void*, void*, void*, void*); | ||||
| 
 | ||||
| struct Intercept_s | ||||
| { | ||||
| 	Intercept_f		call; | ||||
| 	unsigned long		mask; | ||||
| }; | ||||
| 
 | ||||
| #if _no_exit_exit | ||||
| typedef void (*Exitfunc_t)(int); | ||||
| #endif | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	/* the first elements are explicitly initialized */ | ||||
| 
 | ||||
| 	const char*	id; | ||||
| 	char*		cmd; | ||||
| 	char		dot[2]; | ||||
| 	char		null[1]; | ||||
| 	char		one[2]; | ||||
| 	char*		binsh; | ||||
| 	char		env3d[sizeof(var_3d)]; | ||||
| 	char		envpwd[sizeof(var_pwd) + 4 * PATH_MAX]; | ||||
| 	char		envshell[sizeof(var_shell) + PATH_MAX]; | ||||
| 	char		envview[sizeof(var_view)]; | ||||
| 	Fs_t		fs[TABSIZE]; | ||||
| 	char		vdefault[8]; | ||||
| 	char		opaque[8]; | ||||
| 	int		limit; | ||||
| 
 | ||||
| 	/* the rest are implicitly initialized */ | ||||
| 
 | ||||
| 	struct | ||||
| 	{ | ||||
| 	short		monitor; | ||||
| 	short		name; | ||||
| 	}		call; | ||||
| 	struct | ||||
| 	{ | ||||
| 	short		fd; | ||||
| 	unsigned long	internal; | ||||
| 	}		channel; | ||||
| 	struct | ||||
| 	{ | ||||
| 	int		note; | ||||
| 	int		pathsize; | ||||
| 	char*		path; | ||||
| 	}		control; | ||||
| #if VCS && defined(VCS_STATE) | ||||
| 	VCS_STATE; | ||||
| #endif | ||||
| 	int		boundary; | ||||
| 	struct | ||||
| 	{ | ||||
| 	char*		beg; | ||||
| 	char*		end; | ||||
| 	}		brk; | ||||
| 	int		cache; | ||||
| 	char**		env; | ||||
| 	char*		envpath; | ||||
| 	void*		freedirp; | ||||
| 	int		in_2d; | ||||
| 	gid_t		gid; | ||||
| 	int		kernel; | ||||
| 	int		level; | ||||
| 	char		license[64]; | ||||
| 	int		open; | ||||
| 	pid_t		pid; | ||||
| 	char*		pwd; | ||||
| 	int		pwdsize; | ||||
| 	char		pwdbuf[4 * PATH_MAX + 1]; | ||||
| 	long		ret; | ||||
| 	Fs_t*		safe; | ||||
| 	char*		shell; | ||||
| 	uid_t		uid; | ||||
| 	struct | ||||
| 	{ | ||||
| 	char*		value; | ||||
| 	char*		invert; | ||||
| 	char*		next; | ||||
| 	int		valsize; | ||||
| 	int		invertsize; | ||||
| 	}		key; | ||||
| 	struct | ||||
| 	{ | ||||
| 	short		fd; | ||||
| 	short		version; | ||||
| 	int		size; | ||||
| 	char		buf[TABLE_MAX]; | ||||
| 	}		table; | ||||
| 	unsigned long	test; | ||||
| 	struct | ||||
| 	{ | ||||
| 	unsigned long	call; | ||||
| 	short		count; | ||||
| 	pid_t		pid; | ||||
| 	}		trace; | ||||
| 	Table_t		vmap; | ||||
| 	Table_t		vmount; | ||||
| 	Table_t		vpath; | ||||
| 	Table_t		vsafe; | ||||
| 	Table_t		vintercept; | ||||
| 	File_t		file[OPEN_MAX]; | ||||
| 	Visit_t		visit; | ||||
| 	Path_t		path; | ||||
| 	int		real; | ||||
| 	struct | ||||
| 	{ | ||||
| 	int		size; | ||||
| 	Intercept_t	intercept[INTERCEPT_MAX]; | ||||
| 	}		trap; | ||||
| #if _no_exit_exit | ||||
| 	Exitfunc_t	libexit; | ||||
| #endif | ||||
| #if FS | ||||
| 	Mount_t*	global; | ||||
| 	Mount_t		mount[2 * TABSIZE]; | ||||
| #endif | ||||
| } State_t; | ||||
| 
 | ||||
| #include "std_3d.h" | ||||
| 
 | ||||
| extern State_t		state; | ||||
| 
 | ||||
| extern int		bprintf(char**, char*, const char*, ...); | ||||
| extern ssize_t		bvprintf(char**, char*, const char*, va_list); | ||||
| extern void		calldump(char**, char*); | ||||
| extern void		callinit(void); | ||||
| extern int		checklink(const char*, struct stat*, int); | ||||
| extern void		control(void); | ||||
| extern int		fs3d_copy(int, int, struct stat*); | ||||
| extern int		fs3d_dup(int, int); | ||||
| extern int		fs3d_mkdir(const char*, mode_t); | ||||
| extern int		fs3d_open(const char*, int, mode_t); | ||||
| extern void		fsdrop(Fs_t*, int); | ||||
| extern int		fsinit(Fs_t*, int); | ||||
| extern unsigned long	getkey(const char*, const char*, int); | ||||
| extern int		init(int, const char*, int); | ||||
| extern int		instance(char*, char*, struct stat*, int); | ||||
| extern int		iterate(Table_t*, int(*)(Map_t*, char*, int), char*, int); | ||||
| extern int		keep(const char*, size_t, int); | ||||
| extern int		mapdump(Table_t*, char*, int); | ||||
| extern int		mapget(Map_t*, char*, int); | ||||
| extern int		mapinit(const char*, int); | ||||
| extern int		mapset(Table_t*, const char*, int, const char*, int); | ||||
| extern int		nosys(void); | ||||
| extern char*		pathcanon(char*, size_t, int); | ||||
| extern char*		pathcat(const char*, int, const char*, const char*, char*, size_t); | ||||
| extern char*		pathreal(const char*, int, struct stat*); | ||||
| extern ssize_t		peek(int, void*, size_t); | ||||
| extern Map_t*		search(Table_t*, const char*, int, const char*, int); | ||||
| extern Sysfunc_t	sysfunc(int); | ||||
| extern int		intercept(Intercept_f, unsigned long); | ||||
| 
 | ||||
| #if FS | ||||
| extern int		fileinit(int, struct stat*, Mount_t*, int); | ||||
| extern int		fscall(Mount_t*, long, int, ...); | ||||
| extern int		fschannel(Mount_t*); | ||||
| extern char*		fsreal(Mount_t*, long, const char*); | ||||
| extern int		getattr(const char*, char*); | ||||
| extern Mount_t*		getmount(const char*, const char**); | ||||
| extern const char*	setattr(char*, const char*, const char*); | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * non-standard standards | ||||
|  */ | ||||
| 
 | ||||
| #if ! _UWIN | ||||
| extern void*		sbrk(ssize_t); | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * backwards compatibility fixups | ||||
|  * these should go away in 94 (ha!) | ||||
|  */ | ||||
| 
 | ||||
| #if _int_st_spare1 | ||||
| #define NIVIEW(p,v)	((p)->st_spare1=(v)) | ||||
| #else | ||||
| #if _ary_st_spare4 | ||||
| #define NIVIEW(p,v)	((p)->st_spare4[0]=(v)) | ||||
| #else | ||||
| #if _ary_st_pad4 | ||||
| #define NIVIEW(p,v)	((p)->st_pad4[0]=(v)) | ||||
| #else | ||||
| #define NIVIEW(p,v) | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #undef	IVIEW | ||||
| 
 | ||||
| #if _mem_st_rdev_stat | ||||
| #define IVIEW(p,v)	do{NIVIEW(p,(v)&(INSTANCE-1));if(!S_ISBLK((p)->st_mode)&&!S_ISCHR((p)->st_mode))(p)->st_rdev=(v)&(INSTANCE-1);}while(0) | ||||
| #else | ||||
| #define IVIEW(p,v)	NIVIEW(p,(v)&(INSTANCE-1)) | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										376
									
								
								src/cmd/3d/3d.sh
									
										
									
									
									
								
							
							
						
						
									
										376
									
								
								src/cmd/3d/3d.sh
									
										
									
									
									
								
							|  | @ -1,376 +0,0 @@ | |||
| ######################################################################## | ||||
| #                                                                      # | ||||
| #               This software is part of the ast package               # | ||||
| #          Copyright (c) 1989-2011 AT&T Intellectual Property          # | ||||
| #                      and is licensed under the                       # | ||||
| #                 Eclipse Public License, Version 1.0                  # | ||||
| #                    by AT&T Intellectual Property                     # | ||||
| #                                                                      # | ||||
| #                A copy of the License is available at                 # | ||||
| #          http://www.eclipse.org/org/documents/epl-v10.html           # | ||||
| #         (with md5 checksum b35adb5213ca9657e911e9befb180842)         # | ||||
| #                                                                      # | ||||
| #              Information and Software Systems Research               # | ||||
| #                            AT&T Research                             # | ||||
| #                           Florham Park NJ                            # | ||||
| #                                                                      # | ||||
| #                 Glenn Fowler <gsf@research.att.com>                  # | ||||
| #                  David Korn <dgk@research.att.com>                   # | ||||
| #                   Eduardo Krell <ekrell@adexus.cl>                   # | ||||
| #                                                                      # | ||||
| ######################################################################## | ||||
| # NOTE: retain this comment | ||||
| dir=$_ # NOTE: this line must appear before any commands | ||||
| 
 | ||||
| command=3d | ||||
| 
 | ||||
| case $RANDOM in | ||||
| $RANDOM)exec ksh 3d "$@" ;; | ||||
| esac | ||||
| 
 | ||||
| case $(getopts '[-][123:xyz]' opt --xyz 2>/dev/null; echo 0$opt) in | ||||
| 0123)	ARGV0="-a $command" | ||||
| 	USAGE=$' | ||||
| [-? | ||||
| @(#)$Id: 3d (AT&T Labs Research) 2006-10-01 $ | ||||
| ] | ||||
| '$USAGE_LICENSE$' | ||||
| [+NAME?3d - execute a command with nDFS filesystem services enabled] | ||||
| [+DESCRIPTION?\b3d\b executes a dynamically linked \acommand\a | ||||
| 	with \an\a\bDFS\b filesystem services enabled. It intercepts pathname | ||||
| 	system calls and applies the \an\a\bDFS\b operations specified | ||||
| 	by the \bVPATH\b environment variable, the command line mounts, | ||||
| 	and the \bvpath\b command. If \acommand\a is omitted then an | ||||
| 	interactive \bsh\b(1) is started. All processes executed by \acommand\a | ||||
| 	also have \an\a\bDFS\b enabled.] | ||||
| [+?The main \b3d\b service is \aviewpathing\a. A \aviewpath\a mounts one | ||||
| 	directory tree on top of another. Files in the top level | ||||
| 	(directory tree) obscure files in the lower level. Lower level files | ||||
| 	have copy-on-write semantics to the top level. i.e., files in the lower | ||||
| 	level are readonly; if a lower level file is modified it is first | ||||
| 	copied to the top level before modification. Viewpath mounted | ||||
| 	directories can be chained. All levels but the top in a chain are | ||||
| 	readonly. The traditional \bVPATH=\b\ad1:d2:d3\a viewpathing is | ||||
| 	specified by the two \b3d\b mounts "\ad1 d2\a" and "\ad2 d3\a".] | ||||
| [+?The following service mounts are initialized by default:]{ | ||||
| 	[+/dev/fd?\b/dev/fd/\b\an\a refers to the open file descriptor \an\a | ||||
| 		in the current process.] | ||||
| 	[+/dev/fdp?\b/dev/fdp/local/\aservice\a opens a 2-way stream to | ||||
| 		\aservice\a on the local host. The stream supports file | ||||
| 		descriptor exchange.] | ||||
| 	[+/dev/tcp?\b/dev/tcp/\b\ahost\a\b/\b\aservice\a opens a 2-way | ||||
| 		connection to \aservice\a on \ahost\a. \binetd\b(8) services | ||||
| 		are named either by \binet.\b\aservice\a or by port number.] | ||||
| 	[+/dev/udp?\b/dev/udb/\b\ahost\a\b/\b\aservice\a opens a datagram | ||||
| 		connection to \aservice\a on \ahost\a. \binetd\b(8) services | ||||
| 		are named either by \binet.\b\aservice\a or by port number.] | ||||
| } | ||||
| [c:command?Ignored; allows \b3d\b to be invoked like \bsh\b(1).] | ||||
| [d:debug?Set the debug trace level to \alevel\a. Higher levels produce more | ||||
| 	output.]#[level] | ||||
| [l:lite?Disable the default service mounts.] | ||||
| [m:mount?Mount the path \atop\a onto the path \abottom\a. If \abottom\a is a | ||||
| 	directory then the directory \atop\a is viewpathed on top of \abottom\a. | ||||
| 	Otherwise \abottom\a must match a \b3d\b \bfs\b path of the form | ||||
| 	\b/#\b\aspecial\a.]:["top bottom"] | ||||
| [n!:exec?Execute \acommand\a. \b--noexec\b shows how \acommand\a would be | ||||
| 	invoked but does not execute.] | ||||
| [o:output?\b--trace\b and \b--debug\b output is written to \afile\a instead | ||||
| 	of the standard error.]:[file] | ||||
| [s:shell?Sets the \bsh\b(1) executable path to \afile\a.]:[file:=ksh] | ||||
| [t:trace?If \aid\a is \b1\b then intercepted system calls for all child | ||||
| 	processes will be traced. If \aid\a is greater than \b1\b then | ||||
| 	intercepted system calls for the current process and all | ||||
| 	children will be traced.]#[id] | ||||
| [v:version?Use \b3d\b version \amajor.minor\a instead of the latest | ||||
| 	version.]:[major.minor] | ||||
| [x:?Passed to the \b3d\b \bsh\b(1).] | ||||
| [+FS PATHS?\b3d\b \bfs\b paths of the form \b/#\b\aspecial\a[\b/\b...]] | ||||
| 	control the semantics of \b3d\b and allow services to be attached to | ||||
| 	the file namespace. Unsupported \bfs\b paths are silently ignored. The | ||||
| 	supported \bfs\b paths are:]{ | ||||
| 	[+/#fd? ] | ||||
| 	[+/#fs/\aname\a[/\aoption\a/...]]? ] | ||||
| 	[+/#map? ] | ||||
| 	[+/#null? ] | ||||
| 	[+/#option? ]{ | ||||
| 		[+2d? ] | ||||
| 		[+3d? ] | ||||
| 		[+boundary? ] | ||||
| 		[+call=\avalue\a? ] | ||||
| 		[+count=\avalue\a? ] | ||||
| 		[+debug=\alevel\a? ] | ||||
| 		[+dump=\b[\avalue\a]]? ]{ | ||||
| 			[+call=\avalue\a? ] | ||||
| 			[+file=\avalue\a? ] | ||||
| 			[+fs=\avalue\a? ] | ||||
| 			[+map=\avalue\a? ] | ||||
| 			[+mount=\avalue\a? ] | ||||
| 			[+safe=\avalue\a? ] | ||||
| 			[+state=\avalue\a? ] | ||||
| 			[+view=\avalue\a? ] | ||||
| 		} | ||||
| 		[+file=\avalue\a? ] | ||||
| 		[+fork? ] | ||||
| 		[+init? ] | ||||
| 		[+license=\apath\a? ] | ||||
| 		[+mount=\avalue\a? ] | ||||
| 		[+table=\avalue\a? ] | ||||
| 		[+test=\abitmask\a? ] | ||||
| 		[+timeout=\avalue\a? ] | ||||
| 		[+timestamp? ] | ||||
| 		[+trace=\avalue\a? ] | ||||
| 		[+version=1? ] | ||||
| 	} | ||||
| 	[+/#pwd? ] | ||||
| 	[+/#safe? ] | ||||
| 	[+/#view? ] | ||||
| } | ||||
| [+DETAILS?\an\a\bDFS\b semantics are applied by intercepting system calls with | ||||
| 	a dll that is preloaded at process startup before \amain\a() is called. | ||||
| 	The interception mechanism may involve the environment on some systems; | ||||
| 	in those cases commands like \benv\b(1) that clear the enviroment | ||||
| 	before execution may defeat the \b3d\b intercepts. The intercepted | ||||
| 	system calls are listed by \bvpath - /#option/dump=call\b. Note that | ||||
| 	implementation system call names may differ from those listed in | ||||
| 	section 2 of the manual; \bstat\b(2) is especially vulnerbale to | ||||
| 	mangling.] | ||||
| [+?\b3d\b ignores calls not present in a particular host system. In addition, | ||||
| 	\b3d\b only works on dynamically linked executables that have neither | ||||
| 	set-uid nor set-gid permissions. It may not have the intended effect | ||||
| 	on programs written in a language or linked with a language runtime | ||||
| 	that hides or mangles system call library symbols, or that | ||||
| 	directly emit system call instruction sequences rather than using | ||||
| 	the corresponding library functions, or that dynamically link | ||||
| 	libraries outside of the scope of the \b3d\b intercepts.] | ||||
| [+?Multi-process client-server applications may misbehave if the \b3d\b | ||||
| 	environment between the related processes is not kept in sync.] | ||||
| 
 | ||||
| [ command [ arg ... ] ] | ||||
| 
 | ||||
| [+ENVIRONMENT?\b3d\b is implemented by four components: the \b3d\b script, | ||||
| 	located on \b$PATH\b; the \b3d\b dll (shared library), located either | ||||
| 	on \b$PATH\b or in one of the \b../lib\b* directories on \b$PATH\b, | ||||
| 	depending on local compilation system conventions; and the \b2d\b | ||||
| 	\bsh\b(1) alias and \b_2d\b \bsh\b(1) function that allow commands | ||||
| 	to be run with \an\a\bDFS\b semantics disabled. Systems like | ||||
| 	\bsgi.mips3\b that support multiple a.out formats may have multiple | ||||
| 	versions of the \b3d\b dll. In all cases the \b3d\b script handles | ||||
| 	the dll search.] | ||||
| [+EXAMPLES?]{ | ||||
| 	[+\b$ 3d] | ||||
| 	[+\b$ VPATH=$INSTALLROOT::$PACKAGEROOT 3d] | ||||
| 	[+\b$ 3d ls -l] | ||||
| 	[+\b$ 2d ls -l] | ||||
| } | ||||
| [+SEE ALSO?\benv\b(1), \bie\b(1), \bsh\b(1), \btrace\b(1), \bwarp\b(1), | ||||
| 	\bstat\b(2)] | ||||
| ' | ||||
| 	;; | ||||
| *)	ARGV0="" | ||||
| 	USAGE='clnxd:m:o:s:t:v:[ command [ arg ... ] ]' | ||||
| 	;; | ||||
| esac | ||||
| 
 | ||||
| test . -ef "$PWD" || PWD=`pwd` | ||||
| case $dir in | ||||
| */3d)	;; | ||||
| *)	case $0 in | ||||
| 	*/*)	dir=$0 | ||||
| 		;; | ||||
| 	*)	dir=`whence 3d 2>/dev/null` | ||||
| 		dir=`whence -p $dir 2>/dev/null` | ||||
| 		;; | ||||
| 	esac | ||||
| esac | ||||
| case $dir in | ||||
| /*)	dir=${dir%/*} ;; | ||||
| *)	dir=${dir#./}; dir=$PWD/${dir%/*} ;; | ||||
| esac | ||||
| abi= | ||||
| dir=${dir%/*} | ||||
| case $dir in | ||||
| */arch/sgi.mips[0123456789]*) | ||||
| 	if	test -d /lib32 -o -d /lib64 | ||||
| 	then	d=${dir%-*} | ||||
| 		d=${d%?} | ||||
| 		for a in 2: 3:N32 4:64 | ||||
| 		do	t=${a#*:} | ||||
| 			a=${a%:*} | ||||
| 			if	test -d $d$a | ||||
| 			then	abi="$abi $d$a:$t" | ||||
| 			fi | ||||
| 		done | ||||
| 	fi | ||||
| 	;; | ||||
| esac | ||||
| cflag= | ||||
| full="/dev/fdp/local/nam/user /#fs/nam/name/unique /dev/fdp /#nam /dev/tcp /#nam /dev/udp /#nam /dev/fd /#fd" | ||||
| mount="- -" | ||||
| options= | ||||
| output= | ||||
| show= | ||||
| shell=$SHELL | ||||
| trace= | ||||
| SHELL= | ||||
| version= | ||||
| case $VPATH in | ||||
| *:*)	ifs=${IFS-' | ||||
| 	 '} | ||||
| 	IFS=: | ||||
| 	o= | ||||
| 	for a in $VPATH | ||||
| 	do	case $a in | ||||
| 		""|-)	;; | ||||
| 		*)	case $o in | ||||
| 			""|-)	;; | ||||
| 			*)	mount="$mount $o $a" ;; | ||||
| 			esac | ||||
| 			;; | ||||
| 		esac | ||||
| 		o=$a | ||||
| 	done | ||||
| 	IFS=$ifs | ||||
| 	;; | ||||
| esac | ||||
| 
 | ||||
| : grab the options | ||||
| 
 | ||||
| while	getopts $ARGV0 "$USAGE" OPT | ||||
| do	case $OPT in | ||||
| 	c)	cflag=1; break ;; | ||||
| 	d)	trace="$trace/debug=$OPTARG" ;; | ||||
| 	l)	full= ;; | ||||
| 	m)	mount="$mount $OPTARG" ;; | ||||
| 	n)	show="print -u2 --" ;; | ||||
| 	o)	output=$OPTARG ;; | ||||
| 	s)	SHELL=$OPTARG ;; | ||||
| 	t)	trace="$trace/trace=$OPTARG" ;; | ||||
| 	v)	case $OPTARG in | ||||
| 		/*)	version=$OPTARG ;; | ||||
| 		*)	version=.$OPTARG ;; | ||||
| 		esac | ||||
| 		;; | ||||
| 	x)	options="$options -$OPT" ;; | ||||
| 	*)	exit 2 ;; | ||||
| 	esac | ||||
| done | ||||
| set x "$@" | ||||
| shift $OPTIND | ||||
| case $cflag in | ||||
| 1)	set -- -c "$@" ;; | ||||
| esac | ||||
| 
 | ||||
| case $full in | ||||
| ?*)	mount="$full $mount" ;; | ||||
| esac | ||||
| mount="- /#option/3d$trace $mount" | ||||
| case $output in | ||||
| ?*)	mount="$output /#fs/option $mount" ;; | ||||
| esac | ||||
| default=$version | ||||
| case $version in | ||||
| /*)	;; | ||||
| *)	if	getconf LIBPREFIX >/dev/null 2>&1 | ||||
| 	then	d=$(getconf LIBPATH) | ||||
| 		d=${d##*,} | ||||
| 		d=${d%%:*} | ||||
| 		p=$(getconf LIBPREFIX) | ||||
| 		s=$(getconf LIBSUFFIX) | ||||
| 	else	d=lib | ||||
| 		p=lib | ||||
| 		s='.s[lo]' | ||||
| 	fi | ||||
| 	for x in $dir/$d/${p}3d${s}$version $dir/$d/${p}3d${version//./}${s} | ||||
| 	do	case $x in | ||||
| 		*/${p}3d${s}*[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*|*/${p}3d$*[abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]*${s}) | ||||
| 			;; | ||||
| 		*)	version=$x | ||||
| 			break | ||||
| 			;; | ||||
| 		esac | ||||
| 	done | ||||
| 	;; | ||||
| esac | ||||
| exp= | ||||
| if	test -f "$version" | ||||
| then	if	test -d $dir/3d | ||||
| 	then	dir=$dir/3d | ||||
| 	fi | ||||
| 	case :$FPATH: in | ||||
| 	*:$dir/fun:*)	;; | ||||
| 	*)		export FPATH=$dir/fun${FPATH:+:$FPATH} ;; | ||||
| 	esac | ||||
| 	case :$PATH: in | ||||
| 	*:$dir/bin:*)	;; | ||||
| 	*)		export PATH=$dir/bin:$PATH ;; | ||||
| 	esac | ||||
| 	exp="$exp LD_PRELOAD=$version" | ||||
| 	case $abi:-:$version in | ||||
| 	?*:-:$dir/*) | ||||
| 		v=${version#$dir/} | ||||
| 		for a in $abi | ||||
| 		do	d=${a%:*} | ||||
| 			a=${a#*:} | ||||
| 			exp="$exp _RLD${a}_LIST=$d/$v:DEFAULT" | ||||
| 		done | ||||
| 		;; | ||||
| 	*)	v=${version%.*} | ||||
| 		s=${version##*.} | ||||
| 		if	test -f ${v}-n32.$s | ||||
| 		then	exp="$exp _RLD64_LIST=$version:DEFAULT _RLDN32_LIST=$version-n32.$s:DEFAULT _RLD_LIST=${v}-o32.$s:DEFAULT" | ||||
| 		elif	test -f ${v}-64.$s -o -f ${v}-o32.$s | ||||
| 		then	exp="$exp _RLD64_LIST=$version-64.$s:DEFAULT _RLDN32_LIST=$version:DEFAULT _RLD_LIST=${v}-o32.$s:DEFAULT" | ||||
| 		else	exp="$exp _RLD_LIST=$version:DEFAULT" | ||||
| 		fi | ||||
| 		if	test -f ${dir}/lib/libdir64.$s | ||||
| 		then	exp="$exp:${dir}/lib/libdir64.$s" | ||||
| 		fi | ||||
| 		;; | ||||
| 	esac | ||||
| 	export $exp | ||||
| 	case $mount in | ||||
| 	??*)	export __=${mount#' '} ;; | ||||
| 	*)	unset __ ;; | ||||
| 	esac | ||||
| 	unset VPATH | ||||
| else	print -u2 "$command: $version: no shared library" | ||||
| 	case $default in | ||||
| 	"*")	;; | ||||
| 	*)	exit 1 ;; | ||||
| 	esac | ||||
| 	version= | ||||
| 	options= | ||||
| fi | ||||
| case $SHELL in | ||||
| "")	t=`whence ksh 2>/dev/null` | ||||
| 	SHELL=`PATH=$dir/bin:$PATH whence -p $t 2>/dev/null` | ||||
| 	;; | ||||
| esac | ||||
| SHELL=${SHELL:-$shell} | ||||
| SHELL=${SHELL:-/bin/sh} | ||||
| export SHELL | ||||
| case `vpath /#option/3d 2>/dev/null` in | ||||
| */2d)	$show vpath $mount ;; | ||||
| esac | ||||
| case $1:$#:$options in | ||||
| -*)	;; | ||||
| *:0:*|*:*:?*) | ||||
| 	shell="$SHELL $options" | ||||
| 	;; | ||||
| *)	t=`whence $1 2>/dev/null` | ||||
| 	t=`whence -p $t 2>/dev/null` | ||||
| 	case $t in | ||||
| 	""|"''"|'""')	shell="$SHELL $options" ;; | ||||
| 	*)		shell= ;; | ||||
| 	esac | ||||
| 	;; | ||||
| esac | ||||
| case $show in | ||||
| "")	exec $shell "$@" ;; | ||||
| *)	case $version in | ||||
| 	"")	$show __="'$__'" exec $shell "$@" ;; | ||||
| 	*)	$show __="'$__'" $exp exec $shell "$@" ;; | ||||
| 	esac | ||||
| 	;; | ||||
| esac | ||||
|  | @ -1,350 +0,0 @@ | |||
| : 3d regression tests | ||||
| # | ||||
| # 3d.tst (AT&T Research) 2004-07-01 | ||||
| # | ||||
| # the first section defines the test harness | ||||
| # the next section defines individual test functions | ||||
| # the tests are in the last section | ||||
| # | ||||
| 
 | ||||
| ( vpath ) >/dev/null 2>&1 || { | ||||
| 	print -u2 $0: must be run from 3d shell | ||||
| 	exit 1 | ||||
| } | ||||
| 
 | ||||
| export LC_ALL=C | ||||
| 
 | ||||
| integer seconds=0 | ||||
| 
 | ||||
| COMMAND=3d | ||||
| 
 | ||||
| FILE= | ||||
| FORMAT="%K" | ||||
| GROUP= | ||||
| INIT= | ||||
| NEW="new-and-improved" | ||||
| NUKE= | ||||
| OLD="original" | ||||
| pwd=$PWD | ||||
| PREFIX= | ||||
| STAMP="2005-07-17+04:05:06" | ||||
| VIRTUAL= | ||||
| 
 | ||||
| TWD | ||||
| 
 | ||||
| function ACTIVE | ||||
| { | ||||
| 	DO return 0 | ||||
| } | ||||
| 
 | ||||
| function TEST | ||||
| { | ||||
| 	case $INIT in | ||||
| 	"")	INIT=1 | ||||
| 		mkdir -p $TWD/bottom || exit 1 | ||||
| 		cd $TWD | ||||
| 		INTRO | ||||
| 		;; | ||||
| 	esac | ||||
| 	cd $TWD | ||||
| 	case $NUKE in | ||||
| 	?*)	rm -rf $NUKE; NUKE= ;; | ||||
| 	esac | ||||
| 	PREFIX= | ||||
| 	GROUP=$1 | ||||
| 	ACTIVE || return 1 | ||||
| 	vpath - - | ||||
| 	shift | ||||
| 	print "$GROUP	$*" | ||||
| } | ||||
| 
 | ||||
| function FAIL # file message | ||||
| { | ||||
| 	print -u2 "	FAIL $@" | ||||
| 	rm -rf $1 | ||||
| 	(( ERRORS++ )) | ||||
| 	return 0 | ||||
| } | ||||
| 
 | ||||
| function VERIFY # command ... | ||||
| { | ||||
| 	(( TESTS++ )) | ||||
| 	"$@" || FAIL "$@" | ||||
| } | ||||
| 
 | ||||
| function PREFIX | ||||
| { | ||||
| 	PREFIX=$1 | ||||
| 	case $1 in | ||||
| 	/*)	NUKE="$NUKE $1" ;; | ||||
| 	*)	NUKE="$NUKE $PWD/$1" ;; | ||||
| 	esac | ||||
| } | ||||
| 
 | ||||
| function VIRTUAL | ||||
| { | ||||
| 	case $VIRTUAL in | ||||
| 	?*)	pwd=$PWD | ||||
| 		cd $TWD | ||||
| 		rm -rf $TWD/$VIRTUAL | ||||
| 		cd $pwd | ||||
| 		;; | ||||
| 	esac | ||||
| 	VIRTUAL=$1 | ||||
| } | ||||
| 
 | ||||
| function CD | ||||
| { | ||||
| 	VERIFY cd $TWD/$1 | ||||
| } | ||||
| 
 | ||||
| function VPATH | ||||
| { | ||||
| 	VERIFY vpath "$@" | ||||
| } | ||||
| 
 | ||||
| function CP | ||||
| { | ||||
| 	VERIFY cp "$@" | ||||
| 	shift $#-1 | ||||
| 	NUKE="$NUKE $1" | ||||
| } | ||||
| 
 | ||||
| function LN | ||||
| { | ||||
| 	VERIFY ln "$@" | ||||
| 	shift $#-1 | ||||
| 	NUKE="$NUKE $1" | ||||
| } | ||||
| 
 | ||||
| function MV | ||||
| { | ||||
| 	VERIFY mv "$@" | ||||
| 	shift $#-1 | ||||
| 	NUKE="$NUKE $1" | ||||
| } | ||||
| 
 | ||||
| function MKDIR | ||||
| { | ||||
| 	VERIFY mkdir -p $* | ||||
| 	for i | ||||
| 	do	case $i in | ||||
| 		/*)	NUKE="$NUKE $i" ;; | ||||
| 		*)	NUKE="$NUKE $i" ;; | ||||
| 		esac | ||||
| 	done | ||||
| } | ||||
| 
 | ||||
| function DATA | ||||
| { | ||||
| 	VIRTUAL $VIRTUAL | ||||
| 	case $1 in | ||||
| 	-)	remove=1; shift ;; | ||||
| 	*)	remove=0 ;; | ||||
| 	esac | ||||
| 	case $# in | ||||
| 	0)	return 0 ;; | ||||
| 	1)	;; | ||||
| 	*)	return 1 ;; | ||||
| 	esac | ||||
| 	path=$1 | ||||
| 	case $PREFIX in | ||||
| 	"")	FILE=$path ;; | ||||
| 	*)	FILE=$PREFIX/$path ;; | ||||
| 	esac | ||||
| 	file=bottom/$path | ||||
| 	if	[[ ! -f $TWD/$file ]] | ||||
| 	then	case $remove in | ||||
| 		0)	if	[[ $path == */* && ! -d $TWD/${file%/*} ]] | ||||
| 			then	mkdir -p $TWD/${file%/*} || FAIL $TWD/${file%/*} DATA mkdir | ||||
| 			fi | ||||
| 			print $OLD > $TWD/$file | ||||
| 			mode=${file%???} | ||||
| 			mode=${file#$mode} | ||||
| 			chmod $mode $TWD/$file || FAIL $TWD/$file DATA chmod | ||||
| 			;; | ||||
| 		esac | ||||
| 	else	case $remove in | ||||
| 		1)	rm -f $TWD/$file ;; | ||||
| 		esac | ||||
| 	fi | ||||
| 	(( TESTS++ )) | ||||
| 	return 0 | ||||
| } | ||||
| 
 | ||||
| # | ||||
| # the remaining functions implement individiual parameterized tests | ||||
| # | ||||
| 
 | ||||
| function APPEND | ||||
| { | ||||
| 	DATA $* | ||||
| 	print "$NEW" >> $FILE || FAIL $FILE write error | ||||
| 	if	[[ $(<$FILE) != "$OLD"$'\n'"$NEW" ]] | ||||
| 	then	FAIL $FILE unchanged by $0 | ||||
| 	elif	[[ -f $FILE/... && $(<$FILE/...) != "$OLD" ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| function MODE | ||||
| { | ||||
| 	DATA $* | ||||
| 	chmod 000 $FILE || FAIL $FILE chmod error | ||||
| 	if	[[ -f $FILE/... && ! -r $FILE/... ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	elif	[[ -r $FILE ]] | ||||
| 	then	FAIL $FILE unchanged by $0 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| function REMOVE | ||||
| { | ||||
| 	DATA $* | ||||
| 	rm $FILE || FAIL $FILE rm error | ||||
| 	if	[[ ! -f $FILE/... ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	fi | ||||
| 	print "$NEW" > $FILE || FAIL $FILE write error | ||||
| 	rm $FILE || FAIL $FILE rm error | ||||
| 	if	[[ $(<$FILE) != "$OLD" ]] | ||||
| 	then	FAIL $FILE unchanged by $0 | ||||
| 	elif	[[ $(<$FILE/...) != "$OLD" ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| function TOUCH | ||||
| { | ||||
| 	DATA $* | ||||
| 	touch -t "#$((seconds++))" $FILE/... || FAIL $FILE/... touch error | ||||
| 	touch -t "#$((seconds++))" $TWD/reference || FAIL $TWD/reference touch error | ||||
| 	touch -t "#$((seconds++))" $FILE || FAIL $FILE touch error | ||||
| 	if	[[ $FILE/... -nt $TWD/reference ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	elif	[[ ! $FILE -nt $TWD/reference ]] | ||||
| 	then	FAIL $FILE unchanged by $0 | ||||
| 	fi | ||||
| 	touch -t $STAMP $FILE | ||||
| 	if	[[ $(date -m -f $FORMAT $FILE) != "$STAMP" ]] | ||||
| 	then	FAIL $FILE modfiy time does not match $STAMP | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| function UPDATE | ||||
| { | ||||
| 	DATA $* | ||||
| 	print "$NEW" 1<> $FILE || FAIL $FILE write error | ||||
| 	if	[[ $(<$FILE) != "$NEW" ]] | ||||
| 	then	FAIL $FILE unchanged by $0 | ||||
| 	elif	[[ -f $FILE/... && $(<$FILE/...) != "$OLD" ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| function WRITE | ||||
| { | ||||
| 	DATA $* | ||||
| 	print "$NEW" > $FILE || FAIL $FILE write error | ||||
| 	if	[[ $(<$FILE) != "$NEW" ]] | ||||
| 	then	FAIL $FILE unchanged by $0 | ||||
| 	elif	[[ -f $FILE/... && $(<$FILE/...) != "$OLD" ]] | ||||
| 	then	FAIL $FILE/... changed by $0 | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| function RUN | ||||
| { | ||||
| 	[[ $1 == 3d ]] || return | ||||
| 	DATA | ||||
| 	WRITE	w666 | ||||
| 	WRITE	w600 | ||||
| 	TOUCH	t777 | ||||
| 	MODE	m444 | ||||
| 	WRITE	dir/w666 | ||||
| 	WRITE	dir/w600 | ||||
| 	TOUCH	dir/t777 | ||||
| 	MODE	dir/m444 | ||||
| 	UPDATE	u644 | ||||
| 	UPDATE	u640 | ||||
| 	APPEND	a644 | ||||
| 	APPEND	a640 | ||||
| 	UPDATE	dir/u644 | ||||
| 	UPDATE	dir/u640 | ||||
| 	APPEND	dir/a644 | ||||
| 	APPEND	dir/a640 | ||||
| 	VIRTUAL | ||||
| 	REMOVE	r644 | ||||
| 	WRITE	r644 | ||||
| 	REMOVE	r644 | ||||
| } | ||||
| 
 | ||||
| # | ||||
| # finally the tests | ||||
| # | ||||
| 
 | ||||
| TEST 01 PWD==top top exists && | ||||
| { | ||||
| 	VPATH top bottom | ||||
| 	MKDIR top | ||||
| 	CD top | ||||
| 	RUN 3d | ||||
| } | ||||
| 
 | ||||
| TEST 02 PWD!=top top exists && | ||||
| { | ||||
| 	VPATH top bottom | ||||
| 	MKDIR top | ||||
| 	MKDIR junk | ||||
| 	CD junk | ||||
| 	PREFIX ../top | ||||
| 	RUN 3d | ||||
| } | ||||
| 
 | ||||
| TEST 03 PWD==top top virtual && | ||||
| { | ||||
| 	VIRTUAL top | ||||
| 	VPATH top bottom | ||||
| 	CD top | ||||
| 	RUN 3d | ||||
| } | ||||
| 
 | ||||
| TEST 04 PWD!=top top virtual && | ||||
| { | ||||
| 	VIRTUAL top | ||||
| 	VPATH top bottom | ||||
| 	MKDIR junk | ||||
| 	CD junk | ||||
| 	PREFIX ../top | ||||
| 	RUN 3d | ||||
| } | ||||
| 
 | ||||
| TEST 05 top symlink && | ||||
| { | ||||
| 	if	LN -s text link | ||||
| 	then	[[ -L link ]] || FAIL lstat does stat | ||||
| 	fi | ||||
| } | ||||
| 
 | ||||
| TEST 06 symlink spaghetti && | ||||
| { | ||||
| 	MKDIR usr/bin sbin | ||||
| 	echo : > sbin/cmd && chmod +x sbin/cmd | ||||
| 	LN -s usr/bin bin | ||||
| 	LN -s ../../sbin/cmd usr/bin/cmd | ||||
| 	CD bin | ||||
| 	PATH=:$PATH cmd | ||||
| } | ||||
| 
 | ||||
| TEST 07 PWD==top top exists, bot virtual && | ||||
| { | ||||
| 	VPATH top bot | ||||
| 	MKDIR top | ||||
| 	CD top | ||||
| 	echo foo > foo && echo bar > bar | ||||
| 	CP foo ... | ||||
| 	MV bar ... | ||||
| 	CP foo ... | ||||
| 	[[ -d ... ]] && FAIL ... is a directory && return | ||||
| 	[[ $(cat foo 2>/dev/null) != foo ]] && FAIL top garbled -- $(cat foo 2>&1) | ||||
| } | ||||
|  | @ -1,110 +0,0 @@ | |||
| if CC.HOSTTYPE == "no_build" | ||||
| /* | ||||
|  * 3d fs library | ||||
|  * | ||||
|  * NOTE: ld -r does not work with $(CC.DLL) so lib3d.o is not possible | ||||
|  *       (unless we compile it in one file -- no thanks) | ||||
|  *	 so a static link needs -u _exit -l3d other-libs | ||||
|  */ | ||||
| 
 | ||||
| :PACKAGE: ast:nolibrary | ||||
| 
 | ||||
| LICENSE = since=1989,author=gsf+dgk+ekrell | ||||
| 
 | ||||
| ID = 3d | ||||
| VERSION = 4.0 | ||||
| CATALOG = 3d | ||||
| 
 | ||||
| CCFLAGS = -O $(CC.DLL) /* NOTE: gcc $(CC.OPTIMIZE) fails here! */ | ||||
| IFFEREFS = -last | ||||
| TMP = 3.$(tmp) | ||||
| 
 | ||||
| DEBUG == 1 | ||||
| DEBUG_TABLE == 0 | ||||
| FS == 1 | ||||
| IDNAME == "$(ID)" | ||||
| PATHCHECK == "$(ID)" | ||||
| MIX == | ||||
| VCS == 1 | ||||
| 
 | ||||
| if LITE | ||||
| DEBUG = 0 | ||||
| DEBUG_TABLE = 0 | ||||
| FS = 0 | ||||
| VCS = 0 | ||||
| end | ||||
| 
 | ||||
| $(ID)$(VARIANTID) $(VERSION) id=$(ID) :LIBRARY: README RELEASE PROMO.mm \ | ||||
| 	3d.h lib_3d.h dir_3d.h \
 | ||||
| 	init.c \
 | ||||
| 	bio.c copy.c error.c execv.c fs.c lib.c map.c \
 | ||||
| 	pathcanon.c pathnext.c pathreal.c peek.c \
 | ||||
| 	ast.c cs.c license.c \
 | ||||
| 	vcs_3d.h vcs.c \
 | ||||
| 	access3d.c brk3d.c chdir3d.c chmod3d.c chown3d.c close3d.c \
 | ||||
| 	creat3d.c dir3d.c dup23d.c dup3d.c execve3d.c exit3d.c \
 | ||||
| 	fchdir3d.c fchmod3d.c fchown3d.c fcntl3d.c fork3d.c fpathconf3d.c \
 | ||||
| 	fstat3d.c fstatfs3d.c fstatvfs3d.c fsync3d.c \
 | ||||
| 	ftruncate3d.c getdents3d.c kill3d.c link3d.c lseek3d.c \
 | ||||
| 	lstat3d.c mkdir3d.c mknod3d.c mount3d.c open3d.c pathconf3d.c \
 | ||||
| 	pipe3d.c read3d.c readlink3d.c rename3d.c rmdir3d.c sbrk3d.c \
 | ||||
| 	stat3d.c statfs3d.c statvfs3d.c symlink3d.c syscall3d.c \
 | ||||
| 	sysent3d.c truncate3d.c unlink3d.c utime3d.c utimes3d.c utimets3d.c \
 | ||||
| 	vfork3d.c write3d.c \
 | ||||
| 	acl3d.c facl3d.c \
 | ||||
| 	dll3d.c \
 | ||||
| 	utimensat3d.c \
 | ||||
| 	-ldl | ||||
| 
 | ||||
| if ! VARIANTID | ||||
| 
 | ||||
| 3d :: 3d.sh | ||||
| 
 | ||||
| opaque :: opaque.sh | ||||
| 
 | ||||
| vex :: vex.sh | ||||
| 
 | ||||
| $(FUNDIR) :INSTALLDIR: mode=+x _2d | ||||
| 
 | ||||
| end | ||||
| 
 | ||||
| :VARIANT: | ||||
| 
 | ||||
| /* | ||||
|  * -l<library> :lib: <subdir> ... | ||||
|  * | ||||
|  * snarf src from <library> and its <subdir>s | ||||
|  */ | ||||
| 
 | ||||
| NAME3D = lib_3d.h std_3d.h vcs_3d.h | ||||
| 
 | ||||
| ":lib:" : .MAKE .OPERATOR | ||||
| 	local L | ||||
| 	L := $(<:/-l//) | ||||
| 	eval | ||||
| 	_BLD_$(L) == 1 | ||||
| 	end | ||||
| 	:: $(L)_3d.h | ||||
| 	NAME3D += $(L)_3d.h | ||||
| 	L := ../../$(VARIANTID:?../)lib/lib$(L) | ||||
| 	.SOURCE.c : $(L:X=. $(>)) | ||||
| 	.SOURCE.features/% : $(L) | ||||
| 
 | ||||
| -last :lib: comp dir hash misc path port string tm | ||||
| 
 | ||||
| -lcs :lib: | ||||
| 
 | ||||
| -ldll :lib: | ||||
| 
 | ||||
| terminal FEATURE/eaccess FEATURE/hack | ||||
| 
 | ||||
| 3d :TEST: 3d.tst | ||||
| 	$(BINDIR)/3d $(SHELL) $(REGRESS) $(REGRESSFLAGS) $(*) | ||||
| 
 | ||||
| :: sys.tab | ||||
| 
 | ||||
| else | ||||
| 
 | ||||
| :NOTHING: | ||||
| 
 | ||||
| end | ||||
							
								
								
									
										1326
									
								
								src/cmd/3d/Mamfile
									
										
									
									
									
								
							
							
						
						
									
										1326
									
								
								src/cmd/3d/Mamfile
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -1,106 +0,0 @@ | |||
| .H 1 3d | ||||
| .B 3d | ||||
| is the historical name for | ||||
| .IB n DFS , | ||||
| the multiple dimension file system. | ||||
| It is implemented as a shared library that is preloaded | ||||
| before any other shared library using the recently documented | ||||
| .RI ( ahem ) | ||||
| .B LD_PRELOAD | ||||
| or | ||||
| .B _RLD_LIST | ||||
| feature of the runtime linker. | ||||
| .B 3d | ||||
| intercepts pathname system calls (and other calls if tracing is | ||||
| turned on) and provides a logical namespace on top of the underlying | ||||
| physical file system. | ||||
| The shared library implementation currently works | ||||
| only on | ||||
| .IR bsd.i386 , | ||||
| .IR linux.i386 , | ||||
| .IR osf.alpha , | ||||
| .IR sun4 , | ||||
| .IR sol.* , | ||||
| and | ||||
| .IR sgi.* . | ||||
| .P | ||||
| .B 3d | ||||
| works in conjunction with | ||||
| .B ksh88 | ||||
| or | ||||
| .BR ksh93 . | ||||
| The | ||||
| .B 3d | ||||
| command with no arguments enters a | ||||
| .B 3d | ||||
| shell. | ||||
| The | ||||
| .B vpath | ||||
| builtin controls the logical | ||||
| filesystem view: | ||||
| .EX | ||||
| vpath dir_1 dir_2 | ||||
| .EE | ||||
| mounts the directory hierarchy | ||||
| .I dir_1 | ||||
| on top of | ||||
| .IR dir_2 . | ||||
| Files under | ||||
| .I dir_1 | ||||
| overlay files under | ||||
| .IR dir_2 . | ||||
| Files under | ||||
| .I dir_2 | ||||
| are readonly; | ||||
| any files under | ||||
| .I dir_2 | ||||
| that are modified are first copied to the | ||||
| corresponding place in | ||||
| .IR dir_1 . | ||||
| .I vpaths | ||||
| may be chained: | ||||
| .EX | ||||
| vpath dir_2 dir_3 | ||||
| .EE | ||||
| .I vpaths | ||||
| are per-process; every process may have a different view. | ||||
| .I vpaths | ||||
| are a handy way to separate source and generated files. | ||||
| Typical | ||||
| .B advsoft | ||||
| users set up | ||||
| .B 3d | ||||
| at login or | ||||
| .B xterm | ||||
| time: | ||||
| .EX | ||||
| export HOSTTYPE=$(package) | ||||
| vpath $HOME/arch/$HOSTTYPE $HOME | ||||
| .EE | ||||
| with source files in | ||||
| .LR $HOME/src/(cmd|lib)/* . | ||||
| .B nmake | ||||
| is run in | ||||
| .L $HOME/arch/$HOSTTYPE/src/(cmd|lib)/* | ||||
| and generated files (objects and executables) are dropped in the top hierarchy. | ||||
| .P | ||||
| .B 2d | ||||
| can prefix any command to disable  | ||||
| .B 3d | ||||
| for that command: | ||||
| .EX | ||||
| 2d ls *.c | ||||
| .EE | ||||
| .P | ||||
| .B 3d | ||||
| also provides tracing, monitoring and call intercept services. | ||||
| .B vpm | ||||
| uses monitoring to graph the process and io hierarchy. | ||||
| The | ||||
| .I cs | ||||
| name server uses pathname call intercepts to translate network | ||||
| pathnames. | ||||
| Try this for any host: | ||||
| .EX | ||||
| cat /dev/tcp/hostname/inet.daytime | ||||
| .EE | ||||
|  | @ -1,25 +0,0 @@ | |||
| vpath - /#option/debug=level | ||||
| 
 | ||||
| 	set debug trace level | ||||
| 
 | ||||
| vpath - /#option/trace[=pid] | ||||
| 
 | ||||
| 	turn on truss style tracing with option pid prefix | ||||
| 
 | ||||
| vpath	/dev/tcp/share/cat/#/home/gsf/tmp/call.out \ | ||||
| 	/#fs/proc/global/monitor/call=fork,exec,exit | ||||
| 
 | ||||
| 	monitor fork,exec,exit by sending messages to the cat server | ||||
| 
 | ||||
| vpath	/tmp/io.out \ | ||||
| 	/#fs/io/global/monitor/call=open,close,write | ||||
| 
 | ||||
| 	monitor open,close,write by appending messages /tmp/io.out | ||||
| 
 | ||||
| vpath /home/gsf/tmp/rpl.out /#fs/rpl/monitor | ||||
| 
 | ||||
| 	create a per-tree monitor to rpl.out | ||||
| 
 | ||||
| vpath . /#rpl /tmp /#rpl | ||||
| 
 | ||||
| 	all calls on files in . and /tmp trees monitored to rpl.out | ||||
|  | @ -1,152 +0,0 @@ | |||
| 12-06-25 change strcpy() within buffer to strcopy() | ||||
| 12-06-22 sys.tab,utimensat3d.c: add utimensat() | ||||
| 12-05-25 sys.tab: handle missing getdents64 on linux+gcc-4.4 | ||||
| 12-05-25 syscall3d.c: tweak _exit() logic (really?) to dumped core on recent solaris | ||||
| 11-12-01 fix fcntl 3rd arg int vs void* | ||||
| 10-06-01 sync with ast api 20100601 | ||||
| 10-04-10 mkdir3d.c: fix mkdir() intermediate dir logic | ||||
| 10-01-19 3d.h: increase some path buffer sizes -- these need to be dynamic! | ||||
| 09-05-15 dll_3d.h: handle dllopen => dlopen | ||||
| 08-12-04 fs.c: change open(/dev/fd/NN,...) try open(2) first, then dup(2) | ||||
| 08-06-20 ast_3d.h,ast.c: add libast/misc/setenviron.c | ||||
| 07-03-26 Makefile: drop -L* from IFFEREFS -- handled by .IFFE.REF. | ||||
| 07-03-21 lib_3d.h,error.c: handle error_info => *_error_data_ | ||||
| 06-12-04 3d.h: strmode() bsd conflict tweak | ||||
| 06-11-23 finally get linux to pass regression tests | ||||
| 06-11-21 fchdir3d: let chdir do the work if fd matches cached path | ||||
| 06-09-28 3d.sh: used getconf LIBPATH|LIBPREFIX|LIBSUFFIX -- how novel | ||||
| 06-09-26 3d.h,dir3d.c,dll3d.c: fix strtou*l*l maps for __int64 vs. long long | ||||
| 06-09-18 strmatch.c,touch.c: add private obsolete api copies | ||||
| 06-08-27 mkdir3d.c: foloow mkdir -p mode rules for missing intermediates | ||||
| 05-02-01 3d.sh: IFS may be unset and { ash bsh } don't on startup -- wow | ||||
| 05-01-01 sys.tab,utimets3d.c: add utimets() intercept | ||||
| 04-12-15 pathreal.c: "..." should fail if no lower view -- doh | ||||
| 04-10-01 features/syslib: _exit test now uses SIGKILL (openbsd abort() hangs) | ||||
| 04-07-26 3d.sh: update runtime docs | ||||
| 	 3d.1: drop in deference to the 3d.sh runtime docs | ||||
| 04-07-20 3d.h: undef _BLD_DEBUG to avoid raw libast symbols | ||||
| 04-07-19 fs.c,lib.c,open3d.c,vcs_3d.h: { O_RDONLY O_WRONLY O_RDWR } are values | ||||
| 04-07-19 dir3d.c: rewinddir643d() must call seekdir643d() (not seekdir64()) | ||||
| 04-07-01 3d.tst: TMP => TWD to match regress(1) | ||||
| 04-06-16 3d.tst: coordinate $TMP with regress(1) | ||||
| 04-06-14 lib.c: fix fs3d() 2d return value | ||||
| 04-06-11 3d.tst: fix test and error counts | ||||
| 04-05-04 open3d.c: create missing lower level dirs for O_CREAT ... file paths | ||||
| 03-08-15 mount3d.c: change 3d intercept test to handle NiL || "" | ||||
| 03-06-11 ast.c: add _map_malloc checks for _ast_malloc => malloc | ||||
| 03-06-05 pathreal.c: fix ancient multiple relative|.. symlink bug | ||||
| 03-06-04 3d.sh: change `shift $OPTIND-1' to `set x "@"; shift $OPTIND' | ||||
| 03-03-28 dir3d.c,rmdir3d.c,syscall3d.c: add D_FILENO and D_TYPE ifdefs | ||||
| 03-03-25 dup3d.c: fix bug that cleared Dir_t pointer just after allocation | ||||
| 03-03-07 ftruncate3d.c,lseek3d.c,truncate3d.c: check _typ_off64_t | ||||
| 02-10-18 features/syscall.sh: handle pseudo files in cc -E line syncs | ||||
| 02-07-17 syscall3d.c: clean up user level intercept code | ||||
| 02-06-25 open3d.c: fix bug that created 0 mode file with only O_RDWR | ||||
| 02-06-14 ast_3d.h,cs.c: move fmttime() macro override to cs.c | ||||
| 02-06-06 dir3d.c: fix rewinddir() bug that did not decrement intercepted count | ||||
| 02-04-01 Makefile,cs.c,cs_3d.h,ast_3d.h: _WIN32 tweaks | ||||
| 01-11-26 pathreal.c: empty path is an error | ||||
| 01-11-16 ftruncate3d.c,truncate3d.c: use lseek3d indirection via sysfunc() | ||||
| 01-10-31 fchdir3d: add along with state.file[].dir to cache open dir paths | ||||
| 	 dir3d.c: add recursive call intercepts | ||||
| 	 error.c: add recursive call intercepts | ||||
| 	 pathreal.c: add buffer size check | ||||
| 	 features/syscall.sh: add bsd syscall __RENAME() checks | ||||
| 	 syscall3d.c: check _lib_syscall before using it! | ||||
| 01-10-30 features/syscall.sh,syscall3d.c: handle -ldl calls back into 3d | ||||
| 01-09-20 3d.sh: drop extra } in USAGE that emitted -} for --? | ||||
| 01-07-17 Makefile: don't link 3d dll against ast dll | ||||
| 01-02-19 close3d: dup reserved fd's higher | ||||
| 01-02-14 add :VARIANT: to build dll's for CC.DLL.VARIANTS | ||||
| 01-01-01 dir_3d.h: real readdir must be struct dirent, not dirent64 | ||||
| 00-12-14 3d.sh: fix -c | ||||
| 00-10-31 ast.c add pathtemp.c | ||||
| 00-10-19 init.c: initialize _3d_2d | ||||
| 00-07-17 fix fchown to call MSG_fchown (not MSG_fchown); fixes vim dump! | ||||
| 00-02-14 3d command long options (finally) | ||||
| 99-01-01 --- release 4.0 --- | ||||
| 99-04-01 dll: sfsprintf => _3d_sfsprintf | ||||
| 	 check for __*_nc (osf.alpha) | ||||
| 99-02-14 pathreal: copy to state.path.name if not already there | ||||
| 	 rewinddir3d: just call seekdir(p,0); fixes `top' core dump | ||||
| 99-01-11 lseek3d,syscall3d: add sysfunc() for off_t!=long | ||||
| 99-01-01 --- release 3.0 --- | ||||
| 98-02-14 3d.sh: fix _RLD32_LIST => _RLDN32_LIST typo | ||||
| 	 pathreal: fix (P_LSTAT|P_READLINK) under pwd bug that did phys on . | ||||
| 	 features/syscall.sh: tighten up version __call header grep | ||||
| 	 unlink: trap remove() too | ||||
| 	 features/syscall.sh: favor strong (_ prefix) name for some arch's | ||||
| 98-02-06 syscall3d: handle longjmp with cp->active | ||||
| 98-01-23 features/syscall.sh: check for _xstat vs __xstat | ||||
| 98-01-01 add readdir64 rewinddir64 seekdir64 telldir64 | ||||
| 97-10-11 fix lefty's virtual dir touch bug -- recursive doubling on stbuf | ||||
| 97-07-17 CS_INTERFACE=2 | ||||
| 97-04-01 features/syscall.sh: fix __exit() test for new sgi | ||||
| 96-12-25 handle stat64() implementations on top of _xstat() | ||||
| 	 3d.tst must be run under 3d! | ||||
| 	 _SCO_STAT_VER tweaks | ||||
| 	 sgi _RLD_NEXT_PATHNAME fix for -32 -n32 -64 differentiation | ||||
| 	 _*xstat() hacks around proto in *stat3d.c | ||||
| 	 add constant casts for long shift counts | ||||
| 	 fix pathnext() to report version instance level in state.path.level | ||||
| 96-11-28 fix rename() to do physical stat on subject path! | ||||
| 96-02-29 handle syscall loops caused by botched libs like solaris libsocket.so | ||||
| 	 generalize name service interface to handle ifs+vcs | ||||
| 	 catch acl,facl even if not on local sys | ||||
| 	 fix features/syscall.sh bug that set $stdc incorrectly | ||||
| 	 use alloca() in execve() if possible | ||||
| 	 add 3d.tst and test makefile action | ||||
| 	 fix a few important virtual dir / create / append bugs | ||||
| 	 fix null dereference in open3d() for state.in_2d | ||||
| 96-02-14 add NFS acl,facl | ||||
| 96-02-08 fix 2d bug in link,rename,symlink that generated empty arg 1 | ||||
| 96-01-30 fix features/syscall.sh for compilers that ignore prototypes | ||||
| 96-01-22 P_TOP only takes effect for files in virtual dir! | ||||
| 95-11-24 optimize exec $shell to eval in 3d.sh | ||||
| 95-11-11 don't fs3d_copy opaqued files | ||||
| 95-10-11 fs3d_mkdir virtual dir fix  | ||||
| 	 fix 2d virtual dir test in pathreal() | ||||
| 	 solaris _rename() != weak rename() | ||||
| 	 solaris exit() doesn't call _exit() | ||||
| 	 all static data in state | ||||
| 	 test state.in_2d in link3d() | ||||
| 	 fix opaque.sh that was broken sometime after 91 | ||||
| 	 linux LD_BIND_NOW not needed with ld.so-1.7.9 | ||||
| 95-07-17 handle irix-5.3 struct stat64 and off64_t | ||||
| 	 dlsym(__exit) before dlsym(_exit) | ||||
| 95-05-09 fix pathcanon() bug that incremented state.path.level too far on ... | ||||
| 	 percolate inode metadata changes to the top level too (no more EROFS) | ||||
| 	 add P_TOP to truncate() too! | ||||
| 	 feature/syscall.sh does not generate #include, up to *3d.c | ||||
| 	 spawnveg.c must come after spawnve.c in ast.c | ||||
| 	 cspoll.c must come after cs*.c in cs.c | ||||
| 	 fix 3d to work like $SHELL if no shared 3d lib found | ||||
| 	 fix chdir .. symlink bug that set state.pwd to physical path | ||||
| 	 add %n.n.nd to bvprintf | ||||
| 	 ignore a few more non-initialization setcwd() errors | ||||
| 95-01-19 fix undefined var ref for _VER_ hack calls in features/syscall.sh | ||||
| 95-01-11 access W_OK succeeds if on lower view | ||||
| 94-12-01 add /#fs/NAME/load to load shared lib fs | ||||
| 	 add user system call trap() stack | ||||
| 	 VPATH=*::* or VPATH=*:-:* to separate disjoint views | ||||
| 	 change trap() to intercept() | ||||
| 94-07-17 add /#fs/safe | ||||
| 94-06-01 fix symlink() and link() bug that didn't instantiate virtual dir | ||||
| 	 fix [f]statvfs() infinite loop for att hybrids | ||||
| 94-05-11 merge with the real vcs | ||||
| 	 add char*_3d_2d: if _3d_2d!=0&&getenv(_3d_2d)==0 then 2d | ||||
| 	 trailing slash in pathreal() interpreted as slash dot (off/w test=010) | ||||
| 93-05-28 add /#option/limit=n to limit view depth | ||||
| 93-04-01 --- release 2.0 --- | ||||
| 93-03-11 change /dev/3d/* to /#* | ||||
| 	 remove anno and rpl specific hooks | ||||
| 	 add name,monitor,active fs mounts | ||||
| 92-04-01 --- release 1.1 --- | ||||
| 92-02-11 change retained mounts to /dev/3d/dev | ||||
| 92-01-11 add $SHELL and /bin/sh exec() checks to force 3d sh | ||||
| 	 fix checklink() to concatenate relative links with original prefix | ||||
| 91-11-11 --- release 1.0 --- | ||||
| 	 add feature/syscall.sh to handle att s5r4, hp snake, sun 4.1 | ||||
| 	 change umask() 3d state toggle to mount(-,/dev/3d/option/{2d,3d}) | ||||
| 	 fix creat() virtual dir bug for umteenth time | ||||
| 	 link() and rename() now migrate to top instead of EROFS | ||||
|  | @ -1,40 +0,0 @@ | |||
| # | ||||
| # 2d  [ - | + ] | [ cmd ... ] | ||||
| # | ||||
| # @(#)2d (AT&T Bell Laboratories) 06/22/93 | ||||
| # | ||||
| #	2d	start 2d shell | ||||
| #	2d -	disable 2d [ enable 3d ] | ||||
| #	2d +	enable 2d [ disable 3d ] | ||||
| #	2d cmd	run cmd in 2d | ||||
| # | ||||
| 
 | ||||
| function _2d | ||||
| { | ||||
| 	option=$(vpath /#option/3d 2>/dev/null) | ||||
| 	case $option in | ||||
| 	?*)	trap "set +o noglob; vpath \$option; export LD_PRELOAD='$LD_PRELOAD' _RLD_LIST='$_RLD_LIST' _RLDN32_LIST='$_RLDN32_LIST'" 0 INT QUIT | ||||
| 		vpath - /#option/2d | ||||
| 		;; | ||||
| 	esac | ||||
| 	set +o noglob | ||||
| 	if	test -d . | ||||
| 	then	case $1 in | ||||
| 		-|+)	case $1 in | ||||
| 			+)	option="- /#option/2d" ;; | ||||
| 			-)	option="- /#option/3d" ;; | ||||
| 			esac | ||||
| 			return | ||||
| 			;; | ||||
| 		esac | ||||
| 		# this is close: ^A can't appear in $@ | ||||
| 		typeset IFS='' | ||||
| 		unset __ LD_PRELOAD _RLD_LIST | ||||
| 		case $1 in | ||||
| 		[-+]*)	$SHELL $@ ;; | ||||
| 		*)	${@-$SHELL} ;; | ||||
| 		esac | ||||
| 	else	print -u2 . not found | ||||
| 		return 1 | ||||
| 	fi | ||||
| } | ||||
|  | @ -1,104 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| access3d(const char* path, int mode) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	mode_t		test; | ||||
| 	struct stat 	st; | ||||
| 
 | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_stat, 0, path, &st)) | ||||
| 	{ | ||||
| 		if (state.ret) return(-1); | ||||
| 		sp = 0; | ||||
| 	} | ||||
| 	else | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, &st))) | ||||
| 		return(-1); | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * handle some frequent cases separately | ||||
| 	 */ | ||||
| 
 | ||||
| 	switch (mode) | ||||
| 	{ | ||||
| 	case F_OK: | ||||
| 		return(0); | ||||
| 	case R_OK: | ||||
| 		if ((st.st_mode&(S_IRUSR|S_IRGRP|S_IROTH)) == (S_IRUSR|S_IRGRP|S_IROTH)) | ||||
| 			return(0); | ||||
| 		break; | ||||
| 	case W_OK: | ||||
| 		if (state.path.level && (st.st_mode&(S_IWUSR|S_IWGRP|S_IWOTH)) && !ACCESS(sp, R_OK)) | ||||
| 			return(0); | ||||
| 		break; | ||||
| 	case X_OK: | ||||
| 		if ((st.st_mode&(S_IXUSR|S_IXGRP|S_IXOTH)) == (S_IXUSR|S_IXGRP|S_IXOTH)) | ||||
| 			return(0); | ||||
| 		break; | ||||
| 	} | ||||
| #if FS | ||||
| 	if (sp) | ||||
| #endif | ||||
| 	return(ACCESS(sp, mode)); | ||||
| #if FS | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * simulate access() | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (mode & (R_OK|W_OK|X_OK)) | ||||
| 	{ | ||||
| 		test = 0; | ||||
| 		if (st.st_uid == state.uid) | ||||
| 		{ | ||||
| 			if (mode & R_OK) test |= S_IRUSR; | ||||
| 			if (mode & W_OK) test |= S_IWUSR; | ||||
| 			if (mode & X_OK) test |= S_IXUSR; | ||||
| 		} | ||||
| 		else if (st.st_gid == state.gid) | ||||
| 		{ | ||||
| 			if (mode & R_OK) test |= S_IRGRP; | ||||
| 			if (mode & W_OK) test |= S_IWGRP; | ||||
| 			if (mode & X_OK) test |= S_IXGRP; | ||||
| 		} | ||||
| 		else  | ||||
| 		{ | ||||
| 			if (mode & R_OK) test |= S_IROTH; | ||||
| 			if (mode & W_OK) test |= S_IWOTH; | ||||
| 			if (mode & X_OK) test |= S_IXOTH; | ||||
| 		} | ||||
| 		if ((st.st_mode & test) != test) | ||||
| 		{ | ||||
| 			errno = EACCES; | ||||
| 			return(-1); | ||||
| 		} | ||||
| 	} | ||||
| 	return(0); | ||||
| #endif | ||||
| } | ||||
|  | @ -1,62 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if !defined(ACL3D) || !defined(SETACL) | ||||
| 
 | ||||
| #define aclent_t	char | ||||
| #define SETACL		1 | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #define MSG_acl		MSG_INIT(MSG_control, 051121, MSG_VAR_FILE) | ||||
| 
 | ||||
| int | ||||
| acl3d(const char* path, int cmd, int cnt, aclent_t* buf) | ||||
| { | ||||
| 	register char*		sp; | ||||
| 	register int		r; | ||||
| 
 | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_acl, 0, path, cmd, cnt, buf)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, cmd == SETACL ? (state.safe ? (P_SAFE|P_TOP) : P_TOP) : 0, NiL))) | ||||
| 		return -1; | ||||
| 	r = ACL(sp, cmd, cnt, buf); | ||||
| #if FS | ||||
| 	if (r >= 0) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_acl, 0, state.path.name, cmd, cnt, buf); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_acl)) | ||||
| 				fscall(mp, MSG_acl, 0, state.path.name, cmd, cnt, buf); | ||||
| 	} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
							
								
								
									
										121
									
								
								src/cmd/3d/ast.c
									
										
									
									
									
								
							
							
						
						
									
										121
									
								
								src/cmd/3d/ast.c
									
										
									
									
									
								
							|  | @ -1,121 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #define NoN(x) | ||||
| 
 | ||||
| #include "3d.h" | ||||
| #include "ast.h" | ||||
| 
 | ||||
| static char	conf[] = ""; | ||||
| 
 | ||||
| #define astconf(a,b,c)	conf | ||||
| #define ctermid		___ctermid | ||||
| 
 | ||||
| #include "state.c" | ||||
| 
 | ||||
| #include "astintercept.c" | ||||
| #include "getenv.c" | ||||
| #include "setenviron.c" | ||||
| #include "getcwd.c" | ||||
| #include "getwd.c" | ||||
| #include "hashalloc.c" | ||||
| #include "hashfree.c" | ||||
| #include "hashlook.c" | ||||
| #include "hashscan.c" | ||||
| #include "hashsize.c" | ||||
| #include "hashwalk.c" | ||||
| #include "memset.c" | ||||
| 
 | ||||
| #if DEBUG | ||||
| #include "fmterror.c" | ||||
| #endif | ||||
| 
 | ||||
| #if FS | ||||
| #include "tvgettime.c" | ||||
| #include "eaccess.c" | ||||
| #include "pathcat.c" | ||||
| #include "pathtemp.c" | ||||
| #include "pathtmp.c" | ||||
| 
 | ||||
| char* | ||||
| pathbin(void) | ||||
| { | ||||
| 	char*	p; | ||||
| 
 | ||||
| 	if (!(p = state.envpath) && !(p = getenv("PATH"))) | ||||
| 		p = ":/bin:/usr/bin:/usr/ucb"; | ||||
| 	return(p); | ||||
| } | ||||
| 
 | ||||
| #include "tokscan.c" | ||||
| #include "touch.c" | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #include "strmatch.c" | ||||
| #include "sigcrit.c" | ||||
| #include "waitpid.c" | ||||
| 
 | ||||
| #undef	_real_vfork | ||||
| 
 | ||||
| #define close	CLOSE | ||||
| #define fcntl	FCNTL | ||||
| #define read	READ | ||||
| #define write	WRITE | ||||
| 
 | ||||
| #include "pathshell.c" | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d doesn't handle spawnve() yet | ||||
|  * we need spawnveg3d() | ||||
|  */ | ||||
| 
 | ||||
| #if _lib_fork || _lib_vfork | ||||
| #undef	_lib_spawnve | ||||
| #endif | ||||
| 
 | ||||
| #include "spawnveg.c"	/* follows spawnve.c because of #undef's */ | ||||
| 
 | ||||
| #include "gross.c" | ||||
| 
 | ||||
| #if _map_malloc | ||||
| 
 | ||||
| #undef	calloc | ||||
| #undef	free | ||||
| #undef	malloc | ||||
| #undef	realloc | ||||
| #undef	strdup | ||||
| 
 | ||||
| extern void*	calloc(size_t, size_t); | ||||
| extern void	free(void*); | ||||
| extern void*	malloc(size_t); | ||||
| extern void*	realloc(void*, size_t); | ||||
| extern char*	strdup(const char*); | ||||
| 
 | ||||
| extern void*	_ast_calloc(size_t n, size_t m) { return calloc(n, m); } | ||||
| extern void	_ast_free(void* p) { free(p); } | ||||
| extern void*	_ast_malloc(size_t n) { return malloc(n); } | ||||
| extern void*	_ast_realloc(void* p, size_t n) { return realloc(p, n); } | ||||
| extern char*	_ast_strdup(const char* s) { return strdup(s); } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,61 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| /*
 | ||||
|  * libast 3d symbol mappings to minimize pollution | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _NAME3D_AST_H | ||||
| #define _NAME3D_AST_H | ||||
| 
 | ||||
| #define _ast_state	_3d_ast_state | ||||
| #define _ast_getenv	_3d_ast_getenv | ||||
| #define _ast_info	_3d_ast_info | ||||
| #define _ast_setenviron	_3d_ast_setenviron | ||||
| #define _hash_info_	_3d_hash_info | ||||
| #define astintercept	_3d_astintercept | ||||
| #define fmterror	_3d_fmterror | ||||
| #define fmttime		_3d_fmttime | ||||
| #define hashalloc	_3d_hashalloc | ||||
| #define hashdone	_3d_hashdone | ||||
| #define hashfree	_3d_hashfree | ||||
| #define hashlook	_3d_hashlook | ||||
| #define hashnext	_3d_hashnext | ||||
| #define hashscan	_3d_hashscan | ||||
| #define hashsize	_3d_hashsize | ||||
| #define hashwalk	_3d_hashwalk | ||||
| #define pathbin		_3d_pathbin | ||||
| #define pathcheck	_3d_pathcheck | ||||
| #define pathshell	_3d_pathshell | ||||
| #define pathtemp	_3d_pathtemp | ||||
| #define strmatch	_3d_strmatch | ||||
| #define strsubmatch	_3d_strsubmatch | ||||
| #define tokscan		_3d_tokscan | ||||
| #define touch		_3d_touch | ||||
| 
 | ||||
| #include <ast_lib.h> | ||||
| 
 | ||||
| #undef	_lib_fmterror | ||||
| 
 | ||||
| extern char*		_3d_ast_getenv(const char*); | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										391
									
								
								src/cmd/3d/bio.c
									
										
									
									
									
								
							
							
						
						
									
										391
									
								
								src/cmd/3d/bio.c
									
										
									
									
									
								
							|  | @ -1,391 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d buffer io | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| /*
 | ||||
|  * stripped down printf -- only { %c %[l[l]][dopux] %s } | ||||
|  */ | ||||
| 
 | ||||
| ssize_t | ||||
| bvprintf(char** buf, char* end, register const char* format, va_list ap) | ||||
| { | ||||
| 	register int	c; | ||||
| 	register char*	p; | ||||
| 	register char*	e; | ||||
| 	int		w; | ||||
| 	int		l; | ||||
| 	int		f; | ||||
| 	int		g; | ||||
| 	int		r; | ||||
| 	long		n; | ||||
| 	unsigned long	u; | ||||
| 	ssize_t		z; | ||||
| #if _typ_int64_t | ||||
| 	int64_t		q; | ||||
| 	uint64_t	v; | ||||
| #endif | ||||
| 	char*		s; | ||||
| 	char*		b; | ||||
| 	char*		x; | ||||
| 	char		num[32]; | ||||
| 
 | ||||
| 	static char	digits[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLNMOPQRSTUVWXYZ@_"; | ||||
| 
 | ||||
| 	if (buf) | ||||
| 	{ | ||||
| 		p = *buf; | ||||
| 		e = end; | ||||
| 	} | ||||
| 	else e = (p = end) + SHRT_MAX; | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		switch (c = *format++) | ||||
| 		{ | ||||
| 		case 0: | ||||
| 			goto done; | ||||
| 		case '%': | ||||
| 			if (*format == '-') | ||||
| 			{ | ||||
| 				format++; | ||||
| 				l = 1; | ||||
| 			} | ||||
| 			else l = 0; | ||||
| 			if (*format == '0') | ||||
| 			{ | ||||
| 				format++; | ||||
| 				f = l ? ' ' : '0'; | ||||
| 			} | ||||
| 			else f = ' '; | ||||
| 			if ((c = *format) == '*') | ||||
| 			{ | ||||
| 				format++; | ||||
| 				w = va_arg(ap, int); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				w = 0; | ||||
| 				while (c >= '0' && c <= '9') | ||||
| 				{ | ||||
| 					w = w * 10 + c - '0'; | ||||
| 					c = *++format; | ||||
| 				} | ||||
| 			} | ||||
| 			r = 0; | ||||
| 			if (c == '.') | ||||
| 			{ | ||||
| 				if ((c = *++format) == '*') | ||||
| 				{ | ||||
| 					format++; | ||||
| 					va_arg(ap, int); | ||||
| 				} | ||||
| 				else while (c >= '0' && c <= '9') c = *++format; | ||||
| 				if (c == '.') | ||||
| 				{ | ||||
| 					if ((c = *++format) == '*') | ||||
| 					{ | ||||
| 						format++; | ||||
| 						r = va_arg(ap, int); | ||||
| 					} | ||||
| 					else while (c >= '0' && c <= '9') | ||||
| 					{ | ||||
| 						r = r * 10 + c - '0'; | ||||
| 						c = *++format; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			if ((c = *format++) != 'l') | ||||
| 				n = 0; | ||||
| 			else if ((c = *format++) != 'l') | ||||
| 				n = 1; | ||||
| 			else | ||||
| 			{ | ||||
| 				n = 2; | ||||
| 				c = *format++; | ||||
| 			} | ||||
| 			g = 0; | ||||
| 			b = num; | ||||
| 			switch (c) | ||||
| 			{ | ||||
| 			case 0: | ||||
| 				break; | ||||
| 			case 'c': | ||||
| 				*b++ = va_arg(ap, int); | ||||
| 				break; | ||||
| 			case 'd': | ||||
| 				switch (n) | ||||
| 				{ | ||||
| 				case 0: | ||||
| 					n = va_arg(ap, int); | ||||
| 					break; | ||||
| 				default: | ||||
| #if _typ_int64_t | ||||
| 					q = va_arg(ap, int64_t); | ||||
| 					if (q < 0) | ||||
| 					{ | ||||
| 						g = '-'; | ||||
| 						q = -q; | ||||
| 					} | ||||
| 					v = q; | ||||
| 					goto dec_8; | ||||
| 				case 1: | ||||
| #endif | ||||
| 					n = va_arg(ap, long); | ||||
| 					break; | ||||
| 				} | ||||
| 				if (n < 0) | ||||
| 				{ | ||||
| 					g = '-'; | ||||
| 					n = -n; | ||||
| 				} | ||||
| 				u = n; | ||||
| 				goto dec; | ||||
| 			case 'o': | ||||
| 				switch (n) | ||||
| 				{ | ||||
| 				case 0: | ||||
| 					u = va_arg(ap, unsigned int); | ||||
| 					break; | ||||
| 				default: | ||||
| #if _typ_int64_t | ||||
| 					v = va_arg(ap, uint64_t); | ||||
| 					goto oct_8; | ||||
| 				case 1: | ||||
| #endif | ||||
| 					u = va_arg(ap, unsigned long); | ||||
| 					break; | ||||
| 				} | ||||
| 				do *b++ = (u & 07) + '0'; while (u >>= 3); | ||||
| 				break; | ||||
| 			case 's': | ||||
| 				s = va_arg(ap, char*); | ||||
| 				if (!s) s = "(null)"; | ||||
| 				if (w) | ||||
| 				{ | ||||
| 					n = w - strlen(s); | ||||
| 					if (l) | ||||
| 					{ | ||||
| 						while (w-- > 0) | ||||
| 						{ | ||||
| 							if (p >= e) goto done; | ||||
| 							if (!(*p = *s++)) break; | ||||
| 							p++; | ||||
| 						} | ||||
| 						while (n-- > 0) | ||||
| 						{ | ||||
| 							if (p >= e) goto done; | ||||
| 							*p++ = f; | ||||
| 						} | ||||
| 						continue; | ||||
| 					} | ||||
| 					while (n-- > 0) | ||||
| 					{ | ||||
| 						if (p >= e) goto done; | ||||
| 						*p++ = f; | ||||
| 					} | ||||
| 				} | ||||
| 				for (;;) | ||||
| 				{ | ||||
| 					if (p >= e) goto done; | ||||
| 					if (!(*p = *s++)) break; | ||||
| 					p++; | ||||
| 				} | ||||
| 				continue; | ||||
| 			case 'u': | ||||
| 				switch (n) | ||||
| 				{ | ||||
| 				case 0: | ||||
| 					u = va_arg(ap, unsigned int); | ||||
| 					break; | ||||
| 				default: | ||||
| #if _typ_int64_t | ||||
| 					v = va_arg(ap, uint64_t); | ||||
| 					goto dec_8; | ||||
| 				case 1: | ||||
| #endif | ||||
| 					u = va_arg(ap, unsigned long); | ||||
| 					break; | ||||
| 				} | ||||
| 			dec: | ||||
| 				if (r <= 0 || r >= sizeof(digits)) r = 10; | ||||
| 				do *b++ = digits[u % r]; while (u /= r); | ||||
| 				break; | ||||
| 			case 'p': | ||||
| 				if (x = va_arg(ap, char*)) | ||||
| 				{ | ||||
| 					g = 'x'; | ||||
| 					w = 10; | ||||
| 					f = '0'; | ||||
| 					l = 0; | ||||
| 				} | ||||
| #if _typ_int64_t | ||||
| 				if (sizeof(char*) == sizeof(int64_t)) | ||||
| 				{ | ||||
| 					v = (uint64_t)x; | ||||
| 					goto hex_8; | ||||
| 				} | ||||
| #endif | ||||
| 				u = (unsigned long)x; | ||||
| 				goto hex; | ||||
| 			case 'x': | ||||
| 				switch (n) | ||||
| 				{ | ||||
| 				case 0: | ||||
| 					u = va_arg(ap, unsigned int); | ||||
| 					break; | ||||
| 				default: | ||||
| #if _typ_int64_t | ||||
| 					v = va_arg(ap, uint64_t); | ||||
| 					goto hex_8; | ||||
| 				case 1: | ||||
| #endif | ||||
| 					u = va_arg(ap, unsigned long); | ||||
| 					break; | ||||
| 				} | ||||
| 			hex: | ||||
| 				do *b++ = ((n = (u & 0xf)) >= 0xa) ? n - 0xa + 'a' : n + '0'; while (u >>= 4); | ||||
| 				break; | ||||
| 			default: | ||||
| 				if (p >= e) goto done; | ||||
| 				*p++ = c; | ||||
| 				continue; | ||||
| #if _typ_int64_t | ||||
| 			dec_8: | ||||
| 				if (r <= 0 || r >= sizeof(digits)) r = 10; | ||||
| 				do *b++ = digits[v % r]; while (v /= r); | ||||
| 				break; | ||||
| 			hex_8: | ||||
| 				do *b++ = ((n = (v & 0xf)) >= 0xa) ? n - 0xa + 'a' : n + '0'; while (v >>= 4); | ||||
| 				break; | ||||
| 			oct_8: | ||||
| 				do *b++ = (v & 07) + '0'; while (v >>= 3); | ||||
| 				break; | ||||
| #endif | ||||
| 			} | ||||
| 			if (w) | ||||
| 			{ | ||||
| 				if (g == 'x') w -= 2; | ||||
| 				else if (g) w -= 1; | ||||
| 				n = w - (b - num); | ||||
| 				if (!l) | ||||
| 				{ | ||||
| 					if (g && f != ' ') | ||||
| 					{ | ||||
| 						if (g == 'x') | ||||
| 						{ | ||||
| 							if (p >= e) goto done; | ||||
| 							*p++ = '0'; | ||||
| 							if (p >= e) goto done; | ||||
| 							*p++ = 'x'; | ||||
| 						} | ||||
| 						else if (p >= e) goto done; | ||||
| 						else *p++ = g; | ||||
| 						g = 0; | ||||
| 					} | ||||
| 					while (n-- > 0) | ||||
| 					{ | ||||
| 						if (p >= e) goto done; | ||||
| 						*p++ = f; | ||||
| 					} | ||||
| 				} | ||||
| 			} | ||||
| 			if (g == 'x') | ||||
| 			{ | ||||
| 				if (p >= e) goto done; | ||||
| 				*p++ = '0'; | ||||
| 				if (p >= e) goto done; | ||||
| 				*p++ = 'x'; | ||||
| 			} | ||||
| 			else if (g) | ||||
| 			{ | ||||
| 				if (p >= e) goto done; | ||||
| 				*p++ = g; | ||||
| 			} | ||||
| 			while (b > num) | ||||
| 			{ | ||||
| 				if (p >= e) goto done; | ||||
| 				*p++ = *--b; | ||||
| 			} | ||||
| 			if (w && l) while (n-- > 0) | ||||
| 			{ | ||||
| 				if (p >= e) goto done; | ||||
| 				*p++ = f; | ||||
| 			} | ||||
| 			continue; | ||||
| 		default: | ||||
| 			if (p >= e) goto done; | ||||
| 			*p++ = c; | ||||
| 			continue; | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
|  done: | ||||
| 	if (p < e) *p = 0; | ||||
| 	if (buf) | ||||
| 	{ | ||||
| 		z = p - *buf; | ||||
| 		*buf = p; | ||||
| 	} | ||||
| 	else z = p - end; | ||||
| 	return(z); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| bprintf(char** buf, char* end, const char* format, ...) | ||||
| { | ||||
| 	va_list	ap; | ||||
| 	ssize_t	n; | ||||
| 
 | ||||
| 	va_start(ap, format); | ||||
| 	n = bvprintf(buf, end, format, ap); | ||||
| 	va_end(ap); | ||||
| 	return(n); | ||||
| } | ||||
| 
 | ||||
| ssize_t | ||||
| sfsprintf(char* buffer, size_t size, const char* format, ...) | ||||
| { | ||||
| 	va_list	ap; | ||||
| 	char**	buf; | ||||
| 	char*	end; | ||||
| 	int	n; | ||||
| 
 | ||||
| 	va_start(ap, format); | ||||
| 	if (size) | ||||
| 	{ | ||||
| 		buf = &buffer; | ||||
| 		end = buffer + size; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		buf = 0; | ||||
| 		end = buffer; | ||||
| 	} | ||||
| 	n = bvprintf(buf, end, format, ap); | ||||
| 	va_end(ap); | ||||
| 	return(n); | ||||
| } | ||||
|  | @ -1,50 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef	brk3d | ||||
| 
 | ||||
| int | ||||
| brk3d(void* p) | ||||
| { | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 	int			r; | ||||
| 
 | ||||
| 	initialize(); | ||||
| 	if (!(r = BRK(p))) | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_break)) | ||||
| 				fscall(mp, MSG_break, 0, p); | ||||
| 	return(r); | ||||
| #else | ||||
| 	return(BRK(p)); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(brk) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,82 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| chdir3d(const char* path) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	char		buf[2 * PATH_MAX + 1]; | ||||
| 
 | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_stat, 0, path, &state.path.st)) | ||||
| 	{ | ||||
| 		if (state.ret) | ||||
| 			return -1; | ||||
| 		if (!S_ISDIR(state.path.st.st_mode)) | ||||
| 		{ | ||||
| 			errno = ENOTDIR; | ||||
| 			return -1; | ||||
| 		} | ||||
| 		state.level = 1; | ||||
| 	} | ||||
| 	else | ||||
| #else | ||||
| 	initialize(); | ||||
| #endif | ||||
| 	{ | ||||
| 		if (state.level > 0 && state.pwd && !CHDIR(state.pwd)) | ||||
| 			state.level = 0; | ||||
| 		if (!(sp = pathreal(path, P_SAFE, NiL))) | ||||
| 			return -1; | ||||
| 		if (CHDIR(sp)) | ||||
| 			return -1; | ||||
| 	} | ||||
| 	if (state.pwd) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * save absolute path in state.pwd | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (*path != '/') | ||||
| 		{ | ||||
| 			strcpy(buf, state.pwd); | ||||
| 			sp = buf + state.pwdsize; | ||||
| 			*sp++ = '/'; | ||||
| 		} | ||||
| 		else | ||||
| 			sp = buf; | ||||
| 		strcpy(sp, path); | ||||
| #if 0 | ||||
| 		state.path.level = 0; | ||||
| #endif | ||||
| 		if ((sp = pathcanon(buf, sizeof(buf), 0)) && *(sp - 1) == '.' && *(sp - 2) == '/') | ||||
| 			*(sp -= 2) = 0; | ||||
| 		state.pwdsize = strcopy(state.pwd, buf) - state.pwd; | ||||
| 		memcpy(state.envpwd + sizeof(var_pwd) - 1, state.pwd, state.pwdsize); | ||||
| 		state.level = state.path.level; | ||||
| 		message((-1, "chdir: %s [%d]", state.pwd, state.level)); | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -1,70 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide chmod | ||||
| #else | ||||
| #define chmod        ______chmod | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| #define _LS_H		1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide chmod | ||||
| #else | ||||
| #undef  chmod | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| int | ||||
| chmod3d(const char* path, mode_t mode) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 
 | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_chmod, 0, path, mode)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, state.safe ? (P_SAFE|P_TOP) : P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	r = CHMOD(sp, mode); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_chmod, 0, state.path.name, mode); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_chmod)) | ||||
| 				fscall(mp, MSG_chmod, 0, state.path.name, mode); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,61 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef chown3d | ||||
| 
 | ||||
| int | ||||
| chown3d(const char* path, uid_t uid, gid_t gid) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 
 | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_chown, 0, path, uid, gid)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_SAFE|P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	r = CHOWN(sp, uid, gid); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_chown, 0, path, uid, gid); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_chown)) | ||||
| 				fscall(mp, MSG_chown, 0, path, uid, gid); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(chown) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,82 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| close3d(int fd) | ||||
| { | ||||
| 	initialize(); | ||||
| 	if (fd >= 0 && fd < elementsof(state.file)) | ||||
| 	{ | ||||
| 		register int		nfd; | ||||
| 		register short*		rp; | ||||
| #if FS | ||||
| 		register Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| #if defined(fchdir3d) | ||||
| 		if (state.file[fd].dir) | ||||
| 		{ | ||||
| 			free(state.file[fd].dir); | ||||
| 			state.file[fd].dir = 0; | ||||
| 		} | ||||
| #endif | ||||
| 		if (rp = state.file[fd].reserved) | ||||
| 		{ | ||||
| 			if ((nfd = FCNTL(fd, F_DUPFD, fd + 1)) < 0) | ||||
| 			{ | ||||
| 				errno = EBADF; | ||||
| 				return -1; | ||||
| 			} | ||||
| 			*rp = nfd; | ||||
| 			state.file[nfd].reserved = rp; | ||||
| 			state.file[nfd].flags = FILE_LOCK; | ||||
| 			state.file[fd].reserved = 0; | ||||
| 			CLOSE(fd); | ||||
| 		} | ||||
| #if FS | ||||
| 		if ((mp = state.file[fd].mount) && fssys(mp, MSG_close)) | ||||
| 		{ | ||||
| 			if (FSTAT(fd, &state.path.st)) | ||||
| 				state.path.st.st_mtime = 0; | ||||
| 			fscall(mp, MSG_close, 0, fd, state.path.st.st_mtime); | ||||
| 		} | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_close)) | ||||
| 			{ | ||||
| 				if ((state.file[fd].flags & FILE_OPEN) ? FSTAT(fd, &state.path.st) : fileinit(fd, NiL, NiL, 0)) | ||||
| 					state.path.st.st_mtime = 0; | ||||
| 				fscall(mp, MSG_close, 0, fd, state.path.st.st_mtime); | ||||
| 			} | ||||
| 		if (state.file[fd].flags) | ||||
| 		{ | ||||
| 			state.file[fd].flags = 0; | ||||
| 			state.file[fd].mount = 0; | ||||
| 			if (state.cache == fd) | ||||
| 				while (state.cache > 1 && !state.file[--state.cache].flags); | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
| 	return(CLOSE(fd)); | ||||
| } | ||||
|  | @ -1,110 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if _hdr_utime | ||||
| #include <utime.h> | ||||
| #else | ||||
| struct utimbuf | ||||
| { | ||||
| 	time_t  actime; | ||||
| 	time_t  modtime; | ||||
| }; | ||||
| #endif | ||||
| 
 | ||||
| #define COPYBUF		8096 | ||||
| 
 | ||||
| #if __sun__ || sun | ||||
| 
 | ||||
| #if _lib_mmap | ||||
| 
 | ||||
| #define COPYMAP		(32*COPYBUF) | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * copy rfd to wfd | ||||
|  * return 0 if success, otherwise -1. | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fs3d_copy(int rfd, int wfd, struct stat* st) | ||||
| { | ||||
| 	register ssize_t	n; | ||||
| 	ssize_t			filesize; | ||||
| 	struct stat		stbuf; | ||||
| 	struct utimbuf		ut; | ||||
| 	char			buf[COPYBUF]; | ||||
| 
 | ||||
| #ifdef COPYMAP | ||||
| 	off_t			offset; | ||||
| 	size_t			munmapsize; | ||||
| 	size_t			mapsize; | ||||
| 	char*			mapbuf; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!st && FSTAT(rfd, st = &stbuf)) return -1; | ||||
| 	if (!S_ISREG(st->st_mode)) return 0; | ||||
| 	if ((filesize = st->st_size) <= 0) | ||||
| 		filesize = 1; | ||||
| #ifdef COPYMAP | ||||
| 	mapsize = (filesize < COPYMAP) ? filesize : COPYMAP; | ||||
| 	if ((filesize > COPYBUF) && ((mapbuf = mmap((caddr_t)0, mapsize, PROT_READ, MAP_SHARED, rfd, 0)) != ((caddr_t)-1))) | ||||
| 	{ | ||||
| 		offset = 0; | ||||
| 		munmapsize = mapsize; | ||||
| 		for (;;) | ||||
| 		{ | ||||
| 			if (write(wfd, mapbuf, mapsize) != mapsize) | ||||
| 			{ | ||||
| 				munmap(mapbuf, munmapsize); | ||||
| 				return -1; | ||||
| 			} | ||||
| 			filesize -= mapsize; | ||||
| 			if (filesize <= 0) break; | ||||
| 			offset += mapsize; | ||||
| 			if (filesize < mapsize) mapsize = filesize; | ||||
| 			if (mmap(mapbuf, mapsize, PROT_READ, MAP_SHARED|MAP_FIXED, rfd, offset) == (caddr_t)-1) | ||||
| 			{ | ||||
| 				munmap(mapbuf, munmapsize); | ||||
| 				return -1; | ||||
| 			} | ||||
| 		} | ||||
| 		munmap(mapbuf, munmapsize); | ||||
| 	} | ||||
| #endif | ||||
| 	if (filesize > 0) | ||||
| 	{ | ||||
| 		while ((n = read(rfd, buf, COPYBUF)) > 0) | ||||
| 			if (write(wfd, buf, n) != n)  | ||||
| 				return -1; | ||||
| 		if (n < 0 || lseek(wfd, (off_t)0, 0)) return -1; | ||||
| 	} | ||||
| 	ut.actime = st->st_atime; | ||||
| 	ut.modtime = st->st_mtime; | ||||
| 	UTIME(state.path.name, &ut); | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -1,30 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| creat3d(const char* path, mode_t mode) | ||||
| { | ||||
| 	return(open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); | ||||
| } | ||||
|  | @ -1,75 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #define msgreserve(p)	reserve(p) | ||||
| 
 | ||||
| #define gethostname	______gethostname | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #undef	gethostname | ||||
| #undef	FSYNC | ||||
| 
 | ||||
| #include <ctype.h> | ||||
| 
 | ||||
| #define CS_LIB_LOCAL	1 | ||||
| 
 | ||||
| #define _3d_fmttime(a,b)	"[NOW]" | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| #undef	NoN | ||||
| #define NoN(x) | ||||
| 
 | ||||
| #include "csdata.c" | ||||
| #undef	csaddr | ||||
| #define csaddr(p,x)	0 | ||||
| #include "csauth.c" | ||||
| #include "csbind.c" | ||||
| #include "cslocal.c" | ||||
| #include "csname.c" | ||||
| #include "csntoa.c" | ||||
| #include "csread.c" | ||||
| #include "csrecv.c" | ||||
| #include "cssend.c" | ||||
| #include "csvar.c" | ||||
| #include "cswrite.c" | ||||
| 
 | ||||
| #include "msgbuf.c" | ||||
| #include "msgread.c" | ||||
| #include "msguser.c" | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #include "cspeek.c" | ||||
| #include "cspipe.c" | ||||
| 
 | ||||
| #if FS | ||||
| #include "cspoll.c"	/* follows cs*.c because of #undef's */ | ||||
| #endif | ||||
| 
 | ||||
| #include "msggetmask.c" | ||||
| #include "msgindex.c" | ||||
| #include "msginfo.c" | ||||
| #include "msgname.c" | ||||
| #include "msgsetmask.c" | ||||
|  | @ -1,97 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * libcs 3d symbol mappings to minimize pollution | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _NAME3D_CS_H | ||||
| #define _NAME3D_CS_H | ||||
| 
 | ||||
| #define CS_INTERFACE	2 | ||||
| 
 | ||||
| #define _cs_info_	_3d_cs_info_ | ||||
| #define csauth		_3d_csauth | ||||
| #define csbind		_3d_csbind | ||||
| #define cschallenge	_3d_cschallenge | ||||
| #define cslocal		_3d_cslocal | ||||
| #define csname		_3d_csname | ||||
| #define csntoa		_3d_csntoa | ||||
| #define cspeek		_3d_cspeek | ||||
| #define cspipe		_3d_cspipe | ||||
| #define cspoll		_3d_cspoll | ||||
| #define csread		_3d_csread | ||||
| #define csrecv		_3d_csrecv | ||||
| #define cssend		_3d_cssend | ||||
| #define csvar		_3d_csvar | ||||
| #define cswrite		_3d_cswrite | ||||
| 
 | ||||
| #define _cs_addr	_3d_cs_addr | ||||
| #define _cs_attr	_3d_cs_attr | ||||
| #define _cs_auth	_3d_cs_auth | ||||
| #define _cs_bind	_3d_cs_bind | ||||
| #define _cs_challenge	_3d_cs_challenge | ||||
| #define _cs_clone	_3d_cs_clone | ||||
| #define _cs_daemon	_3d_cs_daemon | ||||
| #define _cs_fd		_3d_cs_fd | ||||
| #define _cs_from	_3d_cs_from | ||||
| #define _cs_full	_3d_cs_full | ||||
| #define _cs_info	_3d_cs_info | ||||
| #define _cs_local	_3d_cs_local | ||||
| #define _cs_name	_3d_cs_name | ||||
| #define _cs_note	_3d_cs_note | ||||
| #define _cs_ntoa	_3d_cs_ntoa | ||||
| #define _cs_open	_3d_cs_open | ||||
| #define _cs_path	_3d_cs_path | ||||
| #define _cs_peek	_3d_cs_peek | ||||
| #define _cs_ping	_3d_cs_ping | ||||
| #define _cs_pipe	_3d_cs_pipe | ||||
| #define _cs_poll	_3d_cs_poll | ||||
| #define _cs_port	_3d_cs_port | ||||
| #define _cs_read	_3d_cs_read | ||||
| #define _cs_recv	_3d_cs_recv | ||||
| #define _cs_send	_3d_cs_send | ||||
| #define _cs_serve	_3d_cs_serve | ||||
| #define _cs_stat	_3d_cs_stat | ||||
| #define _cs_timeout	_3d_cs_timeout | ||||
| #define _cs_to		_3d_cs_to | ||||
| #define _cs_var		_3d_cs_var | ||||
| #define _cs_wakeup	_3d_cs_wakeup | ||||
| #define _cs_write	_3d_cs_write | ||||
| 
 | ||||
| #define _msg_info_	_3d_msg_info | ||||
| #define msgcall		_3d_msgcall | ||||
| #define msggetmask	_3d_msggetmask | ||||
| #define msggetu		_3d_msggetu | ||||
| #define msggetz		_3d_msggetz | ||||
| #define msgindex	_3d_msgindex | ||||
| #define msgname		_3d_msgname | ||||
| #define msgputu		_3d_msgputu | ||||
| #define msgputz		_3d_msgputz | ||||
| #define msgread		_3d_msgread | ||||
| #define msgreturn	_3d_msgreturn | ||||
| #define msgsetmask	_3d_msgsetmask | ||||
| #define msgvcall	_3d_msgvcall | ||||
| #define msgvreturn	_3d_msgvreturn | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,528 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d directory(3) | ||||
|  * | ||||
|  * NOTE: there are 3 limitations to this implementation | ||||
|  * | ||||
|  *	 (1) opendir() allocates one file descriptor for each directory | ||||
|  *	     view and these remain open until closedir() | ||||
|  * | ||||
|  *	 (2) telldir() offsets are encoded with the directory view level | ||||
|  *	     and TELLDIR() offset, and the directory view level takes | ||||
|  *	     TABBITS bits, so TELLDIR() offsets are limited to (32-TABBITS) | ||||
|  *	     bits, but that would be one big physical directory | ||||
|  * | ||||
|  *	(3) if dirent.d_type supported then directory stat.st_nlink is | ||||
|  *	    inflated to foil viewpath subdirectory counting that would | ||||
|  *	    skip lower view subdirs not reflected in the top level st_nlink | ||||
|  */ | ||||
| 
 | ||||
| #define _def_map_ast	1 | ||||
| #define _std_strtol	1 | ||||
| 
 | ||||
| #define getdirentries	______getdirentries | ||||
| #define sbrk		______sbrk | ||||
| #define strmode		______strmode | ||||
| 
 | ||||
| #include <ast_std.h> | ||||
| 
 | ||||
| #undef	getdirentries | ||||
| #undef	sbrk | ||||
| #undef	strmode | ||||
| 
 | ||||
| #include "dir_3d.h" | ||||
| 
 | ||||
| #if !_dir_ok | ||||
| #undef	dirent | ||||
| #define dirent	DIRdirent | ||||
| #endif | ||||
| 
 | ||||
| #undef	strtol | ||||
| #undef	strtoul | ||||
| #undef	strtoll | ||||
| #undef	strtoull | ||||
| 
 | ||||
| static int	intercepted; | ||||
| 
 | ||||
| DIR* | ||||
| opendir3d(const char* apath) | ||||
| { | ||||
| 	register char*	path; | ||||
| 	register DIR*	dirp = 0; | ||||
| 	register int	n; | ||||
| 	int		oerrno; | ||||
| 	long		visits = 0; | ||||
| 	struct stat	st; | ||||
| 
 | ||||
| 	if (dirp = (DIR*)state.freedirp) | ||||
| 		state.freedirp = 0; | ||||
| 	else if (!(dirp = newof(0, DIR, 1, 0))) | ||||
| 		return 0; | ||||
| 	intercepted++; | ||||
| 	dirp->fd = -1; | ||||
| 	dirp->viewp = dirp->view; | ||||
| 	n = state.in_2d; | ||||
| 	if (path = pathreal(apath, P_SLASH, NiL)) | ||||
| 		state.in_2d = 2; | ||||
| 	else | ||||
| 		path = (char*)apath; | ||||
| 	dirp->viewp->dirp = OPENDIR(path); | ||||
| 	state.in_2d = n; | ||||
| 	if (!dirp->viewp->dirp) | ||||
| 	{ | ||||
| 		state.freedirp = (void*)dirp; | ||||
| 		intercepted = 0; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	dirp->boundary = state.boundary; | ||||
| 	if (state.in_2d) | ||||
| 	{ | ||||
| 		dirp->overlay = 0; | ||||
| 		(dirp->viewp++)->opaque = 0; | ||||
| 		dirp->viewp->dirp = 0; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		oerrno = errno; | ||||
| 		n = strlen(path); | ||||
| 		path[n] = '/'; | ||||
| 		strcpy(path + n + 1, state.opaque); | ||||
| 		dirp->viewp->level = state.path.level; | ||||
| 		state.in_2d++; | ||||
| 		(dirp->viewp++)->opaque = LSTAT(path, &st) ? 0 : st.st_ino; | ||||
| 		state.in_2d--; | ||||
| 		path[n] = 0; | ||||
| 		while (pathnext(state.path.name, NiL, &visits)) | ||||
| 		{ | ||||
| 			state.in_2d = 2; | ||||
| 			dirp->viewp->dirp = OPENDIR(state.path.name); | ||||
| 			state.in_2d = 0; | ||||
| 			if (dirp->viewp->dirp) | ||||
| 			{ | ||||
| 				n = strlen(state.path.name); | ||||
| 				state.path.name[n] = '/'; | ||||
| 				strcpy(state.path.name + n + 1, state.opaque); | ||||
| 				dirp->viewp->level = state.path.level; | ||||
| 				(dirp->viewp++)->opaque = LSTAT(state.path.name, &st) ? 0 : st.st_ino; | ||||
| 				state.path.name[n] = 0; | ||||
| 			} | ||||
| 		} | ||||
| 		errno = oerrno; | ||||
| 		(dirp->viewp--)->dirp = 0; | ||||
| 		if (dirp->viewp <= dirp->view) | ||||
| 			dirp->overlay = 0; | ||||
| 		else if (!(dirp->overlay = hashalloc(NiL, HASH_set, HASH_ALLOCATE, 0))) | ||||
| 		{ | ||||
| 			closedir(dirp); | ||||
| 			intercepted = 0; | ||||
| 			return 0; | ||||
| 		} | ||||
| 	} | ||||
| 	dirp->viewp = dirp->view; | ||||
| 	CHEATDIR(dirp); | ||||
| 	intercepted = 0; | ||||
| 	return dirp; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| closedir3d(register DIR* dirp) | ||||
| { | ||||
| 	if (dirp) | ||||
| 	{ | ||||
| 		if (intercepted++) | ||||
| 		{ | ||||
| 			intercepted--; | ||||
| 			return CLOSEDIR(dirp); | ||||
| 		} | ||||
| 		for (dirp->viewp = dirp->view; dirp->viewp->dirp; dirp->viewp++) | ||||
| 			CLOSEDIR(dirp->viewp->dirp); | ||||
| 		if (dirp->overlay) | ||||
| 			hashfree(dirp->overlay); | ||||
| 		if (!state.freedirp) | ||||
| 			state.freedirp = (void*)dirp; | ||||
| 		else | ||||
| 			free((char*)dirp); | ||||
| 		intercepted--; | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| struct dirent* | ||||
| readdir3d(register DIR* dirp) | ||||
| { | ||||
| 	register struct DIRdirent*	dp; | ||||
| 	register Dir_physical_t*	covered; | ||||
| 
 | ||||
| 	if (intercepted++) | ||||
| 	{ | ||||
| 		intercepted--; | ||||
| 		return READDIR(dirp); | ||||
| 	} | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		while (!(dp = (struct DIRdirent*)READDIR(dirp->viewp->dirp))) | ||||
| 		{ | ||||
| 			if (!(++dirp->viewp)->dirp) | ||||
| 			{ | ||||
| 				intercepted--; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			CHEATDIR(dirp); | ||||
| 		} | ||||
| #ifdef D_FILENO | ||||
| 		if (!state.in_2d) | ||||
| 		{ | ||||
| 			register char*	s = dp->d_name; | ||||
| 
 | ||||
| 			/*
 | ||||
| 			 * skip opaque and hidden entries | ||||
| 			 */ | ||||
| 
 | ||||
| 			if (*s++ == '.' && *s++ == '.' && *s++ == '.') | ||||
| 			{ | ||||
| 				/*
 | ||||
| 				 * the following for old opaque | ||||
| 				 */ | ||||
| 
 | ||||
| 				if (!*s && !dirp->viewp->opaque) | ||||
| 					dirp->viewp->opaque = D_FILENO(dp); | ||||
| 				continue; | ||||
| 			} | ||||
| 		} | ||||
| #endif | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * NOTE: this (slimey) method assumes READDIR() returns . first | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (dirp->overlay && (!dirp->boundary || dp->d_name[0] != '.' || dp->d_name[1])) | ||||
| 		{ | ||||
| 			if ((covered = (Dir_physical_t*)hashget(dirp->overlay, dp->d_name)) && covered < dirp->viewp) | ||||
| 				continue; | ||||
| 			if ((dirp->viewp + 1)->dirp) | ||||
| 				hashput(dirp->overlay, 0, (char*)dirp->viewp); | ||||
| 		} | ||||
| #ifdef D_FILENO | ||||
| 		if (D_FILENO(dp) == dirp->viewp->opaque) | ||||
| 			continue; | ||||
| #endif | ||||
| 		intercepted--; | ||||
| 		return (struct dirent*)dp; | ||||
| 	} | ||||
| 	/*NOTREACHED*/ | ||||
| } | ||||
| 
 | ||||
| #undef	seekdir | ||||
| 
 | ||||
| #define OFFBITS		(CHAR_BIT*sizeof(long)-TABBITS) | ||||
| #define SETPOS(l,o)	((((long)(l))<<OFFBITS)|GETOFF(o)) | ||||
| #define GETOFF(p)	((p)&((((long)1)<<OFFBITS)-1)) | ||||
| #define GETLEV(p)	(((p)>>OFFBITS)&((((long)1)<<TABBITS)-1)) | ||||
| 
 | ||||
| void | ||||
| seekdir3d(register DIR* dirp, long pos) | ||||
| { | ||||
| 	register int	n; | ||||
| 	int		lev; | ||||
| 
 | ||||
| 	if (intercepted++) | ||||
| 	{ | ||||
| 		intercepted--; | ||||
| 		SEEKDIR(dirp, pos); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (pos) | ||||
| 	{ | ||||
| 		lev = GETLEV(pos); | ||||
| 		pos = GETOFF(pos); | ||||
| 		for (n = 0; dirp->view[n].dirp; n++) | ||||
| 			if (lev == dirp->view[n].level) | ||||
| 				break; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		n = 0; | ||||
| 		hashfree(dirp->overlay); | ||||
| 		dirp->overlay = hashalloc(NiL, HASH_set, HASH_ALLOCATE, 0); | ||||
| 	} | ||||
| 	if (dirp->view[n].dirp) | ||||
| 	{ | ||||
| 		SEEKDIR(dirp->view[n].dirp, pos); | ||||
| 		dirp->viewp = &dirp->view[n]; | ||||
| 		CHEATDIR(dirp); | ||||
| 		while (dirp->view[++n].dirp) | ||||
| 			SEEKDIR(dirp->view[n].dirp, 0L); | ||||
| 	} | ||||
| 	intercepted--; | ||||
| } | ||||
| 
 | ||||
| #undef	telldir | ||||
| 
 | ||||
| long | ||||
| telldir3d(DIR* dirp) | ||||
| { | ||||
| 	if (intercepted++) | ||||
| 	{ | ||||
| 		intercepted--; | ||||
| 		return TELLDIR(dirp); | ||||
| 	} | ||||
| 	return SETPOS(dirp->viewp->level, TELLDIR(dirp->viewp->dirp)); | ||||
| } | ||||
| 
 | ||||
| #undef	rewinddir | ||||
| 
 | ||||
| void | ||||
| rewinddir3d(register DIR* dirp) | ||||
| { | ||||
| 	seekdir(dirp, 0L); | ||||
| } | ||||
| 
 | ||||
| #if !_nosys_readdir64 | ||||
| 
 | ||||
| struct dirent64* | ||||
| readdir643d(register DIR* dirp) | ||||
| { | ||||
| 	register struct dirent64*	dp; | ||||
| 	register Dir_physical_t*	covered; | ||||
| 
 | ||||
| 	if (intercepted++) | ||||
| 	{ | ||||
| 		intercepted--; | ||||
| 		return READDIR64(dirp); | ||||
| 	} | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		while (!(dp = READDIR64(dirp->viewp->dirp))) | ||||
| 		{ | ||||
| 			if (!(++dirp->viewp)->dirp) | ||||
| 			{ | ||||
| 				intercepted--; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			CHEATDIR(dirp); | ||||
| 		} | ||||
| #ifdef D_FILENO | ||||
| 		if (!state.in_2d) | ||||
| 		{ | ||||
| 			register char*	s = dp->d_name; | ||||
| 
 | ||||
| 			/*
 | ||||
| 			 * skip opaque and hidden entries | ||||
| 			 */ | ||||
| 
 | ||||
| 			if (*s++ == '.' && *s++ == '.' && *s++ == '.') | ||||
| 			{ | ||||
| 				/*
 | ||||
| 				 * the following for old opaque | ||||
| 				 */ | ||||
| 
 | ||||
| 				if (!*s && !dirp->viewp->opaque) | ||||
| 					dirp->viewp->opaque = D_FILENO(dp); | ||||
| 				continue; | ||||
| 			} | ||||
| 		} | ||||
| #endif | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * NOTE: this (slimey) method assumes READDIR() returns . first | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (dirp->overlay && (!dirp->boundary || dp->d_name[0] != '.' || dp->d_name[1])) | ||||
| 		{ | ||||
| 			if ((covered = (Dir_physical_t*)hashget(dirp->overlay, dp->d_name)) && covered < dirp->viewp) | ||||
| 				continue; | ||||
| 			if ((dirp->viewp + 1)->dirp) | ||||
| 				hashput(dirp->overlay, 0, (char*)dirp->viewp); | ||||
| 		} | ||||
| #ifdef D_FILENO | ||||
| 		if (D_FILENO(dp) == dirp->viewp->opaque) | ||||
| 			continue; | ||||
| #endif | ||||
| 		intercepted--; | ||||
| 		return dp; | ||||
| 	} | ||||
| 	/*NOTREACHED*/ | ||||
| } | ||||
| 
 | ||||
| #undef	seekdir | ||||
| 
 | ||||
| #define OFFBITS64	(CHAR_BIT*sizeof(off64_t)-TABBITS) | ||||
| #define SETPOS64(l,o)	((((off64_t)(l))<<OFFBITS)|GETOFF(o)) | ||||
| #define GETOFF64(p)	((p)&((((off64_t)1)<<OFFBITS)-1)) | ||||
| #define GETLEV64(p)	(((p)>>OFFBITS)&((((off64_t)1)<<TABBITS)-1)) | ||||
| 
 | ||||
| void | ||||
| seekdir643d(register DIR* dirp, off64_t pos) | ||||
| { | ||||
| 	register int	n; | ||||
| 	int		lev; | ||||
| 
 | ||||
| 	if (intercepted++) | ||||
| 	{ | ||||
| 		intercepted--; | ||||
| 		SEEKDIR64(dirp, pos); | ||||
| 		return; | ||||
| 	} | ||||
| 	if (pos) | ||||
| 	{ | ||||
| 		lev = GETLEV(pos); | ||||
| 		pos = GETOFF(pos); | ||||
| 		for (n = 0; dirp->view[n].dirp; n++) | ||||
| 			if (lev == dirp->view[n].level) | ||||
| 				break; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		n = 0; | ||||
| 		if (dirp->overlay) | ||||
| 		{ | ||||
| 			hashfree(dirp->overlay); | ||||
| 			dirp->overlay = hashalloc(NiL, HASH_set, HASH_ALLOCATE, 0); | ||||
| 		} | ||||
| 	} | ||||
| 	if (dirp->view[n].dirp) | ||||
| 	{ | ||||
| 		SEEKDIR64(dirp->view[n].dirp, pos); | ||||
| 		dirp->viewp = &dirp->view[n]; | ||||
| 		CHEATDIR(dirp); | ||||
| 		while (dirp->view[++n].dirp) | ||||
| 			SEEKDIR64(dirp->view[n].dirp, (off64_t)0); | ||||
| 	} | ||||
| 	intercepted--; | ||||
| } | ||||
| 
 | ||||
| #undef	telldir | ||||
| 
 | ||||
| off64_t | ||||
| telldir643d(DIR* dirp) | ||||
| { | ||||
| 	if (intercepted) | ||||
| 		return TELLDIR64(dirp); | ||||
| 	return SETPOS(dirp->viewp->level, TELLDIR64(dirp->viewp->dirp)); | ||||
| } | ||||
| 
 | ||||
| #undef	rewinddir | ||||
| 
 | ||||
| void | ||||
| rewinddir643d(register DIR* dirp) | ||||
| { | ||||
| 	rewinddir(dirp); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #if !_mangle_syscall && (!_lib_opendir || !_hdr_dirent) | ||||
| 
 | ||||
| #include "dirlib.h" | ||||
| 
 | ||||
| #undef	_dir_ok | ||||
| 
 | ||||
| #define DIR		DIRDIR | ||||
| #undef	DIRDIR | ||||
| #define opendir		OPENDIR | ||||
| #if defined(SYS3D_opendir) | ||||
| #undef	OPENDIR | ||||
| #endif | ||||
| #define readdir		READDIR | ||||
| #if defined(SYS3D_readdir) | ||||
| #undef	READDIR | ||||
| #endif | ||||
| #define seekdir		SEEKDIR | ||||
| #if defined(SYS3D_seekdir) | ||||
| #undef	SEEKDIR | ||||
| #endif | ||||
| #define telldir		TELLDIR | ||||
| #if defined(SYS3D_telldir) | ||||
| #undef	TELLDIR | ||||
| #endif | ||||
| #define closedir	CLOSEDIR | ||||
| #if defined(SYS3D_closedir) | ||||
| #undef	CLOSEDIR | ||||
| #endif | ||||
| 
 | ||||
| #define id		sys_id | ||||
| #define freedirp	sys_freedirp | ||||
| 
 | ||||
| #ifndef	DIRBLKSIZ | ||||
| #ifdef	DIRBLK | ||||
| #define DIRBLKSIZ	DIRBLK | ||||
| #else | ||||
| #ifdef	DIRBUF | ||||
| #define DIRBLKSIZ	DIRBUF | ||||
| #else | ||||
| #define DIRBLKSIZ	8192 | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #include "getdents.c" | ||||
| #include "opendir.c" | ||||
| #include "readdir.c" | ||||
| #include "telldir.c" | ||||
| #include "seekdir.c" | ||||
| 
 | ||||
| #if !_nosys_readdir64 | ||||
| 
 | ||||
| #undef	dirent | ||||
| #define dirent		dirent64 | ||||
| #undef	getdents | ||||
| #define getdents	getdents64 | ||||
| #define DIR		DIRDIR | ||||
| #undef	DIRDIR | ||||
| #undef	readdir | ||||
| #define readdir		READDIR64 | ||||
| #if defined(SYS3D_readdir64) | ||||
| #undef	READDIR64 | ||||
| #endif | ||||
| 
 | ||||
| #if !_nosys_seekdir64 | ||||
| #undef	seekdir | ||||
| #define seekdir		SEEKDIR64 | ||||
| #if defined(SYS3D_seekdir64) | ||||
| #undef	SEEKDIR64 | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #if !_nosys_telldir64 | ||||
| #undef	telldir | ||||
| #define telldir		TELLDIR64 | ||||
| #if defined(SYS3D_telldir64) | ||||
| #undef	TELLDIR64 | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #include "readdir.c" | ||||
| 
 | ||||
| #if !_nosys_telldir64 | ||||
| #include "telldir.c" | ||||
| #endif | ||||
| 
 | ||||
| #if !_nosys_seekdir64 | ||||
| #include "seekdir.c" | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,224 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| /*
 | ||||
|  * AT&T Research | ||||
|  * | ||||
|  * directory stream access library private definitions | ||||
|  * handles 3d file system | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _DIR3D_H | ||||
| #define _DIR3D_H | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if !_mem_DIR | ||||
| #undef	_lib_opendir | ||||
| #endif | ||||
| 
 | ||||
| #define DIRENT_ILLEGAL_ACCESS	1 | ||||
| #define DIR			DIRDIR | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide opendir _opendir __opendir | ||||
| __STDPP__directive pragma pp:hide readdir _readdir __readdir readdir64 _readdir64 __readdir64 | ||||
| __STDPP__directive pragma pp:hide rewinddir _rewinddir __rewinddir rewinddir64 _rewinddir64 __rewinddir64 | ||||
| __STDPP__directive pragma pp:hide seekdir _seekdir __seekdir seekdir64 _seekdir64 __seekdir64 | ||||
| __STDPP__directive pragma pp:hide telldir _telldir __telldir telldir64 _telldir64 __telldir64 | ||||
| __STDPP__directive pragma pp:hide closedir _closedir __closedir | ||||
| __STDPP__directive pragma pp:hide _getdents __getdents getdents64 _getdents64 __getdents64 getdirentries | ||||
| #else | ||||
| #define opendir		DIRopendir | ||||
| #define _opendir	_DIRopendir | ||||
| #define __opendir	__DIRopendir | ||||
| #define readdir		DIRreaddir | ||||
| #define _readdir	_DIRreaddir | ||||
| #define __readdir	__DIRreaddir | ||||
| #define readdir64	DIRreaddir64 | ||||
| #define _readdir64	_DIRreaddir64 | ||||
| #define __readdir64	__DIRreaddir64 | ||||
| #if _lib_rewinddir | ||||
| #define rewinddir	DIRrewinddir | ||||
| #define _rewinddir	_DIRrewinddir | ||||
| #define __rewinddir	__DIRrewinddir | ||||
| #define rewinddir64	DIRrewinddir64 | ||||
| #define _rewinddir64	_DIRrewinddir64 | ||||
| #define __rewinddir64	__DIRrewinddir64 | ||||
| #endif | ||||
| #define seekdir		DIRseekdir | ||||
| #define _seekdir	_DIRseekdir | ||||
| #define __seekdir	__DIRseekdir | ||||
| #define seekdir64	DIRseekdir64 | ||||
| #define _seekdir64	_DIRseekdir64 | ||||
| #define __seekdir64	__DIRseekdir64 | ||||
| #if _lib_telldir | ||||
| #define telldir		DIRtelldir | ||||
| #define _telldir	_DIRtelldir | ||||
| #define __telldir	__DIRtelldir | ||||
| #define telldir64	DIRtelldir64 | ||||
| #define _telldir64	_DIRtelldir64 | ||||
| #define __telldir64	__DIRtelldir64 | ||||
| #endif | ||||
| #define closedir	DIRclosedir | ||||
| #define _closedir	_DIRclosedir | ||||
| #define __closedir	__DIRclosedir | ||||
| #define _getdents	_DIRgetdents | ||||
| #define __getdents	__DIRgetdents | ||||
| #define getdents64	DIRgetdents64 | ||||
| #define _getdents64	_DIRgetdents64 | ||||
| #define __getdents64	__DIRgetdents64 | ||||
| #define getdirentries	DIRgetdirentries | ||||
| #endif | ||||
| 
 | ||||
| #define _BLD_ast	1 | ||||
| #include <ast_dir.h> | ||||
| #undef	_BLD_ast | ||||
| 
 | ||||
| #if _lib_readdir64 && _typ_struct_dirent64 | ||||
| #undef	dirent | ||||
| #undef	DIRdirent | ||||
| #define DIRdirent	dirent | ||||
| #endif | ||||
| 
 | ||||
| #include <hash.h> | ||||
| 
 | ||||
| #if !defined(SYS3D_opendir) | ||||
| extern DIR*		OPENDIR(const char*); | ||||
| #endif | ||||
| #if !defined(SYS3D_readdir) | ||||
| extern struct dirent*	READDIR(DIR*); | ||||
| #endif | ||||
| #if !defined(SYS3D_seekdir) | ||||
| extern void		SEEKDIR(DIR*, long); | ||||
| #endif | ||||
| #if !defined(SYS3D_telldir) | ||||
| extern long		TELLDIR(DIR*); | ||||
| #endif | ||||
| #if !defined(SYS3D_rewinddir) | ||||
| extern void		REWINDDIR(DIR*); | ||||
| #endif | ||||
| #if !defined(SYS3D_closedir) | ||||
| extern void		CLOSEDIR(DIR*); | ||||
| #endif | ||||
| 
 | ||||
| #undef	DIR | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide opendir _opendir __opendir | ||||
| __STDPP__directive pragma pp:nohide readdir _readdir __readdir readdir64 _readdir64 __readdir64 | ||||
| __STDPP__directive pragma pp:nohide rewinddir _rewinddir __rewinddir rewinddir64 _rewinddir64 __rewinddir64 | ||||
| __STDPP__directive pragma pp:nohide seekdir _seekdir __seekdir seekdir64 _seekdir64 __seekdir64 | ||||
| __STDPP__directive pragma pp:nohide telldir _telldir __telldir telldir64 _telldir64 __telldir64 | ||||
| __STDPP__directive pragma pp:nohide closedir _closedir __closedir | ||||
| __STDPP__directive pragma pp:nohide _getdents __getdents getdents64 _getdents64 __getdents64 getdirentries | ||||
| #else | ||||
| #undef	opendir | ||||
| #undef	_opendir | ||||
| #undef	__opendir | ||||
| #undef	readdir | ||||
| #undef	_readdir | ||||
| #undef	__readdir | ||||
| #undef	readdir64 | ||||
| #undef	_readdir64 | ||||
| #undef	__readdir64 | ||||
| #ifndef REWINDDIR | ||||
| #if _lib_rewinddir | ||||
| #undef	rewinddir | ||||
| #undef	_rewinddir | ||||
| #undef	__rewinddir | ||||
| #undef	rewinddir64 | ||||
| #undef	_rewinddir64 | ||||
| #undef	__rewinddir64 | ||||
| #else | ||||
| #define REWINDDIR(p)	rewinddir(p) | ||||
| #define REWINDDIR64(p)	rewinddir64(p) | ||||
| #endif | ||||
| #endif | ||||
| #undef	seekdir | ||||
| #undef	_seekdir | ||||
| #undef	__seekdir | ||||
| #undef	seekdir64 | ||||
| #undef	_seekdir64 | ||||
| #undef	__seekdir64 | ||||
| #ifndef TELLDIR | ||||
| #if _lib_telldir | ||||
| #undef	telldir | ||||
| #undef	_telldir | ||||
| #undef	__telldir | ||||
| #undef	telldir64 | ||||
| #undef	_telldir64 | ||||
| #undef	__telldir64 | ||||
| #else | ||||
| #define TELLDIR64(p)	telldir64(p) | ||||
| #endif | ||||
| #endif | ||||
| #undef	closedir | ||||
| #undef	_closedir | ||||
| #undef	__closedir | ||||
| #undef	_getdents | ||||
| #undef	__getdents | ||||
| #undef	getdents64 | ||||
| #undef	_getdents64 | ||||
| #undef	__getdents64 | ||||
| #undef	getdirentries | ||||
| #endif | ||||
| 
 | ||||
| #if _mem_DIR | ||||
| #define CHEATDIR(p)	((p)->dir = *(p)->viewp->dirp) | ||||
| #else | ||||
| #define CHEATDIR(p) | ||||
| #endif | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	DIRDIR*		dirp;		/* system stream pointer	*/ | ||||
| 	ino_t		opaque;		/* opaque inode number		*/ | ||||
| 	int		level;		/* view level			*/ | ||||
| } Dir_physical_t; | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	int		fd;		/* placeholder for dirfd()	*/ | ||||
| #if _mem_DIR | ||||
| 	DIRDIR		dir;		/* in case user checks *DIRDIR	*/ | ||||
| #endif | ||||
| 	Dir_physical_t*	viewp;		/* current directory in view	*/ | ||||
| 	Dir_physical_t	view[TABSIZE];	/* dirp's in view		*/ | ||||
| 	Hash_table_t*	overlay;	/* directory overlay hash	*/ | ||||
| 	int		boundary;	/* return . at each view level	*/ | ||||
| } DIR;					/* directory stream descriptor	*/ | ||||
| 
 | ||||
| extern int		closedir(DIR*); | ||||
| extern DIR*		opendir(const char*); | ||||
| #if _HUH_2008_11_21 | ||||
| extern struct dirent*	readdir(DIR*); | ||||
| #endif | ||||
| #if _lib_rewinddir && !defined(rewinddir) | ||||
| extern void		rewinddir(DIR*); | ||||
| #endif | ||||
| extern void		seekdir(DIR*, long); | ||||
| #if _lib_telldir && !defined(telldir) | ||||
| extern long		telldir(DIR*); | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,46 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #define _def_map_ast	1 | ||||
| #define _std_strtol	1 | ||||
| 
 | ||||
| #ifndef _GNU_SOURCE | ||||
| #define _GNU_SOURCE	1 | ||||
| #endif | ||||
| #ifndef __EXTENSIONS__ | ||||
| #define __EXTENSIONS__	1 | ||||
| #endif | ||||
| 
 | ||||
| #define strmode		______strmode | ||||
| 
 | ||||
| #include <ast_std.h> | ||||
| 
 | ||||
| #undef	strmode | ||||
| 
 | ||||
| #include "dll_3d.h" | ||||
| 
 | ||||
| #undef	strtol | ||||
| #undef	strtoul | ||||
| #undef	strtoll | ||||
| #undef	strtoull | ||||
| 
 | ||||
| #include "dllnext.c" | ||||
| #include "dlfcn.c" | ||||
|  | @ -1,36 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "lib_3d.h" | ||||
| 
 | ||||
| #include <dlldefs.h> | ||||
| 
 | ||||
| #define dllopen		dlopen | ||||
| 
 | ||||
| #ifdef _DLL_RLD_SYM_TYPE | ||||
| #define _dll_next	_3d_dllnext | ||||
| extern void*		_dll_next(int, _DLL_RLD_SYM_TYPE*); | ||||
| #else | ||||
| #define dllnext		_3d_dllnext | ||||
| extern void*		dllnext(int); | ||||
| #endif | ||||
|  | @ -1,45 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef dup23d | ||||
| 
 | ||||
| int | ||||
| dup23d(int fd, register int r) | ||||
| { | ||||
| 	initialize(); | ||||
| 	if (r >= 0 && r < elementsof(state.file) && state.file[r].reserved) close(r); | ||||
| 	r = DUP2(fd, r); | ||||
| #if FS | ||||
| 	if (r >= 0 && r < elementsof(state.file)) | ||||
| 		fs3d_dup(fd, r); | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(dup2) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,91 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| int | ||||
| fs3d_dup(int ofd, int nfd) | ||||
| { | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (nfd >= 0 && ofd >= 0 && ofd < elementsof(state.file)) | ||||
| 	{ | ||||
| 		if (state.cache) | ||||
| 		{ | ||||
| 			if (!(state.file[ofd].flags & FILE_OPEN)) | ||||
| 				fileinit(ofd, NiL, NiL, 0); | ||||
| 			state.file[nfd] = state.file[ofd]; | ||||
| 			state.file[nfd].flags &= ~FILE_CLOEXEC; | ||||
| 			state.file[nfd].reserved = 0; | ||||
| 			if (nfd > state.cache) | ||||
| 				state.cache = nfd; | ||||
| 			if (nfd > state.open) | ||||
| 				state.open = nfd; | ||||
| 			if (mp = state.file[nfd].mount) | ||||
| 				fscall(mp, MSG_dup, nfd, ofd); | ||||
| 			for (mp = state.global; mp; mp = mp->global) | ||||
| 				if (fssys(mp, MSG_dup)) | ||||
| 					fscall(mp, MSG_dup, nfd, ofd); | ||||
| 		} | ||||
| #if defined(fchdir3d) | ||||
| 		if (state.file[nfd].dir) | ||||
| 		{ | ||||
| 			free(state.file[nfd].dir); | ||||
| 			state.file[nfd].dir = 0; | ||||
| 		} | ||||
| 		if (state.file[ofd].dir && (state.file[nfd].dir = newof(0, Dir_t, 1, strlen(state.file[ofd].dir->path)))) | ||||
| 		{ | ||||
| 			strcpy(state.file[nfd].dir->path, state.file[ofd].dir->path); | ||||
| 			state.file[nfd].dir->dev = state.file[ofd].dir->dev; | ||||
| 			state.file[nfd].dir->ino = state.file[ofd].dir->ino; | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #ifdef dup3d | ||||
| 
 | ||||
| int | ||||
| dup3d(int fd) | ||||
| { | ||||
| 	register int	r; | ||||
| 
 | ||||
| 	initialize(); | ||||
| 	r = DUP(fd); | ||||
| #if FS | ||||
| 	if (r >= 0 && r < elementsof(state.file)) | ||||
| 		fs3d_dup(fd, r); | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(dup) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,248 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * Glenn Fowler | ||||
|  * AT&T Research | ||||
|  * | ||||
|  * error and message formatter | ||||
|  * | ||||
|  *	level is the error level | ||||
|  *	level >= error_info.core!=0 dumps core | ||||
|  *	level >= ERROR_FATAL calls error_info.exit | ||||
|  *	level < 0 is for debug tracing | ||||
|  * | ||||
|  * NOTE: non-sfio version just for 3d | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if DEBUG | ||||
| 
 | ||||
| static ssize_t | ||||
| fs3d_write(int fd, const void* buf, size_t n) | ||||
| { | ||||
| 	return(WRITE(fd, buf, n)); | ||||
| } | ||||
| 
 | ||||
| #undef error_info | ||||
| #define error_info	_error_info_ | ||||
| 
 | ||||
| Error_info_t	_error_info_ = { 2, exit, fs3d_write }; | ||||
| Error_info_t*	_error_infop_ = &_error_info_; | ||||
| Error_info_t*	_error_data_ = &_error_info_; | ||||
| 
 | ||||
| /*
 | ||||
|  * print a name, converting unprintable chars | ||||
|  */ | ||||
| 
 | ||||
| static void | ||||
| print(char** buf, char* end, register char* name, char* delim) | ||||
| { | ||||
| 	register char*	s = *buf; | ||||
| 	register char*	e = end; | ||||
| 	register int	c; | ||||
| 
 | ||||
| 	while (c = *name++) | ||||
| 	{ | ||||
| 		if (c & 0200) | ||||
| 		{ | ||||
| 			c &= 0177; | ||||
| 			if (s >= e) break; | ||||
| 			*s++ = '?'; | ||||
| 		} | ||||
| 		if (c < ' ') | ||||
| 		{ | ||||
| 			c += 'A' - 1; | ||||
| 			if (s >= e) break; | ||||
| 			*s++ = '^'; | ||||
| 		} | ||||
| 		if (s >= e) break; | ||||
| 		*s++ = c; | ||||
| 	} | ||||
| 	while (*delim) | ||||
| 	{ | ||||
| 		if (s >= e) break; | ||||
| 		*s++ = *delim++; | ||||
| 	} | ||||
| 	*buf = s; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| errorv(const char* lib, int level, va_list ap) | ||||
| { | ||||
| 	register int	n; | ||||
| 	int		fd; | ||||
| 	int		flags; | ||||
| 	char*		b; | ||||
| 	char*		e; | ||||
| 	char*		format; | ||||
| 	char		buf[4096]; | ||||
| 
 | ||||
| 	int		line; | ||||
| 	char*		file; | ||||
| 
 | ||||
| 	static int	intercepted; | ||||
| 
 | ||||
| 	if (intercepted++) | ||||
| 	{ | ||||
| 		intercepted--; | ||||
| 		return; | ||||
| 	} | ||||
| 	if (level > 0) | ||||
| 	{ | ||||
| 		flags = level & ~ERROR_LEVEL; | ||||
| 		level &= ERROR_LEVEL; | ||||
| 	} | ||||
| 	else flags = 0; | ||||
| 	if ((fd = fsfd(&state.fs[FS_option])) <= 0 || level < error_info.trace || lib && (error_info.clear & ERROR_LIBRARY) || level < 0 && error_info.mask && !(error_info.mask & (1<<(-level - 1)))) | ||||
| 	{ | ||||
| 		if (level >= ERROR_FATAL) (*error_info.exit)(level - 1); | ||||
| 		intercepted--; | ||||
| 		return; | ||||
| 	} | ||||
| 	if (error_info.trace < 0) flags |= ERROR_LIBRARY|ERROR_SYSTEM; | ||||
| 	flags |= error_info.set; | ||||
| 	flags &= ~error_info.clear; | ||||
| 	if (!lib) flags &= ~ERROR_LIBRARY; | ||||
| 	e = (b = buf) + elementsof(buf) - 1; | ||||
| 	file = error_info.id; | ||||
| 	if (flags & ERROR_USAGE) | ||||
| 	{ | ||||
| 		bprintf(&b, e, (flags & ERROR_NOID) ? "       " : "Usage: "); | ||||
| 		if (file) print(&b, e, file, " "); | ||||
| 	} | ||||
| 	else if (level && !(flags & ERROR_NOID)) | ||||
| 	{ | ||||
| 		if (file) print(&b, e, file, (flags & ERROR_LIBRARY) ? " " : ": "); | ||||
| 		if (flags & ERROR_LIBRARY) | ||||
| 			bprintf(&b, e, "[%s library]: ", lib); | ||||
| 	} | ||||
| 	if (level > 0 && error_info.line > 0) | ||||
| 	{ | ||||
| 		if (error_info.file && *error_info.file) | ||||
| 			bprintf(&b, e, "\"%s\", ", error_info.file); | ||||
| 		bprintf(&b, e, "line %d: ", error_info.line); | ||||
| 	} | ||||
| 	switch (level) | ||||
| 	{ | ||||
| 	case 0: | ||||
| 		break; | ||||
| 	case ERROR_WARNING: | ||||
| 		error_info.warnings++; | ||||
| 		bprintf(&b, e, "warning: "); | ||||
| 		break; | ||||
| 	case ERROR_PANIC: | ||||
| 		error_info.errors++; | ||||
| 		bprintf(&b, e, "panic: "); | ||||
| 		break; | ||||
| 	default: | ||||
| 		if (level < 0) | ||||
| 		{ | ||||
| 			if (error_info.trace < -1) bprintf(&b, e, "debug%d:%s", level, level > -10 ? " " : ""); | ||||
| 			else bprintf(&b, e, "debug: "); | ||||
| 			for (n = 0; n < error_info.indent; n++) | ||||
| 			{ | ||||
| 				*b++ = ' '; | ||||
| 				*b++ = ' '; | ||||
| 			} | ||||
| 		} | ||||
| 		else error_info.errors++; | ||||
| 		break; | ||||
| 	} | ||||
| 	if (flags & ERROR_OUTPUT) fd = va_arg(ap, int); | ||||
| 	if (flags & ERROR_SOURCE) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * source ([version], file, line) message | ||||
| 		 */ | ||||
| 
 | ||||
| 		file = va_arg(ap, char*); | ||||
| 		line = va_arg(ap, int); | ||||
| 		if (error_info.version) bprintf(&b, e, "(%s: %s, line %d) ", error_info.version, file, line); | ||||
| 		else bprintf(&b, e, "(%s, line %d) ", file, line); | ||||
| 	} | ||||
| 	format = va_arg(ap, char*); | ||||
| 	bvprintf(&b, e, format, ap); | ||||
| 	if (!(flags & ERROR_PROMPT)) | ||||
| 	{ | ||||
| 		if ((flags & ERROR_SYSTEM) && errno && errno != error_info.last_errno) | ||||
| 		{ | ||||
| 			n = state.in_2d; | ||||
| 			state.in_2d = 1; | ||||
| 			bprintf(&b, e, " [%s]", fmterror(errno)); | ||||
| 			state.in_2d = n; | ||||
| 			if (error_info.set & ERROR_SYSTEM) errno = 0; | ||||
| 			error_info.last_errno = (level >= 0) ? 0 : errno; | ||||
| 		} | ||||
| 		*b++ = '\n'; | ||||
| 	} | ||||
| 	*b = 0; | ||||
| 	if (error_info.write) (*error_info.write)(fd, buf, b - buf); | ||||
| 	if (level >= error_info.core && error_info.core) | ||||
| 	{ | ||||
| 		signal(SIGQUIT, SIG_DFL); | ||||
| 		kill(getpid(), SIGQUIT); | ||||
| 		pause(); | ||||
| 	} | ||||
| 	if (level >= ERROR_FATAL) (*error_info.exit)(level - ERROR_FATAL + 1); | ||||
| 	intercepted--; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| error(int level, ...) | ||||
| { | ||||
| 	va_list	ap; | ||||
| 
 | ||||
| 	va_start(ap, level); | ||||
| 	errorv(NiL, level, ap); | ||||
| 	va_end(ap); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| errormsg(const char* dictionary, int level, ...) | ||||
| { | ||||
| 	va_list	ap; | ||||
| 
 | ||||
| 	va_start(ap, level); | ||||
| 	errorv(dictionary, level, ap); | ||||
| 	va_end(ap); | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| errorf(void* handle, void* discipline, int level, ...) | ||||
| { | ||||
| 	va_list	ap; | ||||
| 
 | ||||
| 	va_start(ap, level); | ||||
| 	errorv(discipline ? *((char**)handle) : (char*)handle, (discipline || level < 0) ? level : (level | ERROR_LIBRARY), ap); | ||||
| 	va_end(ap); | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(error) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,30 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| execv(const char* path, char* const argv[]) | ||||
| { | ||||
| 	return(execve(path, argv, environ)); | ||||
| } | ||||
|  | @ -1,150 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if _hdr_alloca | ||||
| 
 | ||||
| #include <alloca.h> | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| void | ||||
| fix(void) | ||||
| { | ||||
| 	if (state.brk.beg) | ||||
| 	{ | ||||
| 		ssize_t	n; | ||||
| 
 | ||||
| 		if (state.brk.end && (n = state.brk.end - state.brk.beg) > 0) | ||||
| 		{ | ||||
| 			memset(state.brk.beg, 0, n); | ||||
| 			if ((char*)sbrk(0) == state.brk.end) | ||||
| 				sbrk(-n); | ||||
| 		} | ||||
| 		state.brk.beg = state.brk.end = 0; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| int | ||||
| execve3d(const char* path, char* const* aargv, char* const* aarge) | ||||
| { | ||||
| 	char**		argv = (char**)aargv; | ||||
| 	char**		arge = (char**)aarge; | ||||
| 	register char*	sp; | ||||
| 	register char*	ep; | ||||
| 	register int	size; | ||||
| 	register int	argn = 0; | ||||
| 	int		n; | ||||
| 	char*		tp; | ||||
| 	char		buf[PATH_MAX]; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!(sp = pathreal(path, 0, NiL))) | ||||
| 		return(-1); | ||||
| 	if (state.safe && !state.path.level) | ||||
| 	{ | ||||
| 		errno = EPERM; | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	if (*sp == '/') | ||||
| 	{ | ||||
| #if HUH920211 /* mh corrupts static state strings */ | ||||
| 		if (streq(sp, state.binsh)) sp = state.shell; | ||||
| #else | ||||
| 		if (streq(sp, "/bin/sh")) sp = state.shell; | ||||
| #endif | ||||
| 	} | ||||
| 	else if (!state.in_2d && --sp > state.path.name) *--sp = '.'; | ||||
| 	sp = strncpy(buf, sp, sizeof(buf)); | ||||
| 	if (state.level) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * make sure dot is set correctly if not top level | ||||
| 		 */ | ||||
| 
 | ||||
| 		pathreal(state.pwd, 0, NiL); | ||||
| 	} | ||||
| 	if (arge == state.env + 1) arge--; | ||||
| 	else | ||||
| 	{ | ||||
| 		register char**	op = arge; | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * compute size of environment pointers | ||||
| 		 */ | ||||
| 
 | ||||
| 		while (*op++) argn++; | ||||
| 		argn += 2; | ||||
| 		argn *= sizeof(char*); | ||||
| 	} | ||||
| 	size = mapdump(NiL, NiL, MAP_EXEC); | ||||
| 	n = size + argn + 10; | ||||
| 	n = roundof(n, 32); | ||||
| #if _hdr_alloca | ||||
| 	state.brk.beg = (char*)alloca(n); | ||||
| #else | ||||
| 	state.brk.beg = (char*)sbrk(n); | ||||
| 	state.brk.end = (char*)sbrk(0); | ||||
| #endif | ||||
| 	ep = state.brk.beg + argn + 10 - sizeof(var_3d) + 1; | ||||
| 	tp = strcopy(ep, var_3d); | ||||
| 	size = mapdump(NiL, tp, MAP_EXEC); | ||||
| 	if (!keep(tp, size, 1)) | ||||
| 		reclaim(); | ||||
| 	else | ||||
| 	{ | ||||
| 		if (argn) | ||||
| 		{ | ||||
| 			register char**	op = arge; | ||||
| 			register char**	np; | ||||
| 
 | ||||
| 			arge = (char**)state.brk.beg; | ||||
| 			np = arge + 1; | ||||
| 			while (*np++ = *op++); | ||||
| 		} | ||||
| 		arge[0] = ep; | ||||
| 	} | ||||
| #if FS | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 	{ | ||||
| 		if (fssys(mp, MSG_exec)) | ||||
| 			fscall(mp, MSG_exec, 0, sp, argv, arge); | ||||
| 		if (fssys(mp, MSG_close)) | ||||
| 		{ | ||||
| 			register File_t*	fp; | ||||
| 
 | ||||
| 			for (fp = state.file; fp <= state.file + state.open; fp++) | ||||
| 				if ((fp->flags & FILE_OPEN) && ((fp->flags & FILE_CLOEXEC) || (size = FCNTL(fp - state.file, F_GETFD, NiL)) >= 0 && (size & FD_CLOEXEC)) && !FSTAT(fp - state.file, &state.path.st)) | ||||
| 					fscall(mp, MSG_close, 0, fp - state.file, state.path.st.st_mtime); | ||||
| 		} | ||||
| 	} | ||||
| #endif | ||||
| 	EXECVE(sp, argv, arge); | ||||
| 	reclaim(); | ||||
| 	return(-1); | ||||
| } | ||||
|  | @ -1,42 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| void | ||||
| _exit3d(int code) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	PULL_IN_3D; | ||||
| 
 | ||||
| 	initialize(); | ||||
| #if FS | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_exit)) | ||||
| 			fscall(mp, MSG_exit, 0, code, state.pid); | ||||
| #endif | ||||
| 	EXIT(code); | ||||
| } | ||||
|  | @ -1,58 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if !defined(ACL3D) || !defined(SETACL) | ||||
| 
 | ||||
| #define aclent_t	char | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #define MSG_facl	MSG_INIT(MSG_control, 051131, MSG_VAR_FILE) | ||||
| 
 | ||||
| int | ||||
| facl3d(int fd, int cmd, int cnt, aclent_t* buf) | ||||
| { | ||||
| 	register int	r; | ||||
| 
 | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_facl, 0, fd, cmd, cnt, buf)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	r = FACL(fd, cmd, cnt, buf); | ||||
| #if FS | ||||
| 	if (r >= 0) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_facl, 0, fd, cmd, cnt, buf); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_facl)) | ||||
| 				fscall(mp, MSG_facl, 0, fd, cmd, cnt, buf); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,45 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if defined(fchdir3d) | ||||
| 
 | ||||
| int | ||||
| fchdir3d(int fd) | ||||
| { | ||||
| 	Dir_t*		dp; | ||||
| 	struct stat	st; | ||||
| 
 | ||||
| 	if (fd >= 0 && fd < elementsof(state.file) && (dp = state.file[fd].dir) && !FSTAT(fd, &st) && dp->dev == st.st_dev && dp->ino == st.st_ino) | ||||
| 		chdir(dp->path); | ||||
| 	else if (FCHDIR(fd)) | ||||
| 		return -1; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoP(fchdir) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,54 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef fchmod3d | ||||
| 
 | ||||
| int | ||||
| fchmod3d(int fd, mode_t mode) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fchmod, 0, fd, mode)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FCHMOD(fd, mode)) | ||||
| 		return(-1); | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fchmod, 0, fd, mode); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fchmod)) | ||||
| 			fscall(mp, MSG_fchmod, 0, fd, mode); | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fchmod) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,54 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef fchown3d | ||||
| 
 | ||||
| int | ||||
| fchown3d(int fd, uid_t uid, gid_t gid) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fchown, 0, fd, uid, gid)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FCHOWN(fd, uid, gid)) | ||||
| 		return -1; | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fchown, 0, fd, uid, gid); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fchown)) | ||||
| 			fscall(mp, MSG_fchown, 0, fd, uid, gid); | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fchown) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,73 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef	fcntl3d | ||||
| 
 | ||||
| #include <stdarg.h> | ||||
| 
 | ||||
| int | ||||
| fcntl3d(int fd, int op, ...) | ||||
| { | ||||
| 	register int	r; | ||||
| 	int		n; | ||||
| 	void*		arg; | ||||
| 	va_list		ap; | ||||
| 
 | ||||
| 	initialize(); | ||||
| 	va_start(ap, op); | ||||
| 	arg = va_arg(ap, void*); | ||||
| 	va_end(ap); | ||||
| 	n = (int)integralof(arg); | ||||
| 	if (op == F_DUPFD && state.file[n].reserved) | ||||
| 		close(n); | ||||
| 	r = FCNTL(fd, op, arg); | ||||
| #if FS | ||||
| 	if (r >= 0 && r < elementsof(state.file)) | ||||
| 		switch (op) | ||||
| 		{ | ||||
| 		case F_DUPFD: | ||||
| 			fs3d_dup(fd, r); | ||||
| 			break; | ||||
| 		case F_SETFD: | ||||
| 			if (state.cache) | ||||
| 			{ | ||||
| 				if (!(n & FD_CLOEXEC)) | ||||
| 					state.file[fd].flags &= ~FILE_CLOEXEC; | ||||
| 				else if (!(state.file[fd].flags & FILE_OPEN)) | ||||
| 					fileinit(fd, NiL, NiL, 1); | ||||
| 				else | ||||
| 					state.file[fd].flags |= FILE_CLOEXEC; | ||||
| 			} | ||||
| 			break; | ||||
| 		} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fcntl) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,68 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include <sys/types.h> | ||||
| 
 | ||||
| #if _stream_peek | ||||
| #include <ast_tty.h> | ||||
| #include <stropts.h> | ||||
| #endif | ||||
| 
 | ||||
| #if _socket_peek | ||||
| #include <sys/socket.h> | ||||
| #endif | ||||
| 
 | ||||
| int | ||||
| main() | ||||
| { | ||||
| 	int		fds[2]; | ||||
| 	static char	msg[] = "test"; | ||||
| #if _stream_peek | ||||
| 	struct strpeek	pk; | ||||
| #endif | ||||
| 
 | ||||
| 	if (pipe(fds) || write(fds[1], msg, sizeof(msg)) != sizeof(msg)) | ||||
| 		return(0); | ||||
| #if _stream_peek | ||||
| 	pk.flags = 0; | ||||
| 	pk.ctlbuf.maxlen = -1; | ||||
| 	pk.ctlbuf.len = 0; | ||||
| 	pk.ctlbuf.buf = 0; | ||||
| 	pk.databuf.maxlen = sizeof(msg); | ||||
| 	pk.databuf.buf = msg; | ||||
| 	pk.databuf.len = 0; | ||||
| 	if (ioctl(fds[0], I_PEEK, &pk) > 0 && pk.databuf.len == sizeof(msg)) | ||||
| 	{ | ||||
| 		printf("#undef	_socket_peek\n"); | ||||
| 		return(0); | ||||
| 	} | ||||
| #endif | ||||
| #if _socket_peek | ||||
| 	if (recv(fds[0], msg, sizeof(msg), MSG_PEEK) == sizeof(msg)) | ||||
| 	{ | ||||
| 		printf("#undef	_stream_peek\n"); | ||||
| 		return(0); | ||||
| 	} | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -1,51 +0,0 @@ | |||
| typ	off64_t sys/stat.h | ||||
| 
 | ||||
| hdr	alloca | ||||
| 
 | ||||
| lib	syscall syscall.h sys/syscall.h | ||||
| 
 | ||||
| mem	stat.st_atim,stat.st_fstype sys/types.h sys/stat.h | ||||
| mem	DIR dirent.h -DDIRENT_ILLEGAL_ACCESS | ||||
| 
 | ||||
| tst	fdview execute{ | ||||
| 	#include <fcntl.h> | ||||
| 	#define VIEW	15 | ||||
| 	main() | ||||
| 	{ | ||||
| 		int	fd; | ||||
| 		int	oflags; | ||||
| 		int	nflags; | ||||
| 		int	xflags; | ||||
| 		if ((fd = open(argv[0], 0)) < 0) return(1); | ||||
| 		if ((oflags = fcntl(fd, F_GETFL, 0)) < 0) return(1); | ||||
| 		nflags = (oflags & 0xffff) | (VIEW<<16); | ||||
| 		if (fcntl(fd, F_SETFL, nflags) < 0) return(1); | ||||
| 		if ((xflags = fcntl(fd, F_GETFL, 0)) < 0) return(1); | ||||
| 		if (xflags != nflags) return(1); | ||||
| 		return(0); | ||||
| 	} | ||||
| }end pass{ | ||||
| 	echo "#define getfdview(f)	((fcntl(f,F_GETFL,0)>>16)&037)" | ||||
| 	echo "#define setfdview(f,v)	(fcntl(f,F_SETFL,(fcntl(f,F_GETFL,0)&0xffff)|(((v)&037)<<16)))" | ||||
| }end fail{ | ||||
| 	echo "/* hack alert -- this is the view of the last user open */" | ||||
| 	echo "#define getfdview(f)	(state.path.open_level)" | ||||
| 	echo "#define setfdview(f,v)" | ||||
| }end | ||||
| 
 | ||||
| tst	no_exit_exit note{ exit() bypasses _exit() }end exec{ | ||||
| 	#include <sys/types.h> | ||||
| 	#include <signal.h> | ||||
| 	#ifdef __STDC__ | ||||
| 	#include <unistd.h> | ||||
| 	#endif | ||||
| 	#if _STD_ | ||||
| 	void _exit(int code) { kill(getpid(), SIGKILL); } | ||||
| 	#else | ||||
| 	void _exit(code) int code; { kill(getpid(), SIGKILL); } | ||||
| 	#endif | ||||
| 	int main() | ||||
| 	{ | ||||
| 		return 0; | ||||
| 	} | ||||
| }end | ||||
|  | @ -1,135 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| #include <cs.h> | ||||
| 
 | ||||
| /*
 | ||||
|  * called in the child process by fork() | ||||
|  */ | ||||
| 
 | ||||
| static void | ||||
| forked(pid_t pid) | ||||
| { | ||||
| 	register int		fd; | ||||
| 	register Fs_t*		fs; | ||||
| 	register Mount_t*	mp; | ||||
| 	char*			type; | ||||
| 	long			addr; | ||||
| 	long			port; | ||||
| 	long			clone; | ||||
| 	int			nfd; | ||||
| 	pid_t			ppid; | ||||
| 	char*			b; | ||||
| 
 | ||||
| 	reclaim(); | ||||
| 	ppid = state.pid; | ||||
| 	state.pid = pid; | ||||
| 	state.channel.internal = 0; | ||||
| 	for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++) | ||||
| 	{ | ||||
| 		if ((fs->flags & FS_FORK) && fs->set) | ||||
| 			(*fs->set)(fs, state.null, 0, "fork", 4); | ||||
| 		if ((fs->flags & (FS_ERROR|FS_ON|FS_OPEN|FS_UNIQUE)) == (FS_ON|FS_OPEN|FS_UNIQUE)) | ||||
| 			fsdrop(fs, 0); | ||||
| 	} | ||||
| 	for (mp = state.mount; mp < state.mount + elementsof(state.mount); mp++) | ||||
| 		if (mp->fs) | ||||
| 			switch (mp->fs->flags & (FS_ACTIVE|FS_ERROR|FS_GLOBAL|FS_MONITOR|FS_NAME|FS_ON)) | ||||
| 	{ | ||||
| 	case FS_ACTIVE|FS_ON: | ||||
| 		if (!fscall(mp, MSG_INIT(MSG_fork, 01511, 0), ppid, state.path.name, sizeof(state.path.name)) && state.ret > 0) | ||||
| 		{ | ||||
| 			type = b = state.path.name; | ||||
| 			while (*b && *b != ' ') b++; | ||||
| 			if (*b) *b++ = 0; | ||||
| 			if (streq(type, "fdp")) fd = csrecv(&cs, mp->fs->fd, NiL, &nfd, 1) == 1 ? nfd : -1; | ||||
| 			else | ||||
| 			{ | ||||
| 				addr = strtol(b, &b, 0); | ||||
| 				port = strtol(b, &b, 0); | ||||
| 				clone = strtol(b, &b, 0); | ||||
| 				fd = csbind(&cs, type, addr, port, clone); | ||||
| 			} | ||||
| 			if (fd >= 0) | ||||
| 			{ | ||||
| 				FCNTL(fd, F_DUPFD, mp->fs->fd); | ||||
| 				CLOSE(fd); | ||||
| 			} | ||||
| 		} | ||||
| 		break; | ||||
| 	case FS_ACTIVE|FS_GLOBAL|FS_MONITOR|FS_ON: | ||||
| 	case FS_GLOBAL|FS_MONITOR|FS_ON: | ||||
| 	case FS_ACTIVE|FS_MONITOR|FS_ON: | ||||
| 	case FS_MONITOR|FS_ON: | ||||
| 		if (fssys(mp, MSG_fork)) | ||||
| 			fscall(mp, MSG_fork, ppid); | ||||
| 		break; | ||||
| 	} | ||||
| 
 | ||||
| 	if (state.cache) | ||||
| 		for (fd = 0; fd <= state.cache; fd++) | ||||
| 			if ((mp = state.file[fd].mount) && !(mp->fs->flags & FS_ACTIVE) && fssys(mp, MSG_dup)) | ||||
| 				fscall(mp, MSG_dup, fd, fd); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #ifdef	fork3d | ||||
| 
 | ||||
| pid_t | ||||
| fork3d(void) | ||||
| { | ||||
| 	pid_t			pid; | ||||
| 
 | ||||
| 	initialize(); | ||||
| 	if (!(pid = FORK()) || pid == state.pid || pid == getpid()) | ||||
| 	{ | ||||
| 		pid = 0; | ||||
| #if FS | ||||
| 		forked(getpid()); | ||||
| #else | ||||
| 		state.pid = getpid(); | ||||
| #endif | ||||
| 	} | ||||
| #if FS | ||||
| 	else | ||||
| 	{ | ||||
| 		register Mount_t*	mp; | ||||
| 
 | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_fork)) | ||||
| 				fscall(mp, MSG_fork, pid); | ||||
| 	} | ||||
| #endif | ||||
| 	return(pid); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fork) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,61 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef fpathconf3d | ||||
| 
 | ||||
| long | ||||
| fpathconf3d(int fd, int op) | ||||
| { | ||||
| 	long		r; | ||||
| 	int		oerrno; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fpathconf, 0, fd, op)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	oerrno = errno; | ||||
| 	errno = 0; | ||||
| 	r = FPATHCONF(fd, op); | ||||
| 	if (!errno) | ||||
| 	{ | ||||
| 		errno = oerrno; | ||||
| #if FS | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_fpathconf, 0, fd, op); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_fpathconf)) | ||||
| 				fscall(mp, MSG_fpathconf, 0, fd, op); | ||||
| #endif | ||||
| 	} | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fpathconf) | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										670
									
								
								src/cmd/3d/fs.c
									
										
									
									
									
								
							
							
						
						
									
										670
									
								
								src/cmd/3d/fs.c
									
										
									
									
									
								
							|  | @ -1,670 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d mounted fs support | ||||
|  * | ||||
|  * NOTE: be vewwwy careful with errno | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| #include <cs.h> | ||||
| 
 | ||||
| #define DEVFD		"/dev/fd" | ||||
| #define MNTFD		"path\n" | ||||
| #define MNTNAM		"/dev/tcp/*" | ||||
| 
 | ||||
| /*
 | ||||
|  * initialize mount channel and return fs fd for mp | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fschannel(register Mount_t* mp) | ||||
| { | ||||
| 	register Fs_t*	fs; | ||||
| 	register int	fd; | ||||
| 
 | ||||
| 	if (mp->channel == -1) | ||||
| 		return -1; | ||||
| 	fs = mp->fs; | ||||
| 	if (mp->channel && fs->fd) | ||||
| 		return fs->fd; | ||||
| 	if ((fd = fsfd(fs)) <= 0) | ||||
| 		return -1; | ||||
| 	if (mp->channel) | ||||
| 		return fs->fd; | ||||
| 	mp->channel = 1; | ||||
| 	mp->flags |= MOUNT_PRIMARY; | ||||
| 	return fd; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * generate phony monitor open for fd inherited from parent | ||||
|  */ | ||||
| 
 | ||||
| static void | ||||
| fsphony(register Mount_t* mp, register File_t* fp, int fd) | ||||
| { | ||||
| 	register ssize_t	n; | ||||
| 	int			nd; | ||||
| 	Mount_t*		np; | ||||
| 	char			buf[64]; | ||||
| 
 | ||||
| 	state.kernel++; | ||||
| 	fp->flags |= FILE_LOCK; | ||||
| 	*buf = 0; | ||||
| 	if (!(np = getmount(MNTNAM, NiL)) || (nd = fsfd(np->fs)) < 0) | ||||
| 		sfsprintf(buf, sizeof(buf), "%s/%d", DEVFD, fd); | ||||
| 	else if (!(np->fs->flags & FS_LOCK) && WRITE(nd, MNTFD, sizeof(MNTFD) - 1) == sizeof(MNTFD) - 1) | ||||
| 	{ | ||||
| 		np->fs->flags |= FS_LOCK; | ||||
| 		if (!cssend(&cs, nd, &fd, 1) && (n = READ(nd, buf, sizeof(buf))) > 1) | ||||
| 			buf[n - 1] = 0; | ||||
| 		np->fs->flags &= ~FS_LOCK; | ||||
| 	} | ||||
| 	state.kernel--; | ||||
| 	if (*buf) | ||||
| 	{ | ||||
| 		fp->open |= (1<<(mp-state.mount)); | ||||
| 		message((-3, "fs: phony: %s", buf)); | ||||
| 		fscall(mp, MSG_open, fd, buf, fp->oflag, 0, 0); | ||||
| 	} | ||||
| 	fp->flags &= ~FILE_LOCK; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * return real fd for up under mount mp to be accessed by call | ||||
|  * return value stuck in tail portion of state.path.name | ||||
|  */ | ||||
| 
 | ||||
| char* | ||||
| fsreal(register Mount_t* mp, long call, const char* up) | ||||
| { | ||||
| 	char		dev[2 * PATH_MAX + 3]; | ||||
| 	register char*	s = dev; | ||||
| 	register Fs_t*	fs = mp->fs; | ||||
| 	register int	n; | ||||
| 	register int	fd; | ||||
| 	int		lz; | ||||
| 	int		pz; | ||||
| 
 | ||||
| 	if (!(lz = mp->logicalsize)) | ||||
| 		lz = strlen(mp->logical); | ||||
| 	if (!(pz = mp->physicalsize) && mp->physical) | ||||
| 		pz = strlen(mp->physical); | ||||
| 	n = sfsprintf(s, sizeof(dev) - 1, "%s %-*s %s%s%-*s pwd=%s%s%s", msgname(call), lz, mp->logical, up, pz ? " physical=" : "", pz, mp->physical ? mp->physical : "", state.pwd, mp->fs->attr, mp->attr); | ||||
| 	s[n] = 0; | ||||
| 	message((-2, "fs: %s: real: service=%-*s request=\"%s\"", fs->special, fs->servicesize, fs->service, s)); | ||||
| 	s[n++] = '\n'; | ||||
| 	if ((fd = fsfd(fs)) <= 0) | ||||
| 		return 0; | ||||
| 	s = state.path.name + PATH_MAX; | ||||
| 	if (write(fd, dev, n) != n || (n = csread(&cs, fd, s, PATH_MAX, CS_LINE)) <= 0) | ||||
| 	{ | ||||
| 		fsdrop(fs, 0); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	if (n <= 1) | ||||
| 		return 0; | ||||
| 	s[n - 1] = 0; | ||||
| 	if (s[0] >= 'A' && s[0] <= 'Z' && s[1] == ' ') | ||||
| 	{ | ||||
| 		message((-2, "fs: %s: real: %s", fs->special, s + 2)); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	message((-2, "fs: %s: real: path=%s", fs->special, s)); | ||||
| 	return s; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * do fs call | ||||
|  * -1 returned if not mounted | ||||
|  * 0 returned if mounted with state.ret call return value | ||||
|  * state.path.monitor set if monitor or name service mount | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fscall(register Mount_t* mp, long call, int ret, ...) | ||||
| { | ||||
| 	register Fs_t*		fs; | ||||
| 	register int		retry; | ||||
| 	register int		tries; | ||||
| 	const char*		up; | ||||
| 	const char*		sp; | ||||
| 	int			cd; | ||||
| 	int			fd; | ||||
| 	int			oerrno; | ||||
| 	int			m; | ||||
| 	long			n; | ||||
| 	File_t*			fp; | ||||
| 	Handler_t		handler; | ||||
| 	Msg_return_t*		rp; | ||||
| 	Msg_return_t		rv; | ||||
| 	void**			xp; | ||||
| 	void*			xv[2]; | ||||
| 	int*			ip; | ||||
| 	Msg_file_t		iv[2]; | ||||
| 	va_list			ap; | ||||
| 
 | ||||
| 	oerrno = errno; | ||||
| 	initialize(); | ||||
| 	state.ret = -1; | ||||
| 	if (state.in_2d) | ||||
| 		return -1; | ||||
| 	up = 0; | ||||
| 	/* proto workaround */ | ||||
| 	va_start(ap, ret); va_end(ap); | ||||
| 	if (!mp) | ||||
| 	{ | ||||
| 		state.path.monitor = 0; | ||||
| 		state.path.mount = 0; | ||||
| 		sp = 0; | ||||
| 		va_start(ap, ret); | ||||
| 		switch (MSG_ARG(call, 1)) | ||||
| 		{ | ||||
| 		case MSG_ARG_file: | ||||
| 			fd = va_arg(ap, int); | ||||
| 			if (fd < 0 || fd >= elementsof(state.file)) | ||||
| 				goto nope; | ||||
| 			if (!state.kernel && (mp = state.global) && !((fp = &state.file[fd])->flags & FILE_LOCK)) do | ||||
| 			{ | ||||
| 				if (fssys(mp, MSG_open) && ((fp->flags & FILE_OPEN) || !fileinit(fd, NiL, NiL, 0))) | ||||
| 				{ | ||||
| 					fs = mp->fs; | ||||
| 					if ((!(fs->flags & FS_REGULAR) || (fp->flags & FILE_REGULAR)) && (!(fs->flags & FS_WRITE) || (fp->flags & FILE_WRITE)) && ((mp->flags & MOUNT_PRIMARY) || fd > 2) && !(fp->open & (1<<(mp-state.mount)))) | ||||
| 						fsphony(mp, fp, fd); | ||||
| 				} | ||||
| 			} while (mp = mp->global); | ||||
| 			mp = fgetmount(fd); | ||||
| 			n = FS_ERROR|FS_INIT|FS_LOCK|FS_NAME|FS_ON; | ||||
| 			break; | ||||
| 		case MSG_ARG_string: | ||||
| 			sp = va_arg(ap, const char*); | ||||
| 			if (sp != state.path.name) | ||||
| 				sp = pathreal(sp, P_PATHONLY|P_ABSOLUTE, NiL); | ||||
| 			if (sp) mp = getmount(sp, &up); | ||||
| 			n = FS_ERROR|FS_INIT|FS_LOCK|FS_ON; | ||||
| 			break; | ||||
| 		} | ||||
| 		va_end(ap); | ||||
| 		if (!mp || ((fs = mp->fs)->flags & n) != FS_ON) | ||||
| 			goto nope; | ||||
| 		if (fs->flags & FS_MONITOR) | ||||
| 		{ | ||||
| 			if (!state.kernel && (fs->call & MSG_MASK(call))) | ||||
| 			{ | ||||
| 				if (sp && fs->match) | ||||
| 				{ | ||||
| 					if (fs->matchsize) | ||||
| 					{ | ||||
| 						cd = fs->match[fs->matchsize]; | ||||
| 						fs->match[fs->matchsize] = 0; | ||||
| 					} | ||||
| 					if (strmatch(sp, fs->match)) | ||||
| 						state.path.monitor = mp; | ||||
| 					if (fs->matchsize) | ||||
| 						fs->match[fs->matchsize] = cd; | ||||
| 				} | ||||
| 				else state.path.monitor = mp; | ||||
| 			} | ||||
| 			goto nope; | ||||
| 		} | ||||
| 	} | ||||
| 	else if (((fs = mp->fs)->flags & (FS_ERROR|FS_INIT|FS_LOCK|FS_ON)) != FS_ON) | ||||
| 		goto nope; | ||||
| 	if (!(fs->call & MSG_MASK(call))) | ||||
| 		goto nope; | ||||
| 	if (fs->flags & FS_MONITOR) | ||||
| 	{ | ||||
| 		if (state.kernel) | ||||
| 			goto nope; | ||||
| 		if (MSG_ARG(call, 1) == MSG_ARG_file) | ||||
| 		{ | ||||
| 			va_start(ap, ret); | ||||
| 			fd = va_arg(ap, int); | ||||
| 			va_end(ap); | ||||
| 			if (fd < 0 || fd >= elementsof(state.file)) | ||||
| 				goto nope; | ||||
| 			fp = &state.file[fd]; | ||||
| 			if (fp->flags & FILE_LOCK) | ||||
| 				goto nope; | ||||
| 			if (!(fp->flags & FILE_OPEN) && fileinit(fd, NiL, NiL, 0)) | ||||
| 				goto nope; | ||||
| 			if ((fs->flags & FS_REGULAR) && !(fp->flags & FILE_REGULAR) || (fs->flags & FS_WRITE) && !(fp->flags & FILE_WRITE)) | ||||
| 				goto nope; | ||||
| 			if (fssys(mp, MSG_open) && ((mp->flags & MOUNT_PRIMARY) || fd > 2) && !(fp->open & (1<<(mp-state.mount)))) | ||||
| 				fsphony(mp, fp, fd); | ||||
| 		} | ||||
| 		else if (call == MSG_open) | ||||
| 		{ | ||||
| 			if (fsmount(mp) < 0) | ||||
| 				goto nope; | ||||
| 			if (fs->flags & FS_WRITE) | ||||
| 			{ | ||||
| 				va_start(ap, ret); | ||||
| 				va_arg(ap, const char*); | ||||
| 				n = va_arg(ap, int); | ||||
| 				va_end(ap); | ||||
| 				if ((n & O_ACCMODE) == O_RDONLY) | ||||
| 					goto nope; | ||||
| 			} | ||||
| 		} | ||||
| 		if (MSG_ARG(call, 0) == MSG_ARG_file) | ||||
| 		{ | ||||
| 			fp = &state.file[ret]; | ||||
| 			fp->open |= (1<<(mp-state.mount)); | ||||
| 			rv.file = fp->id; | ||||
| 		} | ||||
| 		else rv.number = ret; | ||||
| 		rp = &rv; | ||||
| 	} | ||||
| 	else if (call == MSG_open) | ||||
| 	{ | ||||
| 		int	oflag; | ||||
| 		int	mode; | ||||
| 		int	level; | ||||
| 
 | ||||
| 		fs->flags |= FS_LOCK; | ||||
| 		va_start(ap, ret); | ||||
| 		sp = va_arg(ap, const char*); | ||||
| 		oflag = va_arg(ap, int); | ||||
| 		mode = va_arg(ap, int); | ||||
| 		level = va_arg(ap, int); | ||||
| 		va_end(ap); | ||||
| 		message((-3, "fs: %s: open: path=%s", fs->special, sp)); | ||||
| 		if (fs == &state.fs[FS_fd]) | ||||
| 		{ | ||||
| 			const char*	ep; | ||||
| 
 | ||||
| 			if ((fd = OPEN(sp, oflag, mode)) >= 0) | ||||
| 			{ | ||||
| 				state.ret = fd; | ||||
| 				goto unlock; | ||||
| 			} | ||||
| 			fd = strtol(up, (char**)&ep, 0); | ||||
| 			if (*ep) | ||||
| 			{ | ||||
| 				oerrno = ENOENT; | ||||
| 				goto unlock; | ||||
| 			} | ||||
| 			if ((n = FCNTL(fd, F_GETFL, 0)) < 0) | ||||
| 			{ | ||||
| 				oerrno = errno; | ||||
| 				goto unlock; | ||||
| 			} | ||||
| 			n &= O_ACCMODE; | ||||
| 			oflag &= O_ACCMODE; | ||||
| 			if (n == O_RDONLY && oflag == O_WRONLY || n == O_WRONLY && oflag == O_RDONLY) | ||||
| 			{ | ||||
| 				oerrno = EPERM; | ||||
| 				goto unlock; | ||||
| 			} | ||||
| 			if ((state.ret = FCNTL(fd, F_DUPFD, 0)) < 0) | ||||
| 				oerrno = errno; | ||||
| 		} | ||||
| 		else if ((sp = (const char*)fsreal(mp, MSG_open, up)) && (fd = fsfd(mp->fs)) > 0) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * /#<id>/[#]<path> for active fd's | ||||
| 			 * /#<id>\n written back to initialize | ||||
| 			 */ | ||||
| 
 | ||||
| 			if (sp[0] == '/' && sp[1] == '#') | ||||
| 			{ | ||||
| 				up = sp; | ||||
| 				if (!(sp = strchr(sp + 2, '/'))) | ||||
| 				{ | ||||
| 					sp = up; | ||||
| 					up = 0; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					m = sp - up; | ||||
| 					if (sp[1] == '#') | ||||
| 						sp += 2; | ||||
| 				} | ||||
| 			} | ||||
| 			else up = 0; | ||||
| 			if (streq(sp, DEVFD)) | ||||
| 			{ | ||||
| 				cd = -1; | ||||
| 				while (csrecv(&cs, fd, NiL, &cd, 1) != 1 && errno == EINTR); | ||||
| 				fd = cd; | ||||
| 			} | ||||
| 			else if ((fd = fs3d_open(sp, oflag, mode)) == -1) | ||||
| 				oerrno = errno; | ||||
| 			if (fd >= 0 && up) | ||||
| 			{ | ||||
| 				*((char*)up + m++) = '\n'; | ||||
| 				if (write(fd, up, m) != m) | ||||
| 					fd = -1; | ||||
| 				else | ||||
| 				{ | ||||
| 					if (fd > state.cache) | ||||
| 						state.cache = fd; | ||||
| 					fp = &state.file[fd]; | ||||
| 					fp->open = ~0; | ||||
| 					fp->flags = FILE_OPEN; | ||||
| 					fp->mount = mp; | ||||
| 				} | ||||
| 			} | ||||
| 			state.ret = fd; | ||||
| 		} | ||||
| 		goto unlock; | ||||
| 	} | ||||
| 	else | ||||
| 		rp = 0; | ||||
| 	if (fs->flags & FS_NAME) | ||||
| 	{ | ||||
| 		if (up && fs != &state.fs[FS_fd]) | ||||
| 		{ | ||||
| 			state.path.monitor = mp; | ||||
| 			state.path.mount = (char*)up; | ||||
| 		} | ||||
| 		goto nope; | ||||
| 	} | ||||
| 	if (MSG_MASK(call) & (MSG_MASK(MSG_close)|MSG_MASK(MSG_dup))) | ||||
| 		goto nope; | ||||
| 	message((-3, "fs: %s: %s: call", fs->special, msgname(call))); | ||||
| 	fs->flags |= FS_LOCK; | ||||
| 	if (fs->terse & MSG_MASK(call)) | ||||
| 	{ | ||||
| 		tries = MSG_ARG_CALL; | ||||
| 		for (;;) | ||||
| 		{ | ||||
| 			tries += MSG_ARG_TYPE; | ||||
| 			switch ((call >> tries) & ((1 << MSG_ARG_TYPE) - 1)) | ||||
| 			{ | ||||
| 			case 0: | ||||
| 				break; | ||||
| 			case MSG_ARG_output: | ||||
| 				if (!(fs->flags & FS_MONITOR)) break; | ||||
| 				/*FALLTHROUGH*/ | ||||
| 			case MSG_ARG_input: | ||||
| 			case MSG_ARG_vector: | ||||
| 				call = (call & ~(((1 << MSG_ARG_TYPE) - 1) << tries)) | (MSG_ARG_number << tries); | ||||
| 				continue; | ||||
| 			default: | ||||
| 				continue; | ||||
| 			} | ||||
| 			break; | ||||
| 		} | ||||
| 	} | ||||
| 	if (fs->flags & FS_ACTIVE) | ||||
| 	{ | ||||
| 		if (!(fs->flags & FS_MONITOR)) | ||||
| 			call |= MSG_RETURN; | ||||
| 		else if (fs->ack & MSG_MASK(call)) | ||||
| 			call |= (fs->flags & FS_INTERACTIVE) ? MSG_RETURN : MSG_ACK; | ||||
| 		retry = fs->retry; | ||||
| 	} | ||||
| 	else retry = 0; | ||||
| 	if ((fs->flags & FS_FLUSH) && (call |= MSG_FLUSH) || retry) | ||||
| 		handler = signal(SIGPIPE, SIG_IGN); | ||||
| 	tries = 1; | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		if ((cd = fsmount(mp)) < 0) | ||||
| 		{ | ||||
| 			message((-2, "fs: %s: %s: connect error on try %d", fs->special, msgname(call), tries)); | ||||
| 			goto unlock; | ||||
| 		} | ||||
| 		va_start(ap, ret); | ||||
| 		xp = xv; | ||||
| 		switch (MSG_ARG(call, 1)) | ||||
| 		{ | ||||
| 		case MSG_ARG_file: | ||||
| 			fd = va_arg(ap, int); | ||||
| 			if (!(fs->flags & FS_MONITOR)) | ||||
| 				cd = fd; | ||||
| 			*xp++ = (void*)&state.file[fd].id; | ||||
| 			break; | ||||
| 		case MSG_ARG_string: | ||||
| 			sp = va_arg(ap, const char*); | ||||
| 			if (MSG_VAR(call) == MSG_VAR_FILE) | ||||
| 			{ | ||||
| 				if (!(fs->flags & FS_MONITOR)) | ||||
| 					sp = up; | ||||
| 				else if (sp != state.path.name && !(sp = (const char*)pathreal(sp, P_PATHONLY|P_ABSOLUTE, NiL))) | ||||
| 					goto unlock; | ||||
| 			} | ||||
| 			*xp++ = (void*)sp; | ||||
| 			break; | ||||
| 		case MSG_ARG_output: | ||||
| 			if (call == MSG_pipe) | ||||
| 			{ | ||||
| 				ip = va_arg(ap, int*); | ||||
| 				for (n = 0; n < 2; n++) | ||||
| 				{ | ||||
| 					fp = &state.file[ip[n]]; | ||||
| 					if (!(fp->flags & FILE_OPEN)) | ||||
| 						fileinit(ip[n], NiL, NiL, 0); | ||||
| 					fp->open |= (1<<(mp-state.mount)); | ||||
| 					iv[n] = fp->id; | ||||
| 					*xp++ = (void*)iv; | ||||
| 				} | ||||
| 			} | ||||
| 			break; | ||||
| 		default: | ||||
| 			xp = 0; | ||||
| 			break; | ||||
| 		} | ||||
| 		if (xp) | ||||
| 		{ | ||||
| 			*xp = 0; | ||||
| 			xp = xv; | ||||
| 		} | ||||
| 		n = msgvcall(cd, MSG_CHANNEL(state.pid, mp->channel), call, rp, xp, ap); | ||||
| 		va_end(ap); | ||||
| 		if (n != -1) | ||||
| 			break; | ||||
| 		if (errno != EMSGIO) | ||||
| 		{ | ||||
| 			if (!(fs->flags & FS_MONITOR)) | ||||
| 				oerrno = errno; | ||||
| 			break; | ||||
| 		} | ||||
| 		message((-2, "fs: %s: %s: error on try %d", fs->special, msgname(call), tries)); | ||||
| 		if (tries++ > retry) | ||||
| 			break; | ||||
| 		fsdrop(fs, 0); | ||||
| 	} | ||||
| 	if ((fs->flags & FS_FLUSH) || retry) | ||||
| 		signal(SIGPIPE, handler); | ||||
| 	if (fs->flags & FS_ACTIVE) | ||||
| 	{ | ||||
| 		if ((state.ret = n) > 0 && (fs->flags & (FS_ACTIVE|FS_INTERACTIVE|FS_MONITOR)) == (FS_ACTIVE|FS_INTERACTIVE|FS_MONITOR) && (fs->ack & MSG_MASK(call))) | ||||
| 		{ | ||||
| 			char	buf[TABLE_MAX]; | ||||
| 
 | ||||
| 			if ((n = READ(cd, buf, sizeof(buf))) > 1) | ||||
| 			{ | ||||
| 				buf[n - 1] = 0; | ||||
| 				mapinit(buf, 0); | ||||
| 			} | ||||
| 			else message((-3, "fs: %s: %s: interactive ack failed", fs->special, msgname(call))); | ||||
| 		} | ||||
| 	} | ||||
| 	else if (!(fs->flags & FS_MONITOR)) | ||||
| 	{ | ||||
| 		oerrno = errno = ENODEV; | ||||
| 		message((-3, "fs: %s: %s: return: passive fs", fs->special, msgname(call))); | ||||
| 	} | ||||
| 	else if (fs->ack & MSG_MASK(call)) | ||||
| 	{ | ||||
| 		oerrno = errno = ENODEV; | ||||
| 		message((-3, "fs: %s: %s: ack: passive fs", fs->special, msgname(call))); | ||||
| 	} | ||||
| 	else state.ret = 0; | ||||
|  unlock: | ||||
| 	fs->flags &= ~FS_LOCK; | ||||
| 	errno = oerrno; | ||||
| 	return 0; | ||||
|  nope: | ||||
| 	errno = oerrno; | ||||
| 	return -1; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * initialize mounted fs and return device service fd | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fsinit(register Fs_t* fs, int fd) | ||||
| { | ||||
| 	int	n; | ||||
| 	int	oerrno; | ||||
| 
 | ||||
| 	if (fd < 0 && (fs->flags & (FS_BOUND|FS_ERROR|FS_INIT|FS_ON)) != (FS_BOUND|FS_ON) || state.kernel && (fs->flags & FS_GLOBAL)) | ||||
| 		return -1; | ||||
| 	oerrno = errno; | ||||
| 	fs->flags |= FS_INIT; | ||||
| 	if ((fs->flags & (FS_ON|FS_OPEN)) != (FS_ON|FS_OPEN)) | ||||
| 	{ | ||||
| 		state.kernel++; | ||||
| 		if ((fs->fd = fd) < 0) | ||||
| 		{ | ||||
| 			char*	svc; | ||||
| 			char	buf[PATH_MAX]; | ||||
| 
 | ||||
| 			if (n = fs->servicesize) | ||||
| 			{ | ||||
| 				if (n >= sizeof(buf)) n = sizeof(buf) - 1; | ||||
| 				svc = (char*)memcpy(buf, fs->service, n); | ||||
| 				svc[n] = 0; | ||||
| 			} | ||||
| 			else svc = fs->service; | ||||
| 			message((-3, "fs: %s: init#1: service=%s", fs->special, svc)); | ||||
| #if FS | ||||
| 			fs->fd = cslocal(&cs, svc); | ||||
| 			message((-3, "fs: %s: init#2: service=%s cslocal=%d", fs->special, svc, fs->fd)); | ||||
| 			if (fs->fd >= 0) | ||||
| 			{ | ||||
| 				if (fs->flags & FS_RECEIVE) | ||||
| 				{ | ||||
| 					n = csrecv(&cs, fs->fd, NiL, &fd, 1); | ||||
| 					CLOSE(fs->fd); | ||||
| 					fs->fd = n == 1 ? fd : -1; | ||||
| 				} | ||||
| 			} | ||||
| 			else if (errno == ENOENT) | ||||
| #endif | ||||
| 			fs->fd = fs3d_open(svc, O_CREAT|O_RDWR|O_APPEND, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); | ||||
| 		} | ||||
| 		if (fs->fd < 0 || FSTAT(fs->fd, &fs->st)) | ||||
| 		{ | ||||
| 			fs->fd = -1; | ||||
| 			fs->flags |= FS_ERROR; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			if (fs->flags & FS_CLOSE) | ||||
| 				FCNTL(fs->fd, F_SETFD, FD_CLOEXEC); | ||||
| 			if (S_ISREG(fs->st.st_mode)) | ||||
| 				fs->flags &= ~FS_ACTIVE; | ||||
| 			fs->flags |= FS_ON|FS_OPEN; | ||||
| 			reserve(&fs->fd); | ||||
| 			if (fd < 0) | ||||
| 				message((-3, "fs: %s: init#3: service=%-*s fd=%d cache=%d", fs->special, fs->servicesize ? fs->servicesize : strlen(fs->service), fs->service, fs->fd, state.cache)); | ||||
| 		} | ||||
| 		state.kernel--; | ||||
| 	} | ||||
| 	fs->flags &= ~FS_INIT; | ||||
| 	errno = oerrno; | ||||
| 	return fs->fd; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * drop internal 3d mount | ||||
|  * if clear!=0 then path binding also cleared | ||||
|  */ | ||||
| 
 | ||||
| void | ||||
| fsdrop(register Fs_t* fs, int clear) | ||||
| { | ||||
| 	int	oerrno; | ||||
| 
 | ||||
| 	state.kernel++; | ||||
| 	oerrno = errno; | ||||
| 	message((-3, "fs: %s: drop:%s", fs->special, clear ? " clear" : state.null)); | ||||
| 	if (fs->flags & FS_OPEN) | ||||
| 	{ | ||||
| 		fs->flags &= ~FS_OPEN; | ||||
| 		cancel(&fs->fd); | ||||
| 	} | ||||
| 	fs->flags &= ~FS_ERROR; | ||||
| 	if (clear) | ||||
| 	{ | ||||
| #if FS | ||||
| 		if (fs->flags & FS_FS) | ||||
| 		{ | ||||
| 			register int		n; | ||||
| 			register int		m; | ||||
| 			register Mount_t*	mp; | ||||
| 
 | ||||
| 			for (n = 0; n <= state.cache; n++) | ||||
| 				if ((mp = state.file[n].mount) && mp->fs == fs) | ||||
| 					state.file[n].mount = 0; | ||||
| 			for (n = m = 0; n < state.vmount.size; n++) | ||||
| 			{ | ||||
| 				if (((Mount_t*)state.vmount.table[n].val)->fs != fs) | ||||
| 				{ | ||||
| 					if (n != m) | ||||
| 						state.vmount.table[m] = state.vmount.table[n]; | ||||
| 					m++; | ||||
| 				} | ||||
| 				else if (state.vmount.table[n].valsize & T_ALLOCATE) | ||||
| 					free(state.vmount.table[n].key); | ||||
| 			} | ||||
| 			state.vmount.size = m; | ||||
| 			for (n = 0; n < elementsof(state.mount); n++) | ||||
| 				if (state.mount[n].fs == fs) | ||||
| 				{ | ||||
| 					state.mount[n].fs = 0; | ||||
| 					if (state.mount[n].physical && !state.mount[n].physicalsize) | ||||
| 					{ | ||||
| 						free(state.mount[n].physical); | ||||
| 						state.mount[n].physical = 0; | ||||
| 					} | ||||
| 				} | ||||
| 		} | ||||
| #endif | ||||
| 		if (fs->flags & FS_INTERNAL) fs->flags &= ~(FS_BOUND|FS_ON); | ||||
| 		else | ||||
| 		{ | ||||
| 			fs->flags = 0; | ||||
| 			if (fs->service && !fs->servicesize) | ||||
| 			{ | ||||
| 				free(fs->service); | ||||
| 				fs->service = 0; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	errno = oerrno; | ||||
| 	state.kernel--; | ||||
| } | ||||
|  | @ -1,134 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma noprototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide fstat | ||||
| #else | ||||
| #define fstat		______fstat | ||||
| #endif | ||||
| 
 | ||||
| #define _def_syscall_3d 1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide fstat | ||||
| #else | ||||
| #undef	fstat | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| /* the 3 arg _fxstat() disrupts our proto game -- every party needs one */ | ||||
| #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) | ||||
| int fstat3d(int fd, struct stat* st) | ||||
| #else | ||||
| #if defined(_FSTAT) | ||||
| int _fstat(fd, st) int fd; struct stat* st; { return fstat(fd, st); } | ||||
| #endif | ||||
| int fstat(fd, st) int fd; struct stat* st; | ||||
| #endif | ||||
| { | ||||
| 	int		oerrno; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!state.kernel) | ||||
| 	{ | ||||
| 		if (!fscall(NiL, MSG_fstat, 0, fd, st)) | ||||
| 			return state.ret; | ||||
| 		mp = monitored(); | ||||
| 	} | ||||
| #endif | ||||
| #ifdef _3D_STAT_VER | ||||
| 	if (FXSTAT(_3d_ver, fd, st)) | ||||
| 		return -1; | ||||
| #else | ||||
| 	if (FSTAT(fd, st)) | ||||
| 		return -1; | ||||
| #endif | ||||
| #if _mem_d_type_dirent | ||||
| 	if (S_ISDIR(st->st_mode)) | ||||
| 		st->st_nlink = _3D_LINK_MAX; | ||||
| #endif | ||||
| 	if (state.kernel) | ||||
| 		return 0; | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fstat, 0, fd, st); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fstat)) | ||||
| 			fscall(mp, MSG_fstat, 0, fd, st); | ||||
| #endif | ||||
| 	oerrno = errno; | ||||
| #ifdef _3D_STAT64_VER | ||||
| 	if (_3d_ver == _3D_STAT64_VER) | ||||
| 		IVIEW(((struct stat64*)st), getfdview(fd)); | ||||
| 	else | ||||
| #endif | ||||
| 	IVIEW(st, getfdview(fd)); | ||||
| 	errno = oerrno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #if defined(_LARGEFILE64_SOURCE) && defined(STAT643D) && !defined(_3D_STAT64_VER) | ||||
| 
 | ||||
| int | ||||
| fstat643d(int fd, struct stat64* st) | ||||
| { | ||||
| 	int		oerrno; | ||||
| 	struct stat	ss; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!state.kernel) | ||||
| 	{ | ||||
| 		if (!fscall(NiL, MSG_fstat, 0, fd, &ss)) | ||||
| 			return state.ret; | ||||
| 		mp = monitored(); | ||||
| 	} | ||||
| #endif | ||||
| 	if (FSTAT64(fd, st)) | ||||
| 		return -1; | ||||
| #if _mem_d_type_dirent | ||||
| 	if (S_ISDIR(st->st_mode)) | ||||
| 		st->st_nlink = _3D_LINK_MAX; | ||||
| #endif | ||||
| 	if (state.kernel) | ||||
| 		return 0; | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fstat, 0, fd, st); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fstat)) | ||||
| 			fscall(mp, MSG_fstat, 0, fd, st); | ||||
| #endif | ||||
| 	oerrno = errno; | ||||
| 	IVIEW(st, getfdview(fd)); | ||||
| 	errno = oerrno; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,176 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide fstatfs | ||||
| #else | ||||
| #define fstatfs        ______fstatfs | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if defined(fstatfs3d) && ( _sys_statfs || _sys_vfs || _sys_mount && _mem_f_files_statfs ) | ||||
| 
 | ||||
| #include <cs_lib.h> | ||||
| 
 | ||||
| #if _sys_statfs | ||||
| #include <sys/statfs.h> | ||||
| #else | ||||
| #if _sys_vfs | ||||
| #include <sys/vfs.h> | ||||
| #define _vfs_statfs	1 | ||||
| #else | ||||
| #if _sys_mount | ||||
| #if _lib_getmntinfo | ||||
| #include <sys/param.h>		/* expect some macro redefinitions here */ | ||||
| #endif | ||||
| #include <sys/mount.h> | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide fstatfs | ||||
| #else | ||||
| #undef  fstatfs | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| #if _vfs_statfs | ||||
| #define VFS	(fs) | ||||
| #else | ||||
| #define VFS	(&vfs) | ||||
| #endif | ||||
| 
 | ||||
| #if ARG3D_fstatfs == 4 | ||||
| 
 | ||||
| int | ||||
| fstatfs3d(int fd, struct statfs* fs, int size, int type) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #if !_vfs_statfs | ||||
| 	struct statvfs	vfs; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fstatfs, 0, fd, VFS, size, type)) | ||||
| 	{ | ||||
| #if !_vfs_statfs | ||||
| 		if (!state.ret) | ||||
| 		{ | ||||
| 			memset(fs, 0, sizeof(*fs)); | ||||
| 			fs->f_bsize = vfs.f_bsize; | ||||
| 			fs->f_blocks = vfs.f_blocks; | ||||
| 			fs->f_bfree = vfs.f_bfree; | ||||
| 			fs->f_files = vfs.f_files; | ||||
| 			fs->f_ffree = vfs.f_ffree; | ||||
| 		} | ||||
| #endif | ||||
| 		return state.ret; | ||||
| 	} | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FSTATFS(fd, fs, size, type)) | ||||
| 		return -1; | ||||
| #if FS | ||||
| #if !_vfs_statfs | ||||
| 	if (mp || state.global) | ||||
| 	{ | ||||
| 		memset(&vfs, 0, sizeof(vfs)); | ||||
| 		vfs.f_bsize = fs->f_bsize; | ||||
| 		vfs.f_blocks = fs->f_blocks; | ||||
| 		vfs.f_bfree = fs->f_bfree; | ||||
| 		vfs.f_files = fs->f_files; | ||||
| 		vfs.f_ffree = fs->f_ffree; | ||||
| 	} | ||||
| #endif | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fstatfs, 0, fd, VFS, size, type); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fstatfs)) | ||||
| 			fscall(mp, MSG_fstatfs, 0, fd, VFS, size, type); | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| int | ||||
| fstatfs3d(int fd, struct statfs* fs) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #if !_vfs_statfs | ||||
| 	struct statvfs	vfs; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fstatfs, 0, fd, VFS)) | ||||
| 	{ | ||||
| #if !_vfs_statfs | ||||
| 		if (!state.ret) | ||||
| 		{ | ||||
| 			memset(fs, 0, sizeof(*fs)); | ||||
| 			fs->f_bsize = vfs.f_bsize; | ||||
| 			fs->f_blocks = vfs.f_blocks; | ||||
| 			fs->f_bfree = vfs.f_bfree; | ||||
| 			fs->f_files = vfs.f_files; | ||||
| 			fs->f_ffree = vfs.f_ffree; | ||||
| 		} | ||||
| #endif | ||||
| 		return state.ret; | ||||
| 	} | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FSTATFS(fd, fs)) | ||||
| 		return -1; | ||||
| #if FS | ||||
| #if !_vfs_statfs | ||||
| 	if (mp || state.global) | ||||
| 	{ | ||||
| 		memset(&vfs, 0, sizeof(vfs)); | ||||
| 		vfs.f_bsize = fs->f_bsize; | ||||
| 		vfs.f_blocks = fs->f_blocks; | ||||
| 		vfs.f_bfree = fs->f_bfree; | ||||
| 		vfs.f_files = fs->f_files; | ||||
| 		vfs.f_ffree = fs->f_ffree; | ||||
| 	} | ||||
| #endif | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fstatfs, 0, fd, VFS); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fstatfs)) | ||||
| 			fscall(mp, MSG_fstatfs, 0, fd, VFS); | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fstatfs) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,56 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if defined(fstatvfs3d) && defined(_sys_statvfs) | ||||
| 
 | ||||
| #include <sys/statvfs.h> | ||||
| 
 | ||||
| int | ||||
| fstatvfs3d(int fd, struct statvfs* fs) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fstatfs, 0, fd, fs)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FSTATVFS(fd, fs)) | ||||
| 		return(-1); | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fstatfs, 0, fd, fs); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fstatfs)) | ||||
| 			fscall(mp, MSG_fstatfs, 0, fd, fs); | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fstatvfs) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,54 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef fsync3d | ||||
| 
 | ||||
| int | ||||
| fsync3d(int fd) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_fsync, 0, fd)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FSYNC(fd)) | ||||
| 		return(-1); | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_fsync, 0, fd); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_fsync)) | ||||
| 			fscall(mp, MSG_fsync, 0, fd); | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(fsync) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,104 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef ftruncate3d | ||||
| 
 | ||||
| #if !_nosys_ftruncate64 && _typ_off64_t | ||||
| 
 | ||||
| #undef	off_t | ||||
| #undef	ftruncate | ||||
| 
 | ||||
| typedef int (*Real_f)(int, off64_t); | ||||
| 
 | ||||
| int | ||||
| ftruncate64(int fd, off64_t size) | ||||
| { | ||||
| 	static Real_f	realf; | ||||
| 	int		r; | ||||
| 	int		n; | ||||
| 	int		m; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_ftruncate, 0, fd, size)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!realf) | ||||
| 		realf = (Real_f)sysfunc(SYS3D_ftruncate64); | ||||
| 	for (m = state.trap.size - 1; m >= 0; m--) | ||||
| 		if (MSG_MASK(MSG_truncate) & state.trap.intercept[m].mask) | ||||
| 			break; | ||||
| 	if (m >= 0) | ||||
| 	{ | ||||
| 		n = state.trap.size; | ||||
| 		state.trap.size = m; | ||||
| 		r = (*state.trap.intercept[m].call)(&state.trap.intercept[m], MSG_truncate, SYS3D_ftruncate64, (void*)fd, (void*)&size, NiL, NiL, NiL, NiL); | ||||
| 		state.trap.size = n; | ||||
| 	} | ||||
| 	else | ||||
| 		r = (*realf)(fd, size); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_ftruncate, 0, fd, size); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_ftruncate)) | ||||
| 				fscall(mp, MSG_ftruncate, 0, fd, size); | ||||
| 	} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| int | ||||
| ftruncate3d(int fd, off_t size) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_ftruncate, 0, fd, size)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (FTRUNCATE(fd, size)) | ||||
| 		return -1; | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_ftruncate, 0, fd, size); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_ftruncate)) | ||||
| 			fscall(mp, MSG_ftruncate, 0, fd, size); | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(ftruncate) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,90 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef	getdents3d | ||||
| 
 | ||||
| ssize_t | ||||
| getdents3d(int fd, void* buf, size_t n) | ||||
| { | ||||
| 	ssize_t		r; | ||||
| 
 | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_getdents, 0, fd, buf, n)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if ((r = GETDENTS(fd, buf, n)) >= 0) | ||||
| 	{ | ||||
| #if FS | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_getdents, r, fd, buf, n); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_getdents)) | ||||
| 				fscall(mp, MSG_getdents, r, fd, buf, n); | ||||
| #endif | ||||
| 	} | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(getdents) | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #ifdef	getdents643d | ||||
| 
 | ||||
| ssize_t | ||||
| getdents643d(int fd, void* buf, size_t n) | ||||
| { | ||||
| 	ssize_t		r; | ||||
| 
 | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_getdents, 0, fd, buf, n)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if ((r = GETDENTS64(fd, buf, n)) >= 0) | ||||
| 	{ | ||||
| #if FS | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_getdents, r, fd, buf, n); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_getdents)) | ||||
| 				fscall(mp, MSG_getdents, r, fd, buf, n); | ||||
| #endif | ||||
| 	} | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(getdents64) | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										1714
									
								
								src/cmd/3d/init.c
									
										
									
									
									
								
							
							
						
						
									
										1714
									
								
								src/cmd/3d/init.c
									
										
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							|  | @ -1,49 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef	kill3d | ||||
| 
 | ||||
| int | ||||
| kill3d(pid_t pid, int sig) | ||||
| { | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| #endif | ||||
| 	if (KILL(pid, sig)) | ||||
| 		return(-1); | ||||
| #if FS | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_kill)) | ||||
| 			fscall(mp, MSG_kill, 0, pid, sig); | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(kill) | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										515
									
								
								src/cmd/3d/lib.c
									
										
									
									
									
								
							
							
						
						
									
										515
									
								
								src/cmd/3d/lib.c
									
										
									
									
									
								
							|  | @ -1,515 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d file system library implementation | ||||
|  * | ||||
|  * debug trace levels are controlled by /#option/debug | ||||
|  * debug level n enables tracing for all levels less than or equal to n | ||||
|  * | ||||
|  *	level	trace | ||||
|  *	  0	no trace | ||||
|  *	  1	basic calls | ||||
|  *	  2	mounted fs | ||||
|  *	  3	fs control | ||||
|  *	  4	pathcanon | ||||
|  *	  5	pathreal | ||||
|  *	  6	pathnext | ||||
|  *	  7	*unused* | ||||
|  *	  8	*unused* | ||||
|  *	  9	*unused* | ||||
|  *	 10	getkey | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #include <cs.h> | ||||
| 
 | ||||
| /*
 | ||||
|  * keep 3d tables from buf,siz in state.table.fd | ||||
|  * if force!=0 then state.table.fd set to TABLE_FD | ||||
|  * 0 returned if state.table.fd is ok | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| keep(const char* buf, size_t siz, int force) | ||||
| { | ||||
| 	int	n; | ||||
| 
 | ||||
| 	if (force && state.in_2d || siz > sizeof(state.table.buf)) | ||||
| 	{ | ||||
| 		if (state.table.fd > 0) | ||||
| 			cancel(&state.table.fd); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	if (state.table.fd > 0) | ||||
| 	{ | ||||
| 		char	tmp[sizeof(state.table.buf)]; | ||||
| 
 | ||||
| 		if (peek(state.table.fd, tmp, sizeof(tmp) - 1) == siz && !memcmp(tmp, buf, siz)) | ||||
| 			return(0); | ||||
| 		cancel(&state.table.fd); | ||||
| 	} | ||||
| #if _stream_peek || _socket_peek | ||||
| 	{ | ||||
| 		int	fds[2]; | ||||
| 
 | ||||
| 		state.in_2d++; | ||||
| #if _socket_peek | ||||
| 		n = cspipe(&cs, fds); | ||||
| #else | ||||
| 		n = pipe(fds); | ||||
| #endif | ||||
| 		state.in_2d--; | ||||
| 		if (!n && fds[1] == TABLE_FD) | ||||
| 		{ | ||||
| #if _pipe_rw || _lib_socketpair | ||||
| 			fds[1] = fds[0]; | ||||
| 			fds[0] = TABLE_FD; | ||||
| #else | ||||
| 			CLOSE(fds[0]); | ||||
| 			state.in_2d++; | ||||
| 			n = pipe(fds); | ||||
| 			state.in_2d--; | ||||
| 			CLOSE(TABLE_FD); | ||||
| #endif | ||||
| 		} | ||||
| 		if (!n) | ||||
| 		{ | ||||
| 			if (fds[0] == TABLE_FD) state.table.fd = fds[0]; | ||||
| 			else | ||||
| 			{ | ||||
| 				if (force) CLOSE(TABLE_FD); | ||||
| 				state.table.fd = FCNTL(fds[0], F_DUPFD, TABLE_FD); | ||||
| 				CLOSE(fds[0]); | ||||
| 			} | ||||
| 			n = WRITE(fds[1], buf, siz) == siz; | ||||
| 			CLOSE(fds[1]); | ||||
| 			if (n) | ||||
| 			{ | ||||
| 				state.table.size = siz; | ||||
| 				reserve(&state.table.fd); | ||||
| 				return(0); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| #else | ||||
| 	sfsprintf(state.path.name, sizeof(state.path.name), "/tmp/3D#%d", state.pid); | ||||
| 	if ((n = OPEN(state.path.name, O_CREAT, S_IRUSR|S_IRGRP|S_IROTH)) >= 0) | ||||
| 	{ | ||||
| 		UNLINK(state.path.name); | ||||
| 		if (force) CLOSE(TABLE_FD); | ||||
| 		if (n == TABLE_FD) state.table.fd = TABLE_FD; | ||||
| 		else | ||||
| 		{ | ||||
| 			state.table.fd = FCNTL(n, F_DUPFD, TABLE_FD); | ||||
| 			CLOSE(n); | ||||
| 		} | ||||
| 		if (WRITE(state.table.fd, buf, siz) == siz && !LSEEK(state.table.fd, 0L, 0)) | ||||
| 		{ | ||||
| 			state.table.size = siz; | ||||
| 			reserve(&state.table.fd); | ||||
| 			return(0); | ||||
| 		} | ||||
| 	} | ||||
| #endif | ||||
| 	if (state.table.fd > 0) | ||||
| 		cancel(&state.table.fd); | ||||
| 	return(-1); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * enable/disable/test 3d/anno state | ||||
|  * allows state transitions without changing the tables | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fs3d(register int op) | ||||
| { | ||||
| 	register int	po; | ||||
| 	register int	n; | ||||
| 
 | ||||
| 	if ((n = FS3D_op(op)) == FS3D_OP_INIT || !state.pid) | ||||
| 		init(1, 0, 0); | ||||
| 	if (!state.in_2d) | ||||
| 		po = FS3D_ON; | ||||
| 	else if (state.limit != TABSIZE) | ||||
| 		po = FS3D_LIMIT(state.limit); | ||||
| 	else | ||||
| 		po = FS3D_OFF; | ||||
| 	switch (n) | ||||
| 	{ | ||||
| 	case FS3D_OP_INIT: | ||||
| 	case FS3D_OP_TEST: | ||||
| 		break; | ||||
| 	case FS3D_OP_LIMIT: | ||||
| 		if ((n = FS3D_arg(op)) <= 0 || n > TABSIZE) | ||||
| 			n = TABSIZE; | ||||
| 		state.limit = n; | ||||
| 		state.in_2d = 0; | ||||
| 		break; | ||||
| 	case FS3D_OP_OFF: | ||||
| 		if (state.level > 0) | ||||
| 			po = -1; | ||||
| 		else | ||||
| 		{ | ||||
| 			state.limit = TABSIZE; | ||||
| 			state.in_2d = 1; | ||||
| 		} | ||||
| 		break; | ||||
| 	case FS3D_OP_ON: | ||||
| 		state.limit = TABSIZE; | ||||
| 		state.in_2d = 0; | ||||
| 		break; | ||||
| 	default: | ||||
| 		po = -1; | ||||
| 		break; | ||||
| 	} | ||||
| 	message((-1, "fs3d(%d)=%d", op, po)); | ||||
| 	return po; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * for code that includes <fs3d.h> | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fs3d_mount(const char* source, char* target, int flags, void* data) | ||||
| { | ||||
| 	return mount(source, target, flags, data, 0, 0); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * return 6 char lower case hash of key | ||||
|  * end is end of key string | ||||
|  * 0 returned at end of keys | ||||
|  * state.key.value is set to key value | ||||
|  * if `no<key>' then state.key.invert gets value and state.key.value="" | ||||
|  * otherwise state.key.invert=0 | ||||
|  * state.key.next is set to next key if any | ||||
|  */ | ||||
| 
 | ||||
| unsigned long | ||||
| getkey(register const char* key, register const char* end, int alt) | ||||
| { | ||||
| 	register const char*	val; | ||||
| 	register unsigned long	x = 0; | ||||
| 	register int		invert; | ||||
| 	register int		c; | ||||
| #if DEBUG | ||||
| 	const char*		beg; | ||||
| #endif | ||||
| 
 | ||||
| 	if (key) | ||||
| 	{ | ||||
| #if DEBUG | ||||
| 		beg = key; | ||||
| #endif | ||||
| 		if (key < end - 1 && *key == 'n' && *(key + 1) == 'o') | ||||
| 		{ | ||||
| 			key += 2; | ||||
| 			invert = 1; | ||||
| 		} | ||||
| 		else invert = 0; | ||||
| 		if (key < end) | ||||
| 		{ | ||||
| 			val = ((end - key) > HASHKEYMAX) ? key + HASHKEYMAX : end; | ||||
| 			while (key < end && (c = *key) != '=' && c != '/' && c != alt) | ||||
| 			{ | ||||
| 				if (key < val) | ||||
| 					x = (c >= '0' && c <= '9') ? HASHKEYPART(x, HASHKEYN(c)) : HASHKEYPART(x, c); | ||||
| 				key++; | ||||
| 			} | ||||
| 			if (key < end && c == '=') | ||||
| 				key++; | ||||
| 		} | ||||
| 		if (key >= end || *key == '/' || *key == alt) | ||||
| 		{ | ||||
| 			state.key.value = state.one; | ||||
| 			state.key.valsize = 1; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			state.key.value = (char*)key; | ||||
| 			while (key < end && *key != '/' && *key != alt) | ||||
| 				key++; | ||||
| 			state.key.valsize = (char*)key - state.key.value; | ||||
| 		} | ||||
| 		while (key < end && (*key == '/' || *key == alt)) | ||||
| 			key++; | ||||
| 		if (key < end && *key == '#' && *(key - 1) == '/') | ||||
| 			key++; | ||||
| 		if (invert) | ||||
| 		{ | ||||
| 			state.key.invert = state.key.value; | ||||
| 			state.key.invertsize = state.key.valsize; | ||||
| 			state.key.value = state.null; | ||||
| 			state.key.valsize = 0; | ||||
| 		} | ||||
| 		else state.key.invert = 0; | ||||
| 		state.key.next = (key < end) ? (char*)key : (char*)0; | ||||
| 		message((-10, "getkey: key=%-*s hash=%x value=%-*s next=%-*s", end - beg, beg, x, state.key.valsize, state.key.value, state.key.next ? end - state.key.next : 6, state.key.next)); | ||||
| 	} | ||||
| 	else state.key.next = 0; | ||||
| 	return(x); | ||||
| } | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| /*
 | ||||
|  * return mount pointer for path | ||||
|  * under is set to the part of the path under the mount | ||||
|  */ | ||||
| 
 | ||||
| Mount_t* | ||||
| getmount(register const char* path, const char** under) | ||||
| { | ||||
| 	register Map_t*	map; | ||||
| 	int		n; | ||||
| 	int		oerrno; | ||||
| 	struct stat	st; | ||||
| 
 | ||||
| 	if (!(map = search(&state.vmount, path, strlen(path), NiL, T_PREFIX)) || ((Mount_t*)map->val)->fs == state.fs) | ||||
| 		return(0); | ||||
| 	if (under) | ||||
| 	{ | ||||
| 		if (*(path += map->keysize)) path++; | ||||
| 		else | ||||
| 		{ | ||||
| 			oerrno = errno; | ||||
| 			n = !STAT(path - map->keysize, &st) && !S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode); | ||||
| 			errno = oerrno; | ||||
| 			if (n) return(0); | ||||
| 			else path = (const char*)state.dot; | ||||
| 		} | ||||
| 		*under = path; | ||||
| 	} | ||||
| 	return((Mount_t*)map->val); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| int | ||||
| nosys(void) | ||||
| { | ||||
| 	errno = EINVAL; | ||||
| 	return(-1); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * copy t into s, return a pointer to the end of s ('\0') | ||||
|  */ | ||||
| 
 | ||||
| char* | ||||
| strcopy(register char* s, register const char* t) | ||||
| { | ||||
| 	if (!t) return(s); | ||||
| 	while (*s++ = *t++); | ||||
| 	return(--s); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * return map for <key,keysize> in tab | ||||
|  * if val!=0 then key=val inserted if not already entered | ||||
|  * valsize==0 causes string val to be malloc'd on insertion | ||||
|  * key is malloc'd on insertion if (valsize|T_ALLOCATE)  | ||||
|  * valsize==T_DELETE for deletion | ||||
|  * valsize==T_PREFIX for longest path prefix search and val==visit_mask | ||||
|  */ | ||||
| 
 | ||||
| Map_t* | ||||
| search(Table_t* tab, const char* key, int keysize, const char* val, int valsize) | ||||
| { | ||||
| 	register Map_t*		lo; | ||||
| 	register Map_t*		mid; | ||||
| 	register Map_t*		hi; | ||||
| 	register const char*	sp; | ||||
| 	register const char*	se; | ||||
| 	register const char*	tp; | ||||
| 	register const char*	te; | ||||
| 	int			n; | ||||
| 	Map_t*			end; | ||||
| 
 | ||||
| 	se = key + keysize; | ||||
| 	lo = tab->table; | ||||
| 	end = lo + tab->size; | ||||
| 	if (valsize == T_PREFIX) | ||||
| 	{ | ||||
| 		mid = 0; | ||||
| 		hi = end; | ||||
| 		while (lo < hi) | ||||
| 		{ | ||||
| 			sp = key; | ||||
| 			tp = lo->key; | ||||
| 			te = tp + lo->keysize; | ||||
| message((-12, "T_PREFIX: %-*s: key=%-*s mid=%-*s", keysize, key, lo->keysize, lo->key, mid ? mid->keysize : 1, mid ? mid->key : "-")); | ||||
| 			for (;;) | ||||
| 			{ | ||||
| 				if (tp >= te) | ||||
| 				{ | ||||
| 					if ((sp >= se || *sp == '/') && (!val || !(*((long*)val) & (1 << (lo - tab->table))))) | ||||
| 					{ | ||||
| 						mid = lo; | ||||
| 						if (sp >= se) | ||||
| 							goto prefix; | ||||
| 					} | ||||
| 					break; | ||||
| 				} | ||||
| 				if (sp >= se || (n = *((unsigned char*)sp++) - *((unsigned char*)tp++)) < 0) | ||||
| 					goto prefix; | ||||
| 				if (n > 0) | ||||
| 				{ | ||||
| 					if (mid && mid->keysize >= (sp - key)) | ||||
| 						goto prefix; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 			lo++; | ||||
| 		} | ||||
| 	prefix: | ||||
| 		if (mid && val) *((long*)val) |= (1 << (mid - tab->table)); | ||||
| 		return(mid); | ||||
| 	} | ||||
| 	if (end > lo) | ||||
| 	{ | ||||
| 		hi = end - 1; | ||||
| 		while (lo <= hi) | ||||
| 		{ | ||||
| 			mid = lo + (hi - lo) / 2; | ||||
| 			sp = key; | ||||
| 			tp = mid->key; | ||||
| 			te = tp + mid->keysize; | ||||
| 			for (;;) | ||||
| 			{ | ||||
| 				if (tp >= te) | ||||
| 				{ | ||||
| 					if (sp >= se) | ||||
| 					{ | ||||
| 						if (valsize != T_DELETE) | ||||
| 							return(mid); | ||||
| 						if (mid->valsize & T_ALLOCATE) | ||||
| 							free(mid->key); | ||||
| #if FS | ||||
| 						if ((mid->valsize & T_SIZE) == T_MOUNT) | ||||
| 							((Mount_t*)mid->val)->fs = 0; | ||||
| 						else | ||||
| #endif | ||||
| 						if (!(mid->valsize & T_SIZE)) | ||||
| 							free(mid->val); | ||||
| 						for (; mid < end; mid++) | ||||
| 							*mid = *(mid + 1); | ||||
| 						tab->size--; | ||||
| 						return(0); | ||||
| 					} | ||||
| 					lo = mid + 1; | ||||
| 					break; | ||||
| 				} | ||||
| 				if (sp >= se || (n = *((unsigned char*)sp++) - *((unsigned char*)tp++)) < 0) | ||||
| 				{ | ||||
| 					hi = mid - 1; | ||||
| 					break; | ||||
| 				} | ||||
| 				if (n > 0) | ||||
| 				{ | ||||
| 					lo = mid + 1; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	if (!val || valsize == T_DELETE || tab->size >= elementsof(tab->table)) | ||||
| 		return(0); | ||||
| 	tab->size++; | ||||
| 	for (hi = end; hi > lo; hi--) | ||||
| 		*hi = *(hi - 1); | ||||
| 	lo->keysize = keysize; | ||||
| 	if (valsize & T_ALLOCATE) lo->key = strcpy(newof(0, char, keysize, 1), key); | ||||
| 	else lo->key = (char*)key; | ||||
| 	if ((lo->valsize = valsize) & T_SIZE) lo->val = (char*)val; | ||||
| 	else lo->val = strcpy(newof(0, char, strlen(val), 1), val); | ||||
| 	return(lo); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * iterate fun over tab | ||||
|  * terminates on first negative return from fun | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| iterate(register Table_t* tab, int (*fun)(Map_t*, char*, int), register char* buf, int flags) | ||||
| { | ||||
| 	register Map_t*	cp; | ||||
| 	register Map_t*	ep; | ||||
| 	register int	n; | ||||
| 	register int	sum; | ||||
| 
 | ||||
| 	sum = 0; | ||||
| 	for (ep = (cp = tab->table) + tab->size; cp < ep; cp++) | ||||
| 	{ | ||||
| 		if ((n = (*fun)(cp, buf, flags)) < 0) | ||||
| 			return(0); | ||||
| 		if (buf) buf += n; | ||||
| 		sum += n; | ||||
| 	} | ||||
| 	return(sum); | ||||
| } | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| /*
 | ||||
|  * initialize open file info | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fileinit(int fd, struct stat* st, Mount_t* mp, int force) | ||||
| { | ||||
| 	register File_t*	f; | ||||
| 	int			ffd; | ||||
| 	int			ffl; | ||||
| 	struct stat		sb; | ||||
| 
 | ||||
| 	f = state.file + fd; | ||||
| 	if (!force && (f->flags & FILE_ERROR) || !st && FSTAT(fd, st = &sb) || (ffd = FCNTL(fd, F_GETFD, NiL)) == -1 || (ffl = FCNTL(fd, F_GETFL, NiL)) == -1) | ||||
| 	{ | ||||
| 		f->flags = FILE_ERROR; | ||||
| 		return -1; | ||||
| 	} | ||||
| 	f->oflag = ffl; | ||||
| 	f->open = 0; | ||||
| 	f->flags = FILE_OPEN; | ||||
| 	if (S_ISREG(st->st_mode)) | ||||
| 		f->flags |= FILE_REGULAR; | ||||
| 	if (ffd & FD_CLOEXEC) | ||||
| 		f->flags |= FILE_CLOEXEC; | ||||
| 	if ((ffl & O_ACCMODE) != O_RDONLY) | ||||
| 		f->flags |= FILE_WRITE; | ||||
| 	f->id.fid[0] = st->st_ino; | ||||
| 	f->id.fid[1] = st->st_dev; | ||||
| 	if ((f->mount = mp) && fd > state.cache) | ||||
| 		state.cache = fd; | ||||
| 	if (fd > state.open) | ||||
| 		state.open = fd; | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,90 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| /*
 | ||||
|  * 3d symbol mappings to minimize pollution | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _NAME3D_H | ||||
| #define _NAME3D_H | ||||
| 
 | ||||
| #include "ast_3d.h" | ||||
| #include "cs_3d.h" | ||||
| #include "dll_3d.h" | ||||
| #include "std_3d.h" | ||||
| 
 | ||||
| #define bprintf		_3d_printf | ||||
| #define bvprintf	_3d_vprintf | ||||
| #define calldump	_3d_calldump | ||||
| #define callinit	_3d_callinit | ||||
| #define checklink	_3d_checklink | ||||
| #define control		_3d_control | ||||
| #define error		_3d_error | ||||
| #define _error_data_	_3d_error_data /*AHA*/ | ||||
| #define _error_info_	_3d_error_info | ||||
| #define _error_infop_	_3d_error_infop | ||||
| #define errorf		_3d_errorf | ||||
| #define errormsg	_3d_errormsg | ||||
| #define errorv		_3d_errorv | ||||
| #define fileinit	_3d_fileinit | ||||
| #define fix		_3d_fix | ||||
| #define forked		_3d_forked | ||||
| #define fs3d_copy	_3d_copy | ||||
| #define fs3d_dup	_3d_dup | ||||
| #define fs3d_mkdir	_3d_mkdir | ||||
| #define fs3d_open	_3d_open | ||||
| #define fscall		_3d_fscall | ||||
| #define fschannel	_3d_fschannel | ||||
| #define fsdrop		_3d_fsdrop | ||||
| #define fsinit		_3d_fsinit | ||||
| #define fsreal		_3d_fsreal | ||||
| #define getattr		_3d_getattr | ||||
| #define getkey		_3d_getkey | ||||
| #define getmount	_3d_getmount | ||||
| #define init		_3d_init | ||||
| #define instance	_3d_instance | ||||
| #define intercept	_3d_intercept | ||||
| #define iterate		_3d_iterate | ||||
| #define keep		_3d_keep | ||||
| #define mapdump		_3d_mapdump | ||||
| #define mapget		_3d_mapget | ||||
| #define mapinit		_3d_mapinit | ||||
| #define mapset		_3d_mapset | ||||
| #define nosys		_3d_nosys | ||||
| #define pathreal	_3d_pathreal | ||||
| #define peek		_3d_peek | ||||
| #define search		_3d_search | ||||
| #define setattr		_3d_setattr | ||||
| #define state		_3d_state | ||||
| #define strcopy		_3d_strcopy | ||||
| #define stub		_3d_stub | ||||
| #define syscall3d	_3d_syscall | ||||
| #define sysfunc		_3d_sysfunc | ||||
| 
 | ||||
| #include <ast.h> | ||||
| 
 | ||||
| #undef	pathcanon | ||||
| #define pathcanon	_3d_pathcanon | ||||
| #undef	pathcat | ||||
| #define pathcat		_3d_pathcat | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,95 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d license via agent to license server | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if LICENSED | ||||
| 
 | ||||
| #define LICENSE_OPEN(s,m,l)	licopen(s,m,l) | ||||
| #define LICENSE_CLOSE(f)	close(f) | ||||
| 
 | ||||
| static int | ||||
| licopen(const char* svc, const char* msg, int len) | ||||
| { | ||||
| 	char*	service; | ||||
| 	char*	env; | ||||
| 	int	n; | ||||
| 	int	fd; | ||||
| 	int	lic; | ||||
| 	char	buf[64]; | ||||
| 
 | ||||
| 	if (state.in_2d) return(-1); | ||||
| 	service = "/dev/fdp/local/nam/user"; | ||||
| 	env = *environ; | ||||
| 	*environ = "_3D_DISABLE=1"; | ||||
| 	if ((fd = cslocal(&cs, service)) < 0) | ||||
| 	{ | ||||
| 		error(ERROR_SYSTEM|2, "%s: cannot connect to server", service); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	*environ = env; | ||||
| 	n = strlen(svc) + 1; | ||||
| 	if (cswrite(&cs, fd, svc, n) != n) | ||||
| 	{ | ||||
| 		error(ERROR_SYSTEM|2, "%s: cannot write to server", service); | ||||
| 		close(fd); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	if (read(fd, buf, sizeof(buf)) <= 0) | ||||
| 	{ | ||||
| 		error(ERROR_SYSTEM|2, "%s: cannot read from server", service); | ||||
| 		close(fd); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	if (csrecv(&cs, fd, NiL, &lic, 1) != 1) | ||||
| 	{ | ||||
| 		error(ERROR_SYSTEM|2, "%s: cannot connect to %s", service, svc); | ||||
| 		close(fd); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	close(fd); | ||||
| 	if (cswrite(&cs, lic, msg, len) != len) | ||||
| 	{ | ||||
| 		error(ERROR_SYSTEM|2, "%s: cannot write to service", svc); | ||||
| 		close(lic); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	fcntl(lic, F_SETFD, FD_CLOEXEC); | ||||
| 	state.in_2d = 0; | ||||
| 	return(lic); | ||||
| } | ||||
| 
 | ||||
| #define tokscan		_3d_tokscan | ||||
| 
 | ||||
| #include "tokscan.c" | ||||
| #include "../license/service.c" | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(license) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,99 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef link3d | ||||
| 
 | ||||
| int | ||||
| link3d(const char* path, const char* target) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register char*	tp; | ||||
| 	register int	r; | ||||
| 	char*		t; | ||||
| 	int		oerrno; | ||||
| 	char		buf[PATH_MAX+1]; | ||||
| #if FS | ||||
| 	char		tmp[PATH_MAX+1]; | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.in_2d) | ||||
| 		return(LINK(path, target)); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_link, 0, path, target)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, state.safe ? (P_SAFE|P_TOP) : P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	sp = strncpy(buf, sp, PATH_MAX); | ||||
| 	if (!(tp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_SAFE, NiL))) | ||||
| 		return(-1); | ||||
| 	oerrno = errno; | ||||
| 	if ((r = LINK(sp, tp)) && errno == ENOENT && (t = strrchr(tp, '/'))) | ||||
| 	{ | ||||
| 		*t = 0; | ||||
| 		r = fs3d_mkdir(tp, S_IRWXU|S_IRWXG|S_IRWXO); | ||||
| 		*t = '/'; | ||||
| 		if (!r) | ||||
| 		{ | ||||
| 			errno = oerrno; | ||||
| 			r = LINK(sp, tp); | ||||
| 		} | ||||
| 	} | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp && !LSTAT(tp, &state.path.st)) | ||||
| 		{ | ||||
| 			if (tp != tmp) | ||||
| 			{ | ||||
| 				if (!(tp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_ABSOLUTE, NiL))) | ||||
| 					return(r); | ||||
| 				tp = strncpy(tmp, tp, PATH_MAX); | ||||
| 			} | ||||
| 			fscall(mp, MSG_link, 0, sp, tp); | ||||
| 		} | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_link)) | ||||
| 			{ | ||||
| 				if (tp != tmp) | ||||
| 				{ | ||||
| 					if (!(tp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_ABSOLUTE, NiL))) | ||||
| 						return(r); | ||||
| 					tp = strncpy(tmp, tp, PATH_MAX); | ||||
| 				} | ||||
| 				fscall(mp, MSG_link, 0, sp, tp); | ||||
| 			} | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(link) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,134 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide lseek | ||||
| #else | ||||
| #define lseek        ______lseek | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| #define _LS_H		1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide lseek | ||||
| #else | ||||
| #undef  lseek | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| #ifdef	lseek3d | ||||
| 
 | ||||
| #if !_nosys_lseek64 && _typ_off64_t | ||||
| 
 | ||||
| typedef off64_t (*Seek64_f)(int, off64_t, int); | ||||
| 
 | ||||
| #undef	off_t | ||||
| #undef	lseek | ||||
| 
 | ||||
| off64_t | ||||
| lseek64(int fd, off64_t off, int op) | ||||
| { | ||||
| 	off64_t		r; | ||||
| 	int		n; | ||||
| 	int		m; | ||||
| 
 | ||||
| 	static Seek64_f	seekf; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_seek, 0, fd, off, op)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!seekf) | ||||
| 		seekf = (Seek64_f)sysfunc(SYS3D_lseek64); | ||||
| 	for (m = state.trap.size - 1; m >= 0; m--) | ||||
| 		if (MSG_MASK(MSG_seek) & state.trap.intercept[m].mask) | ||||
| 			break; | ||||
| 	if (m >= 0) | ||||
| 	{ | ||||
| 		n = state.trap.size; | ||||
| 		state.trap.size = m; | ||||
| 		r = (*state.trap.intercept[m].call)(&state.trap.intercept[m], MSG_seek, SYS3D_lseek64, (void*)fd, (void*)&off, (void*)op, NiL, NiL, NiL) ? -1 : off; | ||||
| 		state.trap.size = n; | ||||
| 	} | ||||
| 	else | ||||
| 		r = (*seekf)(fd, off, op); | ||||
| #if FS | ||||
| 	if (r != (off64_t)(-1)) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_seek, r, fd, off, op); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_seek)) | ||||
| 				fscall(mp, MSG_seek, r, fd, off, op); | ||||
| 	} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| typedef off_t (*Seek_f)(int, off_t, int); | ||||
| 
 | ||||
| off_t | ||||
| lseek3d(int fd, off_t off, int op) | ||||
| { | ||||
| 	off_t		r; | ||||
| 
 | ||||
| 	static Seek_f	seekf; | ||||
| 
 | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_seek, 0, fd, off, op)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (sizeof(off_t) > sizeof(long)) | ||||
| 	{ | ||||
| 		if (!seekf) | ||||
| 			seekf = (Seek_f)sysfunc(SYS3D_lseek); | ||||
| 		r = (*seekf)(fd, off, op); | ||||
| 	} | ||||
| 	else if ((r = LSEEK(fd, off, op)) == -1) | ||||
| 		return -1; | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_seek, r, fd, off, op); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_seek)) | ||||
| 			fscall(mp, MSG_seek, r, fd, off, op); | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(lseek) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,128 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma noprototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if defined(lstat3d) | ||||
| 
 | ||||
| /* the 3 arg _lxstat() disrupts our proto game -- every party needs one */ | ||||
| #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) | ||||
| int lstat3d(const char* path, struct stat* st) | ||||
| #else | ||||
| #if defined(_LSTAT) | ||||
| int _lstat(path, st) char* path; struct stat* st; { return lstat(path, st); } | ||||
| #endif | ||||
| int lstat(path, st) char* path; struct stat* st; | ||||
| #endif | ||||
| { | ||||
| 	register char*	sp; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| #ifdef _3D_STAT_VER | ||||
| 	struct stat*	so; | ||||
| 	struct stat	sc; | ||||
| #endif | ||||
| 
 | ||||
| #ifdef _3D_STAT_VER | ||||
| 	if (_3d_ver != _3D_STAT_VER) | ||||
| 	{ | ||||
| 		so = st; | ||||
| 		st = ≻ | ||||
| 	} | ||||
| #endif | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_lstat, 0, path, st)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_LSTAT, st))) | ||||
| 		return -1; | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_lstat, 0, state.path.name, st); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_lstat)) | ||||
| 			fscall(mp, MSG_lstat, 0, state.path.name, st); | ||||
| #endif | ||||
| #ifdef _3D_STAT_VER | ||||
| 	if (st == &sc) | ||||
| 	{ | ||||
| 		st = so; | ||||
| 		if (LXSTAT(_3d_ver, sp, st)) | ||||
| 			return -1; | ||||
| #ifdef _3D_STAT64_VER | ||||
| 		if (_3d_ver == _3D_STAT64_VER) | ||||
| 			IVIEW(((struct stat64*)st), state.path.level); | ||||
| 		else | ||||
| #endif | ||||
| 		IVIEW(st, state.path.level); | ||||
| 	} | ||||
| #endif | ||||
| #if _mem_d_type_dirent | ||||
| 	if (S_ISDIR(st->st_mode)) | ||||
| 		st->st_nlink = _3D_LINK_MAX; | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #if defined(_LARGEFILE64_SOURCE) && defined(STAT643D) && !defined(_3D_STAT64_VER) | ||||
| 
 | ||||
| int | ||||
| lstat643d(const char* path, struct stat64* st) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	struct stat	ss; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_lstat, 0, path, &ss)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_LSTAT, &ss))) | ||||
| 		return -1; | ||||
| 	if (LSTAT64(sp, st)) | ||||
| 		return -1; | ||||
| 	IVIEW(st, state.path.level); | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_lstat, 0, state.path.name, &ss); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_lstat)) | ||||
| 			fscall(mp, MSG_lstat, 0, state.path.name, &ss); | ||||
| #endif | ||||
| #if _mem_d_type_dirent | ||||
| 	if (S_ISDIR(st->st_mode)) | ||||
| 		st->st_nlink = _3D_LINK_MAX; | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(lstat) | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										670
									
								
								src/cmd/3d/map.c
									
										
									
									
									
								
							
							
						
						
									
										670
									
								
								src/cmd/3d/map.c
									
										
									
									
									
								
							|  | @ -1,670 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d mount map support | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| /*
 | ||||
|  * visit a mapping and compute its size or copy mapping | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| mapget(Map_t* map, char* buf, int flags) | ||||
| { | ||||
| 	register char*	p; | ||||
| 	register int	z; | ||||
| 	register char*	v; | ||||
| 	register int	n; | ||||
| #if FS | ||||
| 	Mount_t*	mp = 0; | ||||
| #endif | ||||
| 
 | ||||
| 	NoP(flags); | ||||
| 	if (!(n = map->keysize)) | ||||
| 		n = strlen(map->key); | ||||
| 	switch (z = map->valsize & T_SIZE) | ||||
| 	{ | ||||
| #if FS | ||||
| 	case T_MOUNT: | ||||
| 		mp = (Mount_t*)map->val; | ||||
| 		if (state.visit.fs && state.visit.fs != mp->fs) | ||||
| 			return 0; | ||||
| 		v = mp->fs->special; | ||||
| 		z = mp->fs->specialsize; | ||||
| 		break; | ||||
| #endif | ||||
| 	case 0: | ||||
| 		z = strlen(map->val); | ||||
| 		/*FALLTHROUGH*/ | ||||
| 	default: | ||||
| 		v = map->val; | ||||
| 		break; | ||||
| 	} | ||||
| 	if (p = buf) | ||||
| 	{ | ||||
| 		strncpy(p, map->key, n); | ||||
| 		p += n; | ||||
| 		*p++ = ' '; | ||||
| 		if ( | ||||
| #if FS | ||||
| 			mp || | ||||
| #endif | ||||
| 			state.visit.prefix) | ||||
| 		{ | ||||
| 			*p++ = '/'; | ||||
| 			*p++ = '#'; | ||||
| #if FS | ||||
| 			if (!mp) | ||||
| #endif | ||||
| 			{ | ||||
| 				p = strcopy(p, state.visit.prefix); | ||||
| 				*p++ = '/'; | ||||
| 				if (*v == '/') | ||||
| 					*p++ = '#'; | ||||
| 			} | ||||
| 		} | ||||
| 		strncpy(p, v, z); | ||||
| 		p += z; | ||||
| #if FS | ||||
| 		if (mp) | ||||
| 		{ | ||||
| 			if (mp->channel) | ||||
| 				p += sfsprintf(p, 0, "/channel=%d", MSG_CHANNEL_SYS(mp->channel)); | ||||
| 			p += getattr(mp->attr, p); | ||||
| 			if (mp->physical) | ||||
| 				p += sfsprintf(p, 0, "%-*s", mp->physicalsize ? mp->physicalsize : strlen(mp->physical), mp->physical); | ||||
| 		} | ||||
| #endif | ||||
| 		*p++ = ' '; | ||||
| 		n = p - buf; | ||||
| 	} | ||||
| 	else | ||||
| 		n += z + state.visit.prelen | ||||
| #if FS | ||||
| 		+ (mp ? ((mp->channel ? 16 : 0) + (mp->physical ? (mp->physicalsize ? mp->physicalsize : strlen(mp->physical)) : 0) + getattr(mp->attr, NiL)) : 0) | ||||
| #endif | ||||
| 		+ 6; | ||||
| 	return n; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * dump table mappings into buf | ||||
|  * the mapping size is returned | ||||
|  * if tab==0 then all 3d mappings are processed | ||||
|  * if buf==0 then the size is just computed | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| mapdump(Table_t* tab, char* buf, int flags) | ||||
| { | ||||
| 	register Fs_t*		fs; | ||||
| 	register int		n; | ||||
| 	register int		sum = 0; | ||||
| 	register char*		p = buf; | ||||
| 
 | ||||
| 	if (flags & (MAP_EXEC|MAP_INIT)) | ||||
| 	{ | ||||
| 		if (state.kernel) | ||||
| 		{ | ||||
| 			if (p) | ||||
| 				*p = 0; | ||||
| 			return 1; | ||||
| 		} | ||||
| 		if (p) | ||||
| 		{ | ||||
| 			n = sfsprintf(p, 0, "%s", TABLE_PREFIX); | ||||
| 			p += n; | ||||
| 		} | ||||
| 		else | ||||
| 			n = sizeof(TABLE_PREFIX) - 1; | ||||
| 		sum += n; | ||||
| 	} | ||||
| 	if (!tab) | ||||
| 	{ | ||||
| 		for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++) | ||||
| 			if (fs->get) | ||||
| 			{ | ||||
| 				n = (*fs->get)(fs, p, NiL, flags); | ||||
| 				if (p) | ||||
| 					p += n; | ||||
| 				sum += n; | ||||
| 			} | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		n = iterate(tab, mapget, p, flags); | ||||
| 		if (p) | ||||
| 			p += n; | ||||
| 		sum += n; | ||||
| 	} | ||||
| 	if (p) | ||||
| 	{ | ||||
| 		if (p > buf) | ||||
| 		{ | ||||
| 			if (!(flags & MAP_INIT)) | ||||
| 				p--; | ||||
| 			else if ((p - buf) == (sizeof(TABLE_PREFIX) - 1)) | ||||
| 				p = buf; | ||||
| 			else | ||||
| 				*(p - 1) = '\n'; | ||||
| 		} | ||||
| 		*p = 0; | ||||
| 		sum = p - buf; | ||||
| 	} | ||||
| 	return sum; | ||||
| } | ||||
| 
 | ||||
| #if LICENSED | ||||
| 
 | ||||
| /*
 | ||||
|  * check fs license | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| licensed(register Fs_t* fs) | ||||
| { | ||||
| 	if ((fs->flags & (FS_INTERNAL|FS_LICENSED)) == FS_INTERNAL) | ||||
| 	{ | ||||
| 		if (!(fs->flags & FS_VALIDATED)) | ||||
| 		{ | ||||
| 			fs->flags |= FS_VALIDATED; | ||||
| 			if (!*state.license) | ||||
| 			{ | ||||
| 				Pathcheck_t	pc; | ||||
| 
 | ||||
| 				if (pathcheck(PATHCHECK, error_info.id, &pc)) | ||||
| 					*state.license = LICENSE_NONE; | ||||
| 				else if (!pc.feature) | ||||
| 					*state.license = LICENSE_ALL; | ||||
| 				else | ||||
| 					sfsprintf(state.license, sizeof(state.license), "%c%s%c", LICENSE_SEP, pc.feature, LICENSE_SEP); | ||||
| 				message((-2, "license: feature=%s", state.license)); | ||||
| 			} | ||||
| 			if (*state.license == LICENSE_ALL) | ||||
| 				fs->flags |= FS_LICENSED; | ||||
| 			else | ||||
| 			{ | ||||
| 				char	buf[sizeof(fs->special) + 4]; | ||||
| 
 | ||||
| 				sfsprintf(buf, sizeof(buf), "*%c%s%c*", LICENSE_SEP, fs->special, LICENSE_SEP); | ||||
| 				message((-1, "mount: license=%s pattern=%s", state.license, buf)); | ||||
| 				if (strmatch(state.license, buf)) | ||||
| 					fs->flags |= FS_LICENSED; | ||||
| 			} | ||||
| 			if (!(fs->flags & FS_LICENSED)) | ||||
| 				error(2, "%s service not licensed", fs->special); | ||||
| 		} | ||||
| 		if (!(fs->flags & FS_LICENSED)) | ||||
| 			return 0; | ||||
| 	} | ||||
| 	return 1; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| #define licensed(p)	(1) | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #if FS | ||||
| 
 | ||||
| /*
 | ||||
|  * copy attributes into table buf | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| getattr(const char* attr, char* buf) | ||||
| { | ||||
| 	register char*	a = (char*)attr; | ||||
| 	register char*	b = buf; | ||||
| 	register int	c; | ||||
| 
 | ||||
| 	if (b) | ||||
| 	{ | ||||
| 		while (c = *b++ = *a++) | ||||
| 			if (c == ' ') | ||||
| 				*(b - 1) = '/'; | ||||
| 		return b - buf - 1; | ||||
| 	} | ||||
| 	return strlen(a); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * add/delete attributes | ||||
|  * attributes stored as | ||||
|  * | ||||
|  *	(<space>name=value)* | ||||
|  */ | ||||
| 
 | ||||
| const char* | ||||
| setattr(char* attr, const char* op, register const char* oe) | ||||
| { | ||||
| 	register const char*	s; | ||||
| 	register const char*	v; | ||||
| 	register char*		a; | ||||
| 	register char*		x; | ||||
| 	register int		n; | ||||
| 	int			k; | ||||
| 	int			m; | ||||
| 
 | ||||
| 	if (s = op) | ||||
| 	{ | ||||
| 		for (;;) | ||||
| 		{ | ||||
| 			if (s >= oe || *s == '/') | ||||
| 				return op; | ||||
| 			if (*s++ == '=') | ||||
| 			{ | ||||
| 				v = s - 1; | ||||
| 				n = v - op; | ||||
| 				while (s < oe && *s != '/') | ||||
| 					s++; | ||||
| 				k = s - v - 1; | ||||
| 				m = s - op; | ||||
| 				a = attr; | ||||
| 				while (*a) | ||||
| 				{ | ||||
| 					a++; | ||||
| 					if (strneq(op, a, n) && a[n] == '=') | ||||
| 					{ | ||||
| 						if (!k || strncmp(op, a, m) || a[m] && a[m] != ' ') | ||||
| 						{ | ||||
| 							if (!(x = strchr(a, ' '))) | ||||
| 							{ | ||||
| 								if (a > attr) | ||||
| 									a--; | ||||
| 								*a = 0; | ||||
| 							} | ||||
| 							else | ||||
| 								while (*a++ = *++x); | ||||
| 						} | ||||
| 						else | ||||
| 							k = 0; | ||||
| 						break; | ||||
| 					} | ||||
| 					if (!(a = strchr(a, ' '))) | ||||
| 						break; | ||||
| 				} | ||||
| 				if (k && ((k = strlen(attr)) + m) < (ATTR_MAX - 1)) | ||||
| 				{ | ||||
| 					a = attr + k; | ||||
| 					*a++ = ' '; | ||||
| 					strncpy(a, op, m); | ||||
| 					a[m] = 0; | ||||
| 				} | ||||
| 				if (s++ >= oe) | ||||
| 					return 0; | ||||
| 				op = s; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	return op; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * handle `arg /#<op>' | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| special(register const char* op, int opsize, const char* arg, int argsize) | ||||
| { | ||||
| 	register const char*	oe; | ||||
| 	register Fs_t*		fs; | ||||
| 	const char*		ov; | ||||
| 	const char*		org; | ||||
| 	Map_t*			map; | ||||
| 	int			arglen; | ||||
| 	unsigned long		x; | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!(arglen = argsize)) | ||||
| 		arglen = strlen(arg); | ||||
| 	oe = op + (opsize ? opsize : strlen(op)); | ||||
| 	if (!(x = getkey(op, oe, 0))) | ||||
| 	{ | ||||
| 		if (arglen) | ||||
| 		{ | ||||
| 			errno = ENODEV; | ||||
| 			return -1; | ||||
| 		} | ||||
| 		for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++) | ||||
| 			if (fs->set) | ||||
| 				(*fs->set)(fs, state.null, 0, state.null, 0); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	if (state.key.invert) | ||||
| 	{ | ||||
| 		errno = ENODEV; | ||||
| 		return -1; | ||||
| 	} | ||||
| 	org = arg; | ||||
| 	if (!argsize && *arg) | ||||
| 	{ | ||||
| 		if (!pathreal(arg, P_PATHONLY|P_ABSOLUTE|P_NOSLASH, NiL)) | ||||
| 			return -1; | ||||
| 		arg = (const char*)state.path.name; | ||||
| 	} | ||||
| 	ov = (char*)state.key.next; | ||||
| 	for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++) | ||||
| 		if (!x || x == fs->key) | ||||
| 	{ | ||||
| 		if (!licensed(fs)) | ||||
| 			return 0; | ||||
| #if FS | ||||
| 		if (fs->flags & FS_FS) | ||||
| 		{ | ||||
| 			if (map = search(&state.vmount, arg, arglen, NiL, op < oe ? 0 : T_DELETE)) | ||||
| 			{ | ||||
| 				mp = (Mount_t*)map->val; | ||||
| 				if (mp->fs != fs) | ||||
| 				{ | ||||
| 					errno = EEXIST; | ||||
| 					return -1; | ||||
| 				} | ||||
| 				message((-2, "mount: old fs=%s map=%-*s arg=%-*s op=%-*s", fs->special, map->keysize, map->key, arglen, arg, ov ? (oe - ov) : 6, ov)); | ||||
| 				if (setattr(mp->attr, ov, oe)) | ||||
| 				{ | ||||
| 					errno = EEXIST; | ||||
| 					return -1; | ||||
| 				} | ||||
| 			} | ||||
| 			else if (op < oe) | ||||
| 			{ | ||||
| 				if (arglen) | ||||
| 				{ | ||||
| 					for (mp = state.mount;; mp++) | ||||
| 					{ | ||||
| 						if (mp >= state.mount + elementsof(state.mount)) | ||||
| 							return -1; | ||||
| 						if (!mp->fs) | ||||
| 							break; | ||||
| 					} | ||||
| 					if (map = search(&state.vmount, arg, arglen, (char*)mp, argsize ? T_MOUNT : (T_MOUNT|T_ALLOCATE))) | ||||
| 					{ | ||||
| 						message((-2, "mount: new fs=%s map=%-*s arg=%-*s op=%-*s", fs->special, map->keysize, map->key, arglen, arg, ov ? (oe - ov) : 6, ov)); | ||||
| 						fs->flags |= FS_REFERENCED; | ||||
| 						if (!(fs->flags & FS_NAME) && !state.cache) | ||||
| 							state.cache = 1; | ||||
| 						mp->fs = fs; | ||||
| 						mp->logical = map->key; | ||||
| 						mp->logicalsize = map->keysize; | ||||
| 						if (ov) | ||||
| 						{ | ||||
| 							if ((oe - ov) > 8 && strneq(ov, "channel=", 8)) | ||||
| 							{ | ||||
| 								mp->channel = strtol(ov + 8, (char**)&ov, 0); | ||||
| 								if (++ov >= oe) | ||||
| 									ov = 0; | ||||
| 							} | ||||
| 							if (ov = setattr(mp->attr, ov, oe)) | ||||
| 							{ | ||||
| 								if (opsize) | ||||
| 								{ | ||||
| 									mp->physical = (char*)ov - 1; | ||||
| 									mp->physicalsize = oe - mp->physical; | ||||
| 								} | ||||
| 								else | ||||
| 								{ | ||||
| 									mp->physical = strcpy(newof(0, char, strlen(ov), 2), ov - 1); | ||||
| 									mp->physicalsize = 0; | ||||
| 								} | ||||
| 							} | ||||
| 						} | ||||
| 					} | ||||
| 				} | ||||
| 				else if (setattr(fs->attr, ov, oe)) | ||||
| 				{ | ||||
| 					errno = EEXIST; | ||||
| 					return -1; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| #endif | ||||
| 		if (fs->set) | ||||
| 		{ | ||||
| 			if (ov) | ||||
| 			{ | ||||
| 				if ((*fs->set)(fs, (fs->flags & FS_RAW) ? org : arg, argsize, ov, oe - ov)) | ||||
| 					return -1; | ||||
| 			} | ||||
| 			else if (arglen) | ||||
| 			{ | ||||
| 				if ((*fs->set)(fs, (fs->flags & FS_RAW) ? org : arg, argsize, state.null, 0)) | ||||
| 					return -1; | ||||
| 			} | ||||
| 			else if ((*fs->set)(fs, state.null, 0, state.null, 0)) | ||||
| 				return -1; | ||||
| 		} | ||||
| 		if (op < oe) | ||||
| 			break; | ||||
| 	} | ||||
| 	if (op < oe && fs >= state.fs + elementsof(state.fs)) | ||||
| 	{ | ||||
| 		errno = ENODEV; | ||||
| 		return -1; | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * set a single 3d table mapping | ||||
|  * size==0 for volatile args | ||||
|  * from="-" maps to from="" | ||||
|  * to="-" maps to to="" | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| mapset(Table_t* tab, const char* from, int fromsize, register const char* to, int tosize) | ||||
| { | ||||
| 	register Map_t*	old; | ||||
| 	register int	n; | ||||
| 	int		x; | ||||
| 	char		buf[PATH_MAX + 1]; | ||||
| 
 | ||||
| 	if (state.safe && !(state.test & 0100)) | ||||
| 	{ | ||||
| 		errno = EPERM; | ||||
| 		return -1; | ||||
| 	} | ||||
| 	if (!fromsize && (!from || !from[0] || from[0] == '-' && !from[1]) || fromsize == 1 && from[0] == '-') | ||||
| 	{ | ||||
| 		from = state.null; | ||||
| 		fromsize = 0; | ||||
| 	} | ||||
| 	if (!tosize && (!to || !to[0] || to[0] == '-' && !to[1]) || tosize == 1 && to[0] == '-') | ||||
| 	{ | ||||
| 		to = state.null; | ||||
| 		tosize = 0; | ||||
| 	} | ||||
| 	message((-2, "mount: %-*s %-*s", from == state.null ? 1 : fromsize ? fromsize : strlen(from), from == state.null ? "-" : from, to == state.null ? 1 : tosize ? tosize : strlen(to), to == state.null ? "-" : to)); | ||||
| 	if ((!tosize || tosize >= 2) && to[0] == '/' && to[1] == '#') | ||||
| 	{ | ||||
| 		to += 2; | ||||
| 		if (tosize) | ||||
| 			tosize -= 2; | ||||
| 		return special(to, tosize, from, fromsize); | ||||
| 	} | ||||
| 	if (!*from) | ||||
| 	{ | ||||
| 		if (!*to) | ||||
| 			while (tab->table->key) | ||||
| 				search(tab, tab->table->key, tab->table->keysize, NiL, T_DELETE); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	if (fromsize) | ||||
| 	{ | ||||
| 		if (tosize || !to[0]) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * no malloc during initialization | ||||
| 			 * so we have to believe from and to here | ||||
| 			 */ | ||||
| 
 | ||||
| 			return search(tab, from, fromsize, to, tosize) ? 0 : -1; | ||||
| 		} | ||||
| 		n = *(from + fromsize); | ||||
| 		*((char*)from + fromsize) = 0; | ||||
| 	} | ||||
| 	if (!licensed(&state.fs[tab == &state.vpath ? FS_view : tab == &state.vmap ? FS_map : FS_safe])) | ||||
| 		return 0; | ||||
| 	if (x = tab != &state.vintercept) | ||||
| 	{ | ||||
| 		if (!pathreal(from, P_PATHONLY|P_ABSOLUTE|P_NOSLASH, NiL)) | ||||
| 			return -1; | ||||
| 		if (fromsize) | ||||
| 		{ | ||||
| 			*((char*)from + fromsize) = n; | ||||
| 			fromsize = 0; | ||||
| 		} | ||||
| 		from = (const char*)state.path.name; | ||||
| 	} | ||||
| 	if (!fromsize) | ||||
| 		fromsize = strlen(from); | ||||
| 	old = search(tab, from, fromsize, NiL, *to ? 0 : T_DELETE); | ||||
| 	if (!*to) | ||||
| 	{ | ||||
| 		search(&state.vmount, from, fromsize, NiL, T_DELETE); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	if (tab == &state.vmap) | ||||
| 	{ | ||||
| 		if (old) | ||||
| 		{ | ||||
| 			if (!(old->valsize & T_SIZE)) | ||||
| 				free(old->val); | ||||
| 			if ((old->valsize = tosize) & T_SIZE) | ||||
| 				old->val = (char*)to; | ||||
| 			else | ||||
| 				old->val = strcpy(newof(0, char, strlen(to), 1), to); | ||||
| 		} | ||||
| 		else | ||||
| 			search(tab, from, fromsize, to, tosize|T_ALLOCATE); | ||||
| 	} | ||||
| 	else if (old) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * ok if previous mapping matched | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (x && !(to = pathreal(to, P_PATHONLY|P_ABSOLUTE|P_NOSLASH, NiL))) | ||||
| 			return -1; | ||||
| 		if ((n = T_VALSIZE(old)) == (tosize ? tosize : strlen(to)) && strneq(old->val, to, n)) | ||||
| 			return 0; | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * already have different mapping | ||||
| 		 */ | ||||
| 
 | ||||
| 		errno = EEXIST; | ||||
| 		return -1; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		strncpy(buf, from, PATH_MAX); | ||||
| 		buf[PATH_MAX] = 0; | ||||
| 		if (x) | ||||
| 		{ | ||||
| 			if (!pathreal(to, P_PATHONLY|P_ABSOLUTE|P_NOSLASH, NiL)) | ||||
| 				return -1; | ||||
| 			to = (const char*)state.path.name; | ||||
| 		} | ||||
| 		if (tab == &state.vsafe || !streq(buf, to)) | ||||
| 			search(tab, buf, fromsize, to, T_ALLOCATE); | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * initialize mappings from space separated pairs in buf | ||||
|  * if readonly!=0 then buf must not be changed after this call | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| mapinit(const char* buf, int readonly) | ||||
| { | ||||
| 	register char*	bp = (char*)buf; | ||||
| 	register char*	from; | ||||
| 	register char*	to; | ||||
| 	int		fromsize; | ||||
| 	int		tosize; | ||||
| 
 | ||||
| #if DEBUG_TABLE | ||||
| 	if (!error_info.trace) | ||||
| 		error_info.trace = -3; | ||||
| 	message((-1, "TABLE `%s'", bp)); | ||||
| #endif | ||||
| 	if (strneq(bp, TABLE_PREFIX, sizeof(TABLE_PREFIX) - 1)) | ||||
| 		bp += sizeof(TABLE_PREFIX) - 1; | ||||
| #if DEBUG_TABLE | ||||
| 	if (bp != buf) | ||||
| 		message((-1, "TABLE `%s'", bp)); | ||||
| #endif | ||||
| 	if (!readonly) | ||||
| 		fromsize = tosize = 0; | ||||
| 	while (*bp) | ||||
| 	{ | ||||
| 		for (from = bp; *bp && *bp != ' '; bp++); | ||||
| 		if (readonly) | ||||
| 		{ | ||||
| 			fromsize = bp - from; | ||||
| 			if (*bp) | ||||
| 				bp++; | ||||
| 		} | ||||
| 		else if (*bp) | ||||
| 			*bp++ = 0; | ||||
| 		for (to = bp; *bp && *bp != ' ' && *bp != '\n'; bp++); | ||||
| 		if (readonly) | ||||
| 			tosize = bp - to; | ||||
| 		else if (*bp) | ||||
| 			*bp++ = 0; | ||||
| #if DEBUG_TABLE | ||||
| 		if (mapset(&state.vpath, from, fromsize, to, tosize)) | ||||
| 		{ | ||||
| 			if (readonly) | ||||
| 				message((-1, "TABLE %-*s -> %-*s FAILED", fromsize, from, tosize, to)); | ||||
| 			else | ||||
| 				message((-1, "TABLE %s -> %s FAILED", from, to)); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (state.table.version != TABLE_VERSION) | ||||
| 		{ | ||||
| 			message((-1, "TABLE state.table.version=%d != TABLE_VERSION=%d", state.table.version, TABLE_VERSION)); | ||||
| 			return -1; | ||||
| 		} | ||||
| #else | ||||
| 		if (mapset(&state.vpath, from, fromsize, to, tosize) || state.table.version != TABLE_VERSION) | ||||
| 			return -1; | ||||
| #endif | ||||
| 		if (*bp) | ||||
| 			bp++; | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -1,179 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide mkdir | ||||
| #else | ||||
| #define mkdir        ______mkdir | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| #define _LS_H		1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide mkdir | ||||
| #else | ||||
| #undef  mkdir | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| /*
 | ||||
|  * mkdir() will always create a directory on the highest layer | ||||
|  * mkdir() will create intermediate directories if they virtually exist | ||||
|  * mkdir() will do a chdir() if a virtual dot directory is created | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| mkdir3d(const char* path, mode_t mode) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register char*	cp; | ||||
| 	register int	r; | ||||
| 	char		buf[PATH_MAX + 1]; | ||||
| 	char		tmp[PATH_MAX + 1]; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.real) | ||||
| 	{ | ||||
| #if FS | ||||
| 		mp = 0; | ||||
| #endif | ||||
| 		sp = (char*)path; | ||||
| 	} | ||||
| #if FS | ||||
| 	else if (!fscall(NiL, MSG_mkdir, 0, path, mode)) | ||||
| 		return(state.ret); | ||||
| #endif | ||||
| 	else | ||||
| 	{ | ||||
| #if FS | ||||
| 		mp = monitored(); | ||||
| #endif | ||||
| 		if (!(sp = pathreal(path, P_PATHONLY|P_NOOPAQUE, NiL))) | ||||
| 			return(-1); | ||||
| 	} | ||||
| 	if (state.path.level || state.level && (sp == state.pwd || streq(sp, state.pwd)) || (r = MKDIR(sp, mode)) && errno == ENOENT) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * copy canonicalized pathname into buf | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (*sp != '/') | ||||
| 			sp = state.path.name; | ||||
| 		for (cp = buf; *cp = *sp++; cp++); | ||||
| 		if (!state.real) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * create intermediate dirs if they exist in lower view | ||||
| 			 */ | ||||
| 
 | ||||
| 			char*	a; | ||||
| 			char*	b; | ||||
| 			Path_t	save; | ||||
| 			int	oerrno; | ||||
| 
 | ||||
| 			a = tmp; | ||||
| 			b = buf; | ||||
| 			while (*a++ = *b++); | ||||
| 			if (b = strrchr(tmp, '/')) | ||||
| 				*b = 0; | ||||
| 			oerrno = errno; | ||||
| 			save = state.path; | ||||
| 			for (;;) | ||||
| 				if (!pathnext(tmp, NiL, NiL) || ACCESS(tmp, F_OK)) | ||||
| 				{ | ||||
| 					state.path = save; | ||||
| 					errno = oerrno; | ||||
| 					return -1; | ||||
| 				} | ||||
| 			state.path = save; | ||||
| 			errno = oerrno; | ||||
| 		} | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * ok to create intermediate dirs | ||||
| 		 */ | ||||
| 
 | ||||
| 		do | ||||
| 		{ | ||||
| 			while (*--cp != '/'); | ||||
| 			if (cp <= buf) return(-1); | ||||
| 			*cp = 0; | ||||
| 			r = !pathreal(buf, 0, NiL) || !streq(buf, state.path.name); | ||||
| 			*cp = '/'; | ||||
| 		} while (r); | ||||
| 		*cp = '/'; | ||||
| 		do | ||||
| 		{ | ||||
| 			r = *++cp; | ||||
| 			if (r == 0 || r == '/') | ||||
| 			{ | ||||
| 				*cp = 0; | ||||
| 				sp = pathreal(buf, P_PATHONLY, NiL); | ||||
| 				*cp = r; | ||||
| 				if (!sp) return(-1); | ||||
| 				if (sp == state.dot) sp = state.pwd; | ||||
| 				if (r = MKDIR(sp, r ? (mode|S_IWUSR|S_IXUSR) : mode)) return(r); | ||||
| #if FS | ||||
| 				if (fsmonitored(state.path.name) && !LSTAT(state.path.name, &state.path.st)) | ||||
| 					fscall(state.path.monitor, MSG_mkdir, 0, state.path.name, state.path.st.st_mode); | ||||
| #endif | ||||
| 				if (sp == state.pwd || streq(sp, state.pwd)) | ||||
| 				{ | ||||
| 					state.level = 0; | ||||
| 					CHDIR(state.pwd); | ||||
| 				} | ||||
| 			} | ||||
| 		} while (*cp); | ||||
| 	} | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) fscall(mp, MSG_mkdir, 0, path, mode); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_mkdir)) | ||||
| 				fscall(mp, MSG_mkdir, 0, path, mode); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d internal mkdir to skip pathreal(path, ...) | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fs3d_mkdir(const char* path, mode_t mode) | ||||
| { | ||||
| 	int	r; | ||||
| 
 | ||||
| 	state.real++; | ||||
| 	r = mkdir(path, mode); | ||||
| 	state.real--; | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,72 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide mknod | ||||
| #else | ||||
| #define mknod        ______mknod | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| #define _LS_H		1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide mknod | ||||
| #else | ||||
| #undef  mknod | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| #ifdef mknod3d | ||||
| 
 | ||||
| int | ||||
| mknod3d(const char* path, mode_t mode, dev_t dev) | ||||
| { | ||||
|  	register char*	sp; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_mknod, 0, path, mode, dev)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
|  	if (!(sp = pathreal(path, P_PATHONLY, NiL)) || MKNOD(sp, mode, dev)) | ||||
| 		return(-1); | ||||
| #if FS | ||||
|  	if (mp && !STAT(sp, &state.path.st)) | ||||
|  		fscall(mp, MSG_mknod, 0, path, state.path.st.st_mode, dev); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_mknod)) | ||||
| 			fscall(mp, MSG_mknod, 0, path, mode, dev); | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(mknod) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,147 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| mount3d(const char* aspc, char* path, int mode, void* a4, void* a5, void* a6) | ||||
| { | ||||
| 	char*			spc = (char*)aspc; | ||||
| 	register Fs_t*		fs; | ||||
| 	register char*		sp; | ||||
| 	register int		r; | ||||
| 	Table_t*		tab; | ||||
| 	int			size = 0; | ||||
| 	int			oerrno; | ||||
| 	unsigned long		x; | ||||
| 
 | ||||
| 	if ((!spc || !*spc) && (!path || !*path) && !mode) return(0); | ||||
| 	if (mode & FS3D_ALL) | ||||
| 	{ | ||||
| 		initialize(); | ||||
| 		switch (mode & FS3D_ALL) | ||||
| 		{ | ||||
| 		case FS3D_VERSION: | ||||
| 			tab = &state.vmap; | ||||
| 			break; | ||||
| 		case FS3D_VIEW: | ||||
| 			tab = &state.vpath; | ||||
| 			break; | ||||
| 		default: | ||||
| 			tab = 0; | ||||
| 			break; | ||||
| 		} | ||||
| 		if (mode & FS3D_GET) | ||||
| 		{ | ||||
| 			size = FS3D_SIZEOF(mode); | ||||
| 			if ((sp = spc) && (!*sp || *sp == '-' && !*(sp + 1) || *sp == '/' && *(sp + 1) == '#')) | ||||
| 			{ | ||||
| 				r = -1; | ||||
| 				oerrno = errno; | ||||
| 				errno = 0; | ||||
| 				if (*sp && *sp++ == '/') sp++; | ||||
| 				if (!*sp) | ||||
| 				{ | ||||
| 					if ((r = mapdump(NiL, NiL, 0)) >= 0 && r < size) | ||||
| 					{ | ||||
| 						mapdump(NiL, path, 0); | ||||
| 						r = 0; | ||||
| 					} | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					x = getkey(sp, sp + strlen(sp), 0); | ||||
| 					for (fs = state.fs; fs < state.fs + elementsof(state.fs); fs++) | ||||
| 						if (x == fs->key) | ||||
| 						{ | ||||
| 							if (fs->get && (r = (*fs->get)(fs, NiL, sp = state.key.next, 0)) >= 0 && r < size) | ||||
| 							{ | ||||
| 								if ((r = (*fs->get)(fs, path, sp, 0)) > 0 && path[r - 1] == ' ') r--; | ||||
| 								path[r] = 0; | ||||
| 								r = 0; | ||||
| 							} | ||||
| 							break; | ||||
| 						} | ||||
| 				} | ||||
| 				if (r >= 0) errno = oerrno; | ||||
| 				else if (!errno) errno = ENODEV; | ||||
| 			} | ||||
| 			else if (!spc) | ||||
| 			{ | ||||
| 				if ((r = mapdump(tab, NiL, 0)) >= 0 && r < size) | ||||
| 				{ | ||||
| 					mapdump(tab, path, 0); | ||||
| 					r = 0; | ||||
| 				} | ||||
| 			} | ||||
| 			else if (tab == &state.vmap) | ||||
| 			{ | ||||
| 				register Map_t*	map; | ||||
| 
 | ||||
| 				if (!(pathreal(spc, P_PATHONLY|P_ABSOLUTE|P_NOSLASH, NiL))) | ||||
| 					r = -1; | ||||
| 				else if (!(map = search(tab, state.path.name, strlen(state.path.name), NiL, 0))) | ||||
| 				{ | ||||
| 					if ((r = 0) < size) | ||||
| 						path[r] = 0; | ||||
| 				} | ||||
| 				else if ((r = T_VALSIZE(map)) < size) | ||||
| 				{ | ||||
| 					strncpy(path, map->val, r); | ||||
| 					path[r] = 0; | ||||
| 					r = 0; | ||||
| 				} | ||||
| 			} | ||||
| 			else if (!pathreal(spc, P_LSTAT, NiL)) r = -1; | ||||
| #if 1 | ||||
| 			else | ||||
| 			{ | ||||
| 				r = strlen(state.path.name); | ||||
| 				if (r > 1) | ||||
| 				{ | ||||
| 					if (state.path.name[r - 1] == '.' && state.path.name[r - 2] == '/') | ||||
| 					{ | ||||
| 						if (!(r -= 2)) | ||||
| 							r = 1; | ||||
| 						state.path.name[r] = 0; | ||||
| 					} | ||||
| 				} | ||||
| 				if (++r <= size) | ||||
| 				{ | ||||
| 					strcpy(path, state.path.name); | ||||
| 					r = 0; | ||||
| 				} | ||||
| 			} | ||||
| #else | ||||
| 			else if ((r = strlen(state.path.name)) < size) | ||||
| 			{ | ||||
| 				strcpy(path, state.path.name); | ||||
| 				r = 0; | ||||
| 			} | ||||
| #endif | ||||
| 			return(r); | ||||
| 		} | ||||
| 		else if (tab && spc) return(mapset(tab, path, 0, spc, 0)); | ||||
| 	} | ||||
| 	return(MOUNT(spc, path ? pathreal(path, 0, NiL) : (char*)0, mode, a4, a5, a6)); | ||||
| } | ||||
|  | @ -1,96 +0,0 @@ | |||
| ######################################################################## | ||||
| #                                                                      # | ||||
| #               This software is part of the ast package               # | ||||
| #          Copyright (c) 1989-2011 AT&T Intellectual Property          # | ||||
| #                      and is licensed under the                       # | ||||
| #                 Eclipse Public License, Version 1.0                  # | ||||
| #                    by AT&T Intellectual Property                     # | ||||
| #                                                                      # | ||||
| #                A copy of the License is available at                 # | ||||
| #          http://www.eclipse.org/org/documents/epl-v10.html           # | ||||
| #         (with md5 checksum b35adb5213ca9657e911e9befb180842)         # | ||||
| #                                                                      # | ||||
| #              Information and Software Systems Research               # | ||||
| #                            AT&T Research                             # | ||||
| #                           Florham Park NJ                            # | ||||
| #                                                                      # | ||||
| #                 Glenn Fowler <gsf@research.att.com>                  # | ||||
| #                  David Korn <dgk@research.att.com>                   # | ||||
| #                   Eduardo Krell <ekrell@adexus.cl>                   # | ||||
| #                                                                      # | ||||
| ######################################################################## | ||||
| : | ||||
| # opaque file ... | ||||
| # handles old (pre-92) and new style opaque | ||||
| # @(#)opaque (AT&T Bell Laboratories) 10/11/95 | ||||
| 
 | ||||
| function err_exit | ||||
| { | ||||
| 	print -u2 "$command: $@" | ||||
| 	exit 1 | ||||
| } | ||||
| 
 | ||||
| function usage | ||||
| { | ||||
| 	print -u2 "Usage: $command file ..." | ||||
| 	exit 2 | ||||
| } | ||||
| 
 | ||||
| command=${0##*/} | ||||
| case $1 in | ||||
| --)	shift | ||||
| 	break | ||||
| 	;; | ||||
| ""|-\?)	usage | ||||
| 	;; | ||||
| -*)	print -u2 -- "$1: invalid option" | ||||
| 	usage | ||||
| 	;; | ||||
| esac | ||||
| 
 | ||||
| # the rest is in 2d | ||||
| 
 | ||||
| 2d + 2>/dev/null || { { : > xxx && rm xxx && 2d + ;} || exit 1 ;} | ||||
| n=$(umask) | ||||
| 
 | ||||
| for i | ||||
| do	if	[[ -f $i ]] | ||||
| 	then	[[ $i -ef .../... ]] || print -u2 "$command: $i: file exists" | ||||
| 	else	case $i in | ||||
| 		*/*)	dir=${i%/*} file=${i##*/} ;; | ||||
| 		*)	dir=. file=$i ;; | ||||
| 		esac | ||||
| 		[[ $dir -ef . ]] || cd "$dir" || err_exit "$dir: cd failed" | ||||
| 		if	[[ ! -f .../... ]] | ||||
| 		then	if	[[ ! -d ... ]] | ||||
| 			then	if	mkdir ... | ||||
| 				then	chgrp 3d ... 2>/dev/null && chmod g+s ... | ||||
| 					umask 777 | ||||
| 					> .../... || err_exit "$i: cannot opaque" | ||||
| 					umask ${n#8#} | ||||
| 				elif	[[ ! -f ... ]] | ||||
| 				then	err_exit "...: cannot mkdir" | ||||
| 				elif	[[ -r ... || -w ... || -x ... || -s ... ]]  | ||||
| 				then	err_exit "...: obsolescent opaque must be 0 mode file" | ||||
| 				else	mkdir ...3d || err_exit "...3d: cannot mkdir" | ||||
| 					if	mv ... ...3d | ||||
| 					then	if	mv ...3d ... | ||||
| 						then	: | ||||
| 						else	rmdir ... | ||||
| 							mv ...3d ... | ||||
| 							err_exit "...: cannot rename obsolescent opaque" | ||||
| 						fi | ||||
| 					else	rmdir ...3d | ||||
| 						err_exit "...: cannot rename obsolescent opaque" | ||||
| 					fi | ||||
| 					chgrp 3d ... 2>/dev/null && chmod g+s ... | ||||
| 				fi | ||||
| 			else	umask 777 | ||||
| 				> .../... || err_exit "$i: cannot opaque" | ||||
| 				umask ${n#8#} | ||||
| 			fi | ||||
| 		fi | ||||
| 		ln .../... "$file" | ||||
| 		[[ $dir -ef . ]] || cd ~- || err_exit "$OLDPWD: cannot restore directory" | ||||
| 	fi | ||||
| done | ||||
|  | @ -1,358 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| /*
 | ||||
|  * this does the actual open, creating versions as required | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| vcreate(register const char* path, int flags, int mode) | ||||
| { | ||||
| 	register char*	cp; | ||||
| 	register char*	ep; | ||||
| 	int		dirlen; | ||||
| 	int		namlen; | ||||
| 	int		fd; | ||||
| 	int		r; | ||||
| 	char		buf[PATH_MAX+1]; | ||||
| 
 | ||||
| 	if (!state.vmap.size || !(flags & O_CREAT)) | ||||
| 		return OPEN(path, flags, mode); | ||||
| 	ep = cp = (char*)path + strlen(path); | ||||
| 	if (!instance(state.path.name, cp, &state.path.st, 1)) | ||||
| 		return OPEN(path, flags, mode); | ||||
| 	while (cp > (char*)path && *--cp != '/'); | ||||
| 	if (*cp == '/') cp++; | ||||
| 	namlen = ep - cp; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * construct pathname for version instance name text into buf | ||||
| 	 */ | ||||
| 
 | ||||
| 	memcpy(buf, path, dirlen = cp - path); | ||||
| 	memcpy(buf + dirlen, state.opaque, 4); | ||||
| 	*ep = '/'; | ||||
| 	strcpy(buf + dirlen + 4, cp); | ||||
| 	if ((fd = OPEN(buf, flags, mode)) >= 0) | ||||
| 		return fd; | ||||
| 	if (errno != ENOTDIR && errno != ENOENT) | ||||
| 		return -1; | ||||
| 	buf[dirlen + namlen + 4] = 0; | ||||
| 	if (MKDIR(buf, VERMODE)) | ||||
| 	{ | ||||
| 		buf[dirlen + 3] = 0; | ||||
| 		if (MKDIR(buf, VERMODE)) | ||||
| 		{ | ||||
| 			if (errno != EEXIST) | ||||
| 				return -1; | ||||
| 			if (LSTAT(buf, &state.path.st)) | ||||
| 				return -1; | ||||
| 
 | ||||
| 			/*
 | ||||
| 			 * check for old style opaque, can be removed soon | ||||
| 			 */ | ||||
| 
 | ||||
| 			if (S_ISREG(state.path.st.st_mode) && !(state.path.st.st_mode & S_IPERM)) | ||||
| 			{ | ||||
| 				char	savebuf[8]; | ||||
| 
 | ||||
| 				memcpy(savebuf, cp, sizeof(savebuf)); | ||||
| 				strcpy(cp, "...."); | ||||
| 				if (RENAME(buf, path)) | ||||
| 				{ | ||||
| 					errno = EEXIST; | ||||
| 					return -1; | ||||
| 				} | ||||
| 				if (MKDIR(buf, VERMODE)) | ||||
| 					return -1; | ||||
| 				buf[dirlen + 3] = '.'; | ||||
| 				buf[dirlen + 4] = 0; | ||||
| 				strcpy(cp, state.opaque); | ||||
| 				if (RENAME(buf, path)) | ||||
| 				{ | ||||
| 					errno = EEXIST; | ||||
| 					return -1; | ||||
| 				} | ||||
| 				memcpy(cp, savebuf, 8); | ||||
| 				buf[dirlen + 3] = 0; | ||||
| 				buf[dirlen + 4] = *cp; | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				errno = EEXIST; | ||||
| 				return -1; | ||||
| 			} | ||||
| 		} | ||||
| 		buf[dirlen + 3] = '/'; | ||||
| 		if (MKDIR(buf, VERMODE)) | ||||
| 			return -1; | ||||
| 	} | ||||
| 	buf[dirlen + namlen + 4] = '/'; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * now create the file | ||||
| 	 */ | ||||
| 
 | ||||
| 	if ((fd = OPEN(buf, flags, mode)) < 0) | ||||
| 		return -1; | ||||
| 	strcpy(buf + dirlen + namlen + 5, state.vdefault); | ||||
| 	*ep = 0; | ||||
| 	r = RENAME(path, buf); | ||||
| 	if (SYMLINK(buf + dirlen, path)) | ||||
| 		return fd; | ||||
| 	if (r) | ||||
| 	{ | ||||
| 		strcpy(buf + dirlen + namlen + 5, ep + 1); | ||||
| 		LINK(buf, path); | ||||
| 	} | ||||
| 	return fd; | ||||
| } | ||||
| 
 | ||||
| int | ||||
| open3d(const char* path, int oflag, ...) | ||||
| { | ||||
| 	register char*	sp = 0; | ||||
| 	register int	r; | ||||
| 	int		fd = -1; | ||||
| 	int		level; | ||||
| 	int		synthesize; | ||||
| 	mode_t		mode; | ||||
| 	struct stat	st; | ||||
| 	va_list		ap; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	va_start(ap, oflag); | ||||
| 	mode = (oflag & O_CREAT) ? va_arg(ap, int) : 0; | ||||
| 	va_end(ap); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_open, 0, path, oflag, mode, 0)) | ||||
| 	{ | ||||
| 		message((-1, "DEBUG: fs open fd=%d", state.ret)); | ||||
| 		return state.ret; | ||||
| 	} | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (state.in_2d) | ||||
| 	{ | ||||
| 		if ((r = OPEN((!path || *path) ? path : state.dot, oflag, mode)) < 0 || !state.call.monitor || state.in_2d == 1 || FSTAT(r, &st)) | ||||
| 			return r; | ||||
| 		goto done; | ||||
| 	} | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		if (!(sp = pathreal(path, (oflag & O_CREAT) ? P_NOOPAQUE : 0, &st))) | ||||
| 		{ | ||||
| 			if (oflag & O_CREAT) | ||||
| 			{ | ||||
| 				Path_t	save; | ||||
| 
 | ||||
| 				save = state.path; | ||||
| 				state.real++; | ||||
| 				sp = pathreal(path, P_PATHONLY|P_DOTDOT, NiL); | ||||
| 				state.real--; | ||||
| 				if (!sp) | ||||
| 				{ | ||||
| 					state.path = save; | ||||
| 					errno = EROFS; | ||||
| 					return -1; | ||||
| 				} | ||||
| 				if (state.path.level && LSTAT(sp, &st)) | ||||
| 				{ | ||||
| 					if (LSTAT(state.dot, &st) || fs3d_mkdir(sp, st.st_mode & S_IPERM)) | ||||
| 					{ | ||||
| 						state.path = save; | ||||
| 						return -1; | ||||
| 					} | ||||
| 					state.path = save; | ||||
| 					continue; | ||||
| 				} | ||||
| 				state.path = save; | ||||
| 				sp = 0; | ||||
| 			} | ||||
| 			st.st_mode = 0; | ||||
| 		} | ||||
| 		else if (S_ISBLK(st.st_mode) || S_ISCHR(st.st_mode)) | ||||
| 		{ | ||||
| 			r = OPEN(path, oflag, mode); | ||||
| 			goto done; | ||||
| 		} | ||||
| 		break; | ||||
| 	} | ||||
| 	level = state.path.level; | ||||
| 	synthesize = state.path.synthesize; | ||||
| #if VCS && defined(VCS_OPEN) | ||||
| 	VCS_OPEN(path, oflag, mode, &state.path.st); | ||||
| #endif | ||||
| 	if ((oflag & O_CREAT) && (!sp || level || (oflag & O_EXCL)) || (sp || level) && ((oflag & O_TRUNC) || (oflag & O_ACCMODE) != O_RDONLY)) | ||||
| 	{ | ||||
| 		if (sp) | ||||
| 		{ | ||||
| 			if ((oflag & O_ACCMODE) != O_RDONLY) | ||||
| 			{ | ||||
| 				if (!level)  | ||||
| 				{ | ||||
| 					r = OPEN(sp, oflag, mode); | ||||
| 					goto done; | ||||
| 				} | ||||
| 				if (!(oflag & O_TRUNC) && (fd = OPEN(sp, O_RDONLY, 0)) < 0) | ||||
| 					return -1; | ||||
| 			} | ||||
| 			mode = ((S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)|(st.st_mode & (S_IXUSR|S_IXGRP|S_IXOTH))); | ||||
| 		} | ||||
| 		if (!(sp = pathreal(path, (oflag & O_CREAT) ? (P_PATHONLY|P_SAFE) : 0, NiL))) | ||||
| 		{ | ||||
| 			if (fd >= 0) | ||||
| 				CLOSE(fd); | ||||
| 			return -1; | ||||
| 		} | ||||
| 		if (synthesize) | ||||
| 			fs3d_mkdir(state.pwd, S_IRWXU|S_IRWXG|S_IRWXO); | ||||
| 	} | ||||
| 	else if (!sp) | ||||
| 	{ | ||||
| 		r = -1; | ||||
| 		goto done; | ||||
| 	} | ||||
| 	r = vcreate(sp, ((oflag & O_ACCMODE) == O_RDWR) ? (oflag|O_CREAT) : oflag, mode); | ||||
| 	if (r < 0 && errno == ENOENT && ((oflag & (O_CREAT|O_TRUNC)) || (oflag & O_ACCMODE) != O_RDONLY)) | ||||
| 	{ | ||||
| 		if (!(sp = pathreal(path, P_PATHONLY|P_NOOPAQUE, NiL))) | ||||
| 			r = -1; | ||||
| 		else if (state.level <= 0 || *sp == '/') | ||||
| 			r = vcreate(sp, O_CREAT|oflag, mode); | ||||
| 		else errno = ENOENT; | ||||
| 		if (r < 0 && errno == ENOENT && (sp = pathreal(path, P_DOTDOT, NiL)) && state.path.level) | ||||
| 		{ | ||||
| 			if (sp = pathreal(path, P_DOTDOT|P_PATHONLY|P_NOOPAQUE, NiL)) | ||||
| 				r = fs3d_mkdir(sp, S_IRWXU|S_IRWXG|S_IRWXO); | ||||
| 			if (!r) | ||||
| 			{ | ||||
| 				/*
 | ||||
| 				 * try again | ||||
| 				 */ | ||||
| 
 | ||||
| 				if (!(sp = pathreal(path, P_PATHONLY|P_SAFE, NiL))) | ||||
| 					r = -1; | ||||
| 				else r = vcreate(sp, O_CREAT|oflag, mode); | ||||
| 			} | ||||
| 			else errno = ENOENT; | ||||
| 		} | ||||
| 	} | ||||
| 	if (r > 0) | ||||
| 	{ | ||||
| 		if (level && fd >= 0) | ||||
| 		{ | ||||
| 			if (fs3d_copy(fd, r, NiL)) | ||||
| 			{ | ||||
| 				CLOSE(r); | ||||
| 				CLOSE(fd); | ||||
| 				return -1; | ||||
| 			} | ||||
| 			state.path.level = 0; | ||||
| 		} | ||||
| 		state.path.open_level = state.path.level; | ||||
| 		setfdview(r, state.path.open_level); | ||||
| 	} | ||||
| 	if (fd >= 0) | ||||
| 		CLOSE(fd); | ||||
|  done: | ||||
| #if FS || defined(fchdir3d) | ||||
| 	if (r >= 0) | ||||
| 	{ | ||||
| #if defined(fchdir3d) | ||||
| 		if (S_ISDIR(st.st_mode) && r < elementsof(state.file)) | ||||
| 		{ | ||||
| 			Dir_t*	dp; | ||||
| 
 | ||||
| 			if (state.file[r].dir) | ||||
| 			{ | ||||
| 				free(state.file[r].dir); | ||||
| 				state.file[r].dir = 0; | ||||
| 			} | ||||
| 			if (dp = newof(0, Dir_t, 1, strlen(sp))) | ||||
| 			{ | ||||
| 				strcpy(dp->path, sp); | ||||
| 				dp->dev = st.st_dev; | ||||
| 				dp->ino = st.st_ino; | ||||
| 				state.file[r].dir = dp; | ||||
| 			} | ||||
| 		} | ||||
| #endif | ||||
| #if FS | ||||
| 		level = state.path.level; | ||||
| 		if (state.cache) | ||||
| 		{ | ||||
| 			if (!st.st_mode) | ||||
| 				FSTAT(r, &st); | ||||
| 			fileinit(r, &st, mp, 1); | ||||
| 		} | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_open, r, state.path.name, oflag, st.st_mode, level); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_open)) | ||||
| 				fscall(mp, MSG_open, r, state.path.name, oflag, st.st_mode, level); | ||||
| #endif | ||||
| 	} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * use this open() within 3d | ||||
|  * to save and restore the path state | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| fs3d_open(const char* path, int oflag, mode_t mode) | ||||
| { | ||||
| 	int	fd; | ||||
| 	Path_t	save; | ||||
| 
 | ||||
| 	save = state.path; | ||||
| 	fd = open(path, oflag, mode); | ||||
| 	state.path = save; | ||||
| 	return fd; | ||||
| } | ||||
| 
 | ||||
| #if !_nosys_open64 | ||||
| 
 | ||||
| int | ||||
| open643d(const char* path, int oflag, ...) | ||||
| { | ||||
| 	mode_t		mode; | ||||
| 	va_list		ap; | ||||
| 
 | ||||
| 	va_start(ap, oflag); | ||||
| 	mode = (oflag & O_CREAT) ? va_arg(ap, int) : 0; | ||||
| 	va_end(ap); | ||||
| #if defined(O_LARGEFILE) | ||||
| 	oflag |= O_LARGEFILE; | ||||
| #endif | ||||
| 	return open(path, oflag, mode); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,156 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * pathcanon - generate canonical pathname from given pathname | ||||
|  * | ||||
|  * this routine works with both relative and absolute paths | ||||
|  * relative paths can contain any number of leading ../ | ||||
|  * a pointer to the trailing '\0' is returned, 0 on error | ||||
|  * the operator ... is also applied by this routine | ||||
|  * phys is for libast compatibility and is currently ignored | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| char* | ||||
| pathcanon(char* path, size_t size, int phys) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register char*	dp = path; | ||||
| 	register int	c = '/'; | ||||
| 	register char*	begin = dp; | ||||
| 	int		add_dot = 0; | ||||
| 	long		visits = 0; | ||||
| 
 | ||||
| 	message((-6, "patcanon: ++ %s%s", path, phys ? " [PHYSICAL]" : "")); | ||||
| 	if (!size) size = strlen(dp) + 1; | ||||
| #if PRESERVE_LEADING_SLASH_SLASH | ||||
| 	if (*dp == '/' && *(dp + 1) == '/') | ||||
| 		path = ++dp; | ||||
| #endif | ||||
| 	if (*dp != '/') dp--; | ||||
| 	sp = dp; | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		sp++; | ||||
| 		if (c == '/') | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * eliminate redundant / | ||||
| 			 */ | ||||
| 
 | ||||
| 			if (*sp == '/') | ||||
| 				continue; | ||||
| 			if (*sp == '.') | ||||
| 			{ | ||||
| 				if ((c = *++sp) == '/') | ||||
| 				{ | ||||
| 					/*
 | ||||
| 					 * ./ | ||||
| 					 */ | ||||
| 
 | ||||
| 					add_dot++; | ||||
| 					continue; | ||||
| 				} | ||||
| 				if (!c) | ||||
| 				{ | ||||
| 					/*
 | ||||
| 					 * . | ||||
| 					 */ | ||||
| 
 | ||||
| 					add_dot++; | ||||
| 					break; | ||||
| 				} | ||||
| 				if (c == '.') | ||||
| 				{ | ||||
| 					if (!(c = *++sp) || c == '/') | ||||
| 					{ | ||||
| 						/*
 | ||||
| 						 * .. | ||||
| 						 */ | ||||
| 
 | ||||
| 						if (dp < begin) | ||||
| 							begin += 3; | ||||
| 						else | ||||
| 						{ | ||||
| 							if (dp > begin) | ||||
| 								while (*--dp != '/') | ||||
| 									if (dp < begin) | ||||
| 										break; | ||||
| 							if (!c) | ||||
| 								break; | ||||
| 							continue; | ||||
| 						} | ||||
| 					} | ||||
| 					else if (c == '.' && !state.in_2d) | ||||
| 					{ | ||||
| 						if (!(c = *++sp) || c == '/') | ||||
| 						{ | ||||
| 							/*
 | ||||
| 							 * ... | ||||
| 							 */ | ||||
| 
 | ||||
| 							*dp = 0; | ||||
| 							phys = state.path.level; | ||||
| 							if (!(dp = pathnext(path, sp, &visits))) | ||||
| 							{ | ||||
| 								message((-6, "patcanon: -- %s", NiL)); | ||||
| 								return(0); | ||||
| 							} | ||||
| 							if (!state.real) | ||||
| 								state.path.level = phys; | ||||
| 							if (!(*(sp = dp) = c)) | ||||
| 							{ | ||||
| 								dp--; | ||||
| 								break; | ||||
| 							} | ||||
| 							continue; | ||||
| 						} | ||||
| 						*++dp = '.'; | ||||
| 					} | ||||
| 					*++dp = '.'; | ||||
| 				} | ||||
| 				*++dp = '.'; | ||||
| 			} | ||||
| 		} | ||||
| 		add_dot = 0; | ||||
| 		if (!(c = *sp)) | ||||
| 			break; | ||||
| 		*++dp = c; | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * preserve trailing /. | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (add_dot) | ||||
| 	{ | ||||
| 		if (*dp != '/') | ||||
| 			*++dp = '/'; | ||||
| 		*++dp = '.'; | ||||
| 	} | ||||
| 	*++dp = 0; | ||||
| 	message((-6, "patcanon: -- %s", path)); | ||||
| 	return(dp); | ||||
| } | ||||
|  | @ -1,64 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef pathconf3d | ||||
| 
 | ||||
| long | ||||
| pathconf3d(const char* path, int op) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	long		r; | ||||
| 	int		oerrno; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_pathconf, 0, path, op)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, NiL))) | ||||
| 		return(-1); | ||||
| 	oerrno = errno; | ||||
| 	errno = 0; | ||||
| 	r = PATHCONF(sp, op); | ||||
| 	if (!errno) | ||||
| 	{ | ||||
| 		errno = oerrno; | ||||
| #if FS | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_pathconf, 0, sp, op); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_pathconf)) | ||||
| 				fscall(mp, MSG_pathconf, 0, sp, op); | ||||
| #endif | ||||
| 	} | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(pathconf) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,203 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| /*
 | ||||
|  * get next view for path sp | ||||
|  */ | ||||
| 
 | ||||
| char* | ||||
| pathnext(char* sp, char* extra, long* visits) | ||||
| { | ||||
| 	register char*	ep = sp + strlen(sp); | ||||
| 	register char*	cp; | ||||
| 	register char*	tmp; | ||||
| 	register int	shift; | ||||
| 	Map_t*		vpath; | ||||
| 	int		vpathlen; | ||||
| 
 | ||||
| 	message((-4, "pathnext: ++ %s%s%s [0x%08x]", sp, extra ? " + " : state.null, extra ? extra : state.null, visits ? *visits : 0L)); | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * check for next layer and previous visit | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (state.path.level + 1 >= state.limit) | ||||
| 	{ | ||||
| 		message((-4, "pathnext: -- %s [limit=%d]", NiL, state.limit)); | ||||
| 		return 0; | ||||
| 	} | ||||
| 	ep = sp + (shift = strlen(sp)); | ||||
| 	if (!(vpath = search(state.path.table ? state.path.table : &state.vpath, sp, shift, (const char*)visits, T_PREFIX))) | ||||
| 	{ | ||||
| 		message((-4, "pathnext: -- %s [0x%08x]", NiL, visits ? *visits : 0L)); | ||||
| 		return 0; | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * we found a viewpath entry | ||||
| 	 * check if stuff after extra needs to be shifted | ||||
| 	 */ | ||||
| 
 | ||||
| 	vpathlen = T_VALSIZE(vpath); | ||||
| 	cp = sp + vpath->keysize; | ||||
| 	shift = vpathlen - (cp - sp); | ||||
| 	if (shift < 0) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * shift left | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (cp < ep) | ||||
| 			strcopy(sp + vpathlen + 1, cp + 1); | ||||
| 	} | ||||
| 	else if (shift > 0) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * shift right extra | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (extra) | ||||
| 		{ | ||||
| 			for (tmp = extra + strlen(extra); tmp >= extra; tmp--) | ||||
| 				tmp[shift] = *tmp; | ||||
| 			extra += shift; | ||||
| 		} | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * shift right cp | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (cp < ep) | ||||
| 		{ | ||||
| 			for (tmp = ep; tmp > cp; tmp--) | ||||
| 				tmp[shift] = *tmp; | ||||
| 			strcopy(sp + vpathlen + 1, cp + shift + 1); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * insert vpath | ||||
| 	 */ | ||||
| 
 | ||||
| 	strncpy(sp, vpath->val, vpathlen); | ||||
| 	sp[vpathlen] = cp < ep ? '/' : 0; | ||||
| 	cp = sp; | ||||
| 	if (extra) | ||||
| 		strcpy(sp = ep + shift, extra); | ||||
| 	state.path.level++; | ||||
| 	message((-4, "pathnext: -- %s [level=%d visits=0x%08x]", cp, state.path.level, visits ? *visits : 0L)); | ||||
| 	return sp; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * search for the instance name for path sp | ||||
|  * and place in instname | ||||
|  * 0 returned when instances exhausted | ||||
|  * if create is non-zero, use name before the first slash as instance | ||||
|  * name, and do not check existence. | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| instance(register char* sp, char* instname, struct stat* st, int create) | ||||
| { | ||||
| 	register char*	cp; | ||||
| 	register char*	mp; | ||||
| 	register char*	mapnext; | ||||
| 	register int	size; | ||||
| 	int		maps; | ||||
| 	char*		mapend; | ||||
| 	Map_t*		map; | ||||
| 
 | ||||
| 	cp = instname++; | ||||
| 	mapnext = mapend = 0; | ||||
| 	maps = 0; | ||||
| 	if (state.vmap.size) | ||||
| 	{ | ||||
| 		while (*--cp != '/'); | ||||
| 		if (!create) cp -= 4; | ||||
| 	} | ||||
| 	else cp = sp; | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		if ((mp = mapnext) >= mapend) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * look for next vmap | ||||
| 			 */ | ||||
| 
 | ||||
| 			while (cp > sp) | ||||
| 			{ | ||||
| 				map = search(&state.vmap, sp, cp - sp, NiL, 0); | ||||
| 				if (cp > sp + 1) | ||||
| 				{ | ||||
| 					while (*--cp != '/'); | ||||
| 					while (cp > sp && cp[-1] == '/') cp--; | ||||
| 					if (cp == sp) cp++; | ||||
| 				} | ||||
| 				else cp = sp; | ||||
| 				if (map && (!create || *map->val != '/')) | ||||
| 					goto match; | ||||
| 			} | ||||
| 			if (!create) | ||||
| 			{ | ||||
| 				strcpy(instname, state.vdefault); | ||||
| 				maps++; | ||||
| 				if (!LSTAT(sp, st)) | ||||
| 					goto found; | ||||
| 			} | ||||
| 			return 0; | ||||
| 		match: | ||||
| 			mp = map->val; | ||||
| 			size = T_VALSIZE(map); | ||||
| 			mapend = mp + size; | ||||
| 			if (create) | ||||
| 			{ | ||||
| 				while (mp < mapend && *mp!='/') mp++; | ||||
| 				if ((size = mp - map->val) <= 0) | ||||
| 					return 0; | ||||
| 				memcpy(instname, map->val, size); | ||||
| 				instname[size] = 0; | ||||
| 				maps++; | ||||
| 				goto found; | ||||
| 			} | ||||
| 			if (*mp == '/') mp++; | ||||
| 		} | ||||
| 		for (mapnext = mp; mapnext < mapend; mapnext++) | ||||
| 			if (*mapnext == '/') | ||||
| 				break; | ||||
| 		if ((size = mapnext - mp) <= 0) continue; | ||||
| 		memcpy(instname, mp, size = mapnext - mp); | ||||
| 		instname[size] = 0; | ||||
| 		while (mapnext < mapend && *mapnext == '/') mapnext++; | ||||
| 		maps++; | ||||
| 		if (!LSTAT(sp, st)) | ||||
| 			goto found; | ||||
| 	} | ||||
| 	/*NOTREACHED*/ | ||||
|  found: | ||||
| 	if (maps > 1) | ||||
| 		state.path.level |= INSTANCE; | ||||
| 	return 1; | ||||
| } | ||||
|  | @ -1,654 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifndef MAXSYMLINKS | ||||
| #define MAXSYMLINKS	20 | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * if <sp> is a hard link to state.opaque in the same directory then the file | ||||
|  * is opaque and the errno should be ENOENT | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| checkopaque(register char* path, struct stat* st) | ||||
| { | ||||
| 	register char*	basesp; | ||||
| 	int		oerrno = errno; | ||||
| 	struct stat	statb; | ||||
| 	char		savebuf[sizeof(state.opaque)]; | ||||
| 	register int	r = 0; | ||||
| 
 | ||||
| 	if (st->st_nlink <= 1) | ||||
| 		return 0; | ||||
| 	if (st->st_mode & (S_IRWXU|S_IRWXG|S_IRWXO)) | ||||
| 		return 0; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * change the basename to state.opaque | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (basesp = strrchr(path, '/')) | ||||
| 		basesp++; | ||||
| 	else | ||||
| 		basesp = path; | ||||
| 	memcpy(savebuf, basesp, sizeof(state.opaque)); | ||||
| 	strcpy(basesp, state.opaque); | ||||
| 	if (LSTAT(path, &statb)) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * for backward compatability | ||||
| 		 */ | ||||
| 
 | ||||
| 		basesp[3] = 0; | ||||
| 		if (LSTAT(path, &statb)) | ||||
| 			goto not_opaque; | ||||
| 	} | ||||
| 	if (statb.st_ino == st->st_ino && statb.st_dev == st->st_dev) | ||||
| 	{ | ||||
| 		errno = ENOENT; | ||||
| 		r = statb.st_ino; | ||||
| 	} | ||||
| 	else | ||||
| 		errno = oerrno; | ||||
|  not_opaque: | ||||
| 	memcpy(basesp, savebuf, sizeof(state.opaque)); | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * return real path name for path | ||||
|  */ | ||||
| 
 | ||||
| #if DEBUG | ||||
| 
 | ||||
| static char*	_pathreal(const char*, int, struct stat*); | ||||
| 
 | ||||
| char* | ||||
| pathreal(const char* apath, register int type, struct stat* st) | ||||
| { | ||||
| 	char*	path = (char*)apath; | ||||
| 
 | ||||
| 	initialize(); | ||||
| 	message((-5, "pathreal: ++ %s type=|%s%s%s%s%s%s%s%s%s%s%s", path | ||||
| 		, (type & P_ABSOLUTE) ? "ABSOLUTE|" : state.null | ||||
| 		, (type & P_DOTDOT) ? "DOTDOT|" : state.null | ||||
| 		, (type & P_LSTAT) ? "LSTAT|" : state.null | ||||
| 		, st ? "MYSTAT|" : state.null | ||||
| 		, (type & P_NOOPAQUE) ? "NOOPAQUE|" : state.null | ||||
| 		, (type & P_NOSLASH) ? "NOSLASH|" : state.null | ||||
| 		, (type & P_PATHONLY) ? "PATHONLY|" : state.null | ||||
| 		, (type & P_READLINK) ? "READLINK|" : state.null | ||||
| 		, (type & P_SAFE) ? "SAFE|" : state.null | ||||
| 		, (type & P_SLASH) ? "SLASH|" : state.null | ||||
| 		, (type & P_TOP) ? "TOP|" : state.null | ||||
| 		)); | ||||
| 	path = _pathreal(path, type, st); | ||||
| 	message((-5, "pathreal: -- %s level=%d links=%d", path, state.path.level, state.path.nlinks)); | ||||
| 	return path; | ||||
| } | ||||
| 
 | ||||
| #undef	initialize | ||||
| #define initialize() | ||||
| #undef	pathreal | ||||
| #define pathreal _pathreal | ||||
| static | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| char* | ||||
| pathreal(const char* apath, register int type, struct stat* st) | ||||
| { | ||||
| 	char*			path = (char*)apath; | ||||
| 	register char*		sp; | ||||
| 	register char*		cp; | ||||
| 	register char*		ip; | ||||
| 	Table_t*		safe; | ||||
| 	int			oerrno = errno; | ||||
| 	int			opaqued = 0; | ||||
| 	int			len; | ||||
| 	int			vir; | ||||
| 	int			safesize; | ||||
| 	int			safe_dir; | ||||
| 	long			visits; | ||||
| 	char			buf[PATH_MAX + 1]; | ||||
| 
 | ||||
| 	static struct stat	stbuf; | ||||
| 	static struct stat	tsbuf; | ||||
| 
 | ||||
| 	state.path.level = state.path.synthesize = state.path.nlinks = 0; | ||||
| 	if (!path) | ||||
| 	{ | ||||
| 		errno = EFAULT; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	initialize(); | ||||
| 	if (state.in_2d) | ||||
| 	{ | ||||
| 		if (!st || (!state.level || *path == '/') && !LSTAT(path, st)) | ||||
| 			return path; | ||||
| 		if (state.level && streq(path, ".") && !CHDIR(state.pwd)) | ||||
| 		{ | ||||
| 			state.level = 0; | ||||
| 			return path; | ||||
| 		} | ||||
| 		return 0; | ||||
| 	} | ||||
| #if FS | ||||
| 	if (mounted() && (sp = fsreal(state.path.monitor, MSG_stat, state.path.mount))) | ||||
| 		apath = (char*)(path = sp); | ||||
| #endif | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * handle null path, . and / separately | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (safe = state.safe ? &state.vsafe : (Table_t*)0) | ||||
| 	{ | ||||
| 		type |= P_ABSOLUTE; | ||||
| 		if (!(safesize = state.safe->servicesize)) | ||||
| 			safesize = strlen(state.safe->service); | ||||
| 	} | ||||
| 	else | ||||
| 		type &= ~P_SAFE; | ||||
|  again: | ||||
| 	if (!*path) | ||||
| 	{ | ||||
| 		errno = ENOENT; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	cp = sp = path; | ||||
| 	state.path.synthesize = state.path.linksize = 0; | ||||
| 	if (!st) | ||||
| 		st = &stbuf; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * check if virtual dir has been created by another process | ||||
| 	 * only P_PATHONLY|P_TOP calls (usually create or modify link) and | ||||
| 	 * references to "." are checked for performance | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (state.level > 0 && state.pwd && ((type & (P_PATHONLY|P_TOP)) && *sp != '/' || *sp == '.' && sp[1] == 0)) | ||||
| 	{ | ||||
| 		if (!CHDIR(state.pwd)) | ||||
| 			state.level = 0; | ||||
| 		else if (!(type & (P_PATHONLY|P_TOP))) | ||||
| 		{ | ||||
| 			len = 0; | ||||
| 			state.path.level += (state.path.synthesize = state.level); | ||||
| 			sp = strcpy(state.path.name, state.pwd); | ||||
| 			goto skip; | ||||
| 		} | ||||
| 	} | ||||
| 	if (!state.pwd || sp[1] == 0 && (*sp == '.' || *sp == '/' && !safe)) | ||||
| 	{ | ||||
| 		if (st != &stbuf && LSTAT(sp, st)) | ||||
| 			return 0; | ||||
| 		if (*sp == '/' || !state.pwd && (type & P_PATHONLY)) | ||||
| 			strncpy(state.path.name, sp, PATH_MAX); | ||||
| 		else if (!state.pwd) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * treat the current directory as if were empty | ||||
| 			 */ | ||||
| 
 | ||||
| 			errno = ENOENT; | ||||
| 			return 0; | ||||
| 		} | ||||
| 		else | ||||
| 			strncpy(state.path.name, state.pwd, PATH_MAX); | ||||
| 		errno = oerrno; | ||||
| 		return state.path.name; | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * put absolute pathname into state.path | ||||
| 	 */ | ||||
| 
 | ||||
| 	safe_dir = 0; | ||||
| 	if (*path != '/') | ||||
| 	{ | ||||
| 		strcpy(state.path.name, state.pwd); | ||||
| 		sp = state.path.name + state.pwdsize; | ||||
| 		*sp++ = '/'; | ||||
| 		if (safe && state.pwdsize >= safesize && !strncmp(state.pwd, state.safe->service, safesize) && (!state.pwd[safesize] || state.pwd[safesize] == '/')) | ||||
| 			safe_dir = safesize; | ||||
| 	} | ||||
| 	else | ||||
| 		sp = state.path.name; | ||||
| 	ip = state.path.name + elementsof(state.path.name); | ||||
| 	while (sp < ip && (*sp = *cp++)) | ||||
| 		sp++; | ||||
| 	if (type & P_DOTDOT) | ||||
| 		strcpy(sp, "/.."); | ||||
| 	sp = state.path.name; | ||||
| 	if (!(ip = pathcanon(sp + safe_dir, sizeof(state.path.name) - safe_dir, 0))) | ||||
| 	{ | ||||
| 		errno = ENOENT; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	if (type & (P_DOTDOT|P_NOSLASH)) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * remove trailing slashes | ||||
| 		 */ | ||||
| 
 | ||||
| 		while (*--ip == '/'); | ||||
| 		*++ip = 0; | ||||
| 	} | ||||
| 	else if ((type & P_SLASH) && *(ip - 1) != '/') | ||||
| 		*ip++ = '/'; | ||||
| 	if (*(ip - 1) == '/' && ip - sp > 1) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * trailing slash is equivalent to trailing slash-dot | ||||
| 		 * this forces the common-sense interpretation | ||||
| 		 */ | ||||
| #if DEBUG | ||||
| 		if (!(state.test & 010)) | ||||
| #endif | ||||
| 		*ip++ = '.'; | ||||
| 		*ip = 0; | ||||
| 	} | ||||
| 	len = ip - sp; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * try to use relative path | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (!(type & (P_LSTAT|P_READLINK))) | ||||
| 	{ | ||||
| 		for (ip = state.pwd; *ip && *ip == *sp++; ip++); | ||||
| 		if (*ip != 0 || *sp && *sp != '/' || state.level < 0) | ||||
| 			sp = state.path.name; | ||||
| 		else | ||||
| 		{ | ||||
| 			state.path.level += (state.path.synthesize = state.level); | ||||
| 			if (state.level && !(type & P_PATHONLY) && st == &stbuf) | ||||
| 			{ | ||||
| 				sp = state.path.name; | ||||
| 				len -= state.pwdsize; | ||||
| 			} | ||||
| 			else if (type & P_ABSOLUTE) | ||||
| 				sp = state.path.name; | ||||
| 			else if (*sp == '/') | ||||
| 				sp++; | ||||
| 		} | ||||
| 		if (*sp == 0) | ||||
| 			sp = state.dot; | ||||
| 	} | ||||
|  skip: | ||||
| 	if ((type & P_NOOPAQUE) && !LSTAT(sp, st) && checkopaque(sp, st)) | ||||
| 	{ | ||||
| 		message((-1, "%s: remove opaque", sp)); | ||||
| 		UNLINK(sp); | ||||
| 		opaqued = 1; | ||||
| 	} | ||||
| 	if (safe && *sp == '/') | ||||
| 	{ | ||||
| 		state.path.table = safe; | ||||
| 		cp = pathnext(sp, NiL, NiL); | ||||
| 		state.path.table = safe = 0; | ||||
| 		if (cp) | ||||
| 		{ | ||||
| 			state.path.level = 0; | ||||
| 			path = strcpy(buf, sp); | ||||
| 			message((-5, "pathreal: == safe map %s", path)); | ||||
| 			type &= ~(P_DOTDOT|P_SAFE); | ||||
| 			goto again; | ||||
| 		} | ||||
| 		if (!*(sp + 1)) | ||||
| 		{ | ||||
| 			strncpy(sp, state.safe->service, safesize); | ||||
| 			sp[safesize] = 0; | ||||
| 		} | ||||
| 		else if (strncmp(sp, state.safe->service, safesize) || sp[safesize] && sp[safesize] != '/') | ||||
| 		{ | ||||
| 			if (*path != '/' && safe_dir) | ||||
| 			{ | ||||
| 				errno = EPERM; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			if (sp[1]) | ||||
| 				strcpy(buf, sp); | ||||
| 			else | ||||
| 				*buf = 0; | ||||
| 			len = sfsprintf(sp, sizeof(state.path.name), "%-*s%s", safesize, state.safe->service, buf); | ||||
| 			message((-5, "pathreal: == safe next %s", sp)); | ||||
| 			if (!pathnext(sp, NiL, NiL)) | ||||
| 			{ | ||||
| 				errno = EPERM; | ||||
| 				return 0; | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 			type &= ~P_SAFE; | ||||
| 	} | ||||
| 	if ((type & P_SAFE) && state.path.level) | ||||
| 	{ | ||||
| 		errno = EPERM; | ||||
| 		return 0; | ||||
| 	} | ||||
| 	if (type & P_PATHONLY) | ||||
| 	{ | ||||
| 		errno = oerrno; | ||||
| 		return sp; | ||||
| 	} | ||||
| 	visits = 0; | ||||
| 	vir = 1; | ||||
| 	while (LSTAT(sp, st)) | ||||
| 	{ | ||||
| 		if (vir) | ||||
| 		{ | ||||
| 			if (apath[0] == '.' && apath[1] == '.' && apath[2] == '.' && !apath[3]) | ||||
| 			{ | ||||
| 				if (state.level > 0) | ||||
| 				{ | ||||
| 					message((-1, "pathreal: %s => %s", apath, sp)); | ||||
| 					LSTAT(".", st); | ||||
| 					return sp; | ||||
| 				} | ||||
| 				errno = ENOENT; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			vir = 0; | ||||
| 		} | ||||
| 		if (errno == ENOTDIR) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * check for version instance | ||||
| 			 */ | ||||
| 
 | ||||
| 			cp = ip = sp + strlen(sp); | ||||
| 			while (ip > sp && *--ip != '/'); | ||||
| 			if (ip < sp) | ||||
| 				return 0; | ||||
| 			while (ip > sp && *--ip == '/'); | ||||
| 			if (ip < sp) | ||||
| 				return 0; | ||||
| 			while (ip > sp && *--ip != '/'); | ||||
| 			if (*ip == '/') | ||||
| 				ip++; | ||||
| 			while (cp >= ip) | ||||
| 			{ | ||||
| 				cp[4] = *cp; | ||||
| 				cp--; | ||||
| 			} | ||||
| 			memcpy(ip, state.opaque, 4); | ||||
| 			if (!LSTAT(sp, st)) | ||||
| 				break; | ||||
| 			errno = ENOTDIR; | ||||
| 			return 0; | ||||
| 		} | ||||
| 
 | ||||
| 		if (errno != ENOENT || opaqued) | ||||
| 			return 0; | ||||
| #if FS | ||||
| 		/*
 | ||||
| 		 * check user mount | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (visits) | ||||
| 		{ | ||||
| 			Mount_t*	mp; | ||||
| 			const char*	up; | ||||
| 
 | ||||
| 			if ((mp = getmount(sp, &up)) && (mp->fs->flags & FS_NAME) && (sp = fsreal(mp, MSG_open, (char*)up)) && !LSTAT(sp, st)) | ||||
| 				break; | ||||
| 		} | ||||
| #endif | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * search down the viewpath | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (type & P_SAFE) | ||||
| 		{ | ||||
| 			errno = EPERM; | ||||
| 			return 0; | ||||
| 		} | ||||
| 		if (!pathnext(state.path.name, NiL, &visits)) | ||||
| 			return 0; | ||||
| 		sp = state.path.name; | ||||
| 		if (!(type & P_ABSOLUTE)) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * try to use relative path | ||||
| 			 */ | ||||
| 
 | ||||
| 			for (ip = state.pwd; *ip && *ip == *sp++; ip++); | ||||
| 			if (*ip == 0 && *sp == '/') | ||||
| 				sp++; | ||||
| 			else | ||||
| 				sp = state.path.name; | ||||
| 		} | ||||
| 		if (*sp == 0) | ||||
| 			sp = state.dot; | ||||
| 	} | ||||
| 	if (st->st_nlink > 1 && checkopaque(sp, st)) | ||||
| 		return 0; | ||||
| 	if ((type & P_TOP) && state.path.level) | ||||
| 	{ | ||||
| 		int	rfd; | ||||
| 		int	wfd; | ||||
| 
 | ||||
| 		if ((rfd = OPEN(sp, O_RDONLY, 0)) < 0) | ||||
| 			sp = 0; | ||||
| 		else | ||||
| 		{ | ||||
| 			tsbuf = *st; | ||||
| 			wfd = open(apath, O_WRONLY|O_CREAT|O_TRUNC|O_cloexec, st->st_mode & S_IPERM); | ||||
| 			*st = tsbuf; | ||||
| 			if (wfd < 0) | ||||
| 				sp = 0; | ||||
| 			else  | ||||
| 			{ | ||||
| 				if (fs3d_copy(rfd, wfd, st)) | ||||
| 					sp = 0; | ||||
| 				CLOSE(wfd); | ||||
| 			} | ||||
| 			CLOSE(rfd); | ||||
| 		} | ||||
| 		if (!sp) | ||||
| 		{ | ||||
| 			errno = EROFS; | ||||
| 			return 0; | ||||
| 		} | ||||
| 		if (st == &stbuf) | ||||
| 			st = 0; | ||||
| 		return pathreal(apath, P_PATHONLY, st); | ||||
| 	} | ||||
| 	IVIEW(st, state.path.level); | ||||
| 	if (state.path.synthesize) | ||||
| 	{ | ||||
| 		if (state.path.level < state.level) | ||||
| 		{ | ||||
| 			if (len) | ||||
| 			{ | ||||
| 				ip  = state.path.name + strlen(state.path.name) - len; | ||||
| 				len = *ip; | ||||
| 				*ip = 0; | ||||
| 			} | ||||
| 			if (!CHDIR(state.path.name)) | ||||
| 				state.level = state.path.level; | ||||
| 			message((-1, "chdir=%s level=%d", state.path.name, state.level)); | ||||
| 			*ip = len; | ||||
| 		} | ||||
| 		else if (S_ISDIR(st->st_mode)) | ||||
| 		{ | ||||
| 			int		mask; | ||||
| 			static int	uid = -1; | ||||
| 			static int	gid; | ||||
| 
 | ||||
| 			umask(mask = umask(0)); | ||||
| 			st->st_mode = (st->st_mode | (S_IRWXU|S_IRWXG|S_IRWXO)) & ~(mask & (S_IRWXU|S_IRWXG|S_IRWXO)); | ||||
| 			if (uid == -1) | ||||
| 			{ | ||||
| 				uid = geteuid(); | ||||
| 				gid = getegid(); | ||||
| 			} | ||||
| 			st->st_uid = uid; | ||||
| 			st->st_gid = gid; | ||||
| 		} | ||||
| 	} | ||||
| 	ip = sp; | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * symbolic links handled specially | ||||
| 	 * get filename from pathname | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (S_ISLNK(st->st_mode) && (len = checklink(sp, st, type)) > 1 && !(type & (P_LSTAT|P_READLINK)) && state.path.nlinks++ < MAXSYMLINKS) | ||||
| 	{ | ||||
| 		path = strcpy(buf, state.path.name); | ||||
| 		message((-1, "pathreal: == again %s", path)); | ||||
| 		if (*path != '/') | ||||
| 			state.path.level = 0; | ||||
| 		type &= ~(P_DOTDOT|P_SAFE); | ||||
| 		goto again; | ||||
| 	} | ||||
| #if VCS && defined(VCS_REAL) | ||||
| 	VCS_REAL(state.path.name, st); | ||||
| #endif | ||||
| 	errno = oerrno; | ||||
| 	return sp; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * check whether sp points to a version object and find version instance | ||||
|  * sp is canonicalized and points into state.path | ||||
|  * when called from unlink, (type & P_PATHONLY) is set | ||||
|  *     -1 for non-existent link | ||||
|  *     length of path for a relative link that is not a version object | ||||
|  *     0  otherwise | ||||
|  *    state.path.linkname and state.path.linksize are set for version object | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| checklink(const char* asp, struct stat* st, int type) | ||||
| { | ||||
| 	register char*	sp = (char*)asp; | ||||
| 	register char*	ip; | ||||
| 	register int	len; | ||||
| 	register int	n; | ||||
| 	register char*	bp; | ||||
| 
 | ||||
| 	char		buf[PATH_MAX + 1]; | ||||
| 
 | ||||
| 	if (sp < state.path.name || sp >= state.path.name + sizeof(state.path.name)) | ||||
| 	{ | ||||
| 		message((-1, "AHA#%d checklink bounds sp=%p state.path.name=%p sp=%s", __LINE__, sp, state.path.name, sp)); | ||||
| 		sp = strncpy(state.path.name, sp, sizeof(state.path.name) - 1); | ||||
| 	} | ||||
| 	while (S_ISLNK(st->st_mode)) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * go to the last component | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (ip = strrchr(sp, '/')) | ||||
| 			ip++; | ||||
| 		else | ||||
| 			ip = sp; | ||||
| 		strcpy(buf, ip); | ||||
| 		len = (state.path.name + sizeof(state.path.name) - 1) - ip; | ||||
| 		if ((len = READLINK(sp, ip, len)) < 0) | ||||
| 		{ | ||||
| 			message((-1, "%s: cannot readlink", sp)); | ||||
| 			return 0; | ||||
| 		} | ||||
| 		state.path.linkname = ip; | ||||
| 		state.path.linksize = len; | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * check for relative link | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (*ip != '/') | ||||
| 		{ | ||||
| 			ip[len] = 0; | ||||
| 			if (*ip == *state.opaque && !memcmp(ip, state.opaque, 4) && !memcmp(ip + 4, buf, n = strlen(buf))) | ||||
| 			{ | ||||
| 				/*
 | ||||
| 				 * version object | ||||
| 				 */ | ||||
| 
 | ||||
| 				ip += n + 4; | ||||
| 				if (instance(state.path.name, ip, st, 0)) | ||||
| 				{ | ||||
| 					state.path.linksize = strlen(state.path.linkname); | ||||
| 					if (type & P_LSTAT) | ||||
| 					{ | ||||
| 						st->st_size = state.path.linksize; | ||||
| 						st->st_mode &= S_IPERM; | ||||
| #ifdef S_IFLNK | ||||
| 						st->st_mode |= S_IFLNK; | ||||
| #endif | ||||
| 						return 0; | ||||
| 					} | ||||
| 					continue; | ||||
| 				} | ||||
| 				errno = ENOENT; | ||||
| 				return -1; | ||||
| 			} | ||||
| 			else if (!(type & (P_LSTAT|P_PATHONLY|P_READLINK)) && *ip == '.' && *(ip + 1) == '.' && (*(ip + 2) == '/' || *(ip + 2) == 0)) | ||||
| 			{ | ||||
| 				memcpy(buf, ip, len + 1); | ||||
| 				bp = state.path.name; | ||||
| 				while (ip > bp && *(ip - 1) == '/') | ||||
| 					ip--; | ||||
| 				for (;;) | ||||
| 				{ | ||||
| 					*(sp = ip) = 0; | ||||
| 					while (ip > bp && *--ip != '/'); | ||||
| 					while (ip > bp && *(ip - 1) == '/') | ||||
| 						ip--; | ||||
| 					if (*ip == '/') | ||||
| 						ip++; | ||||
| 					if ((n = READLINK(state.path.name, ip, PATH_MAX - (ip - state.path.name))) <= 0) | ||||
| 					{ | ||||
| 						*sp++ = '/'; | ||||
| 						state.path.linkname = (char*)memcpy(sp, buf, len + 1); | ||||
| 						return sp + len - state.path.name; | ||||
| 					} | ||||
| 					if (*ip == '/') | ||||
| 						ip = (char*)memcpy(bp = state.path.name, ip, n); | ||||
| 					else if (ip > bp) | ||||
| 						*(ip - 1) = '/'; | ||||
| 					ip += n; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		/*
 | ||||
| 		 * restore last component | ||||
| 		 */ | ||||
| 
 | ||||
| 		if (!(type & P_READLINK)) | ||||
| 			strcpy(ip, buf); | ||||
| 		break; | ||||
| 	} | ||||
| 	return 0; | ||||
| } | ||||
|  | @ -1,49 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #include <cs.h> | ||||
| 
 | ||||
| /*
 | ||||
|  * peek siz chars from fd into buf | ||||
|  * if not peekable but seekable then chars are peeked at offset 0 | ||||
|  */ | ||||
| 
 | ||||
| ssize_t | ||||
| peek(int fd, void* buf, size_t siz) | ||||
| { | ||||
| 	register int	n; | ||||
| 
 | ||||
| 	n = cspeek(&cs, fd, buf, siz); | ||||
| 	if (n >= 0) | ||||
| 		return(n); | ||||
| 	cspeek(&cs, -1, NiL, 0); | ||||
| 	if (!FSTAT(fd, &state.path.st) && state.path.st.st_size <= siz) | ||||
| 	{ | ||||
| 		while ((n = read(fd, buf, siz)) != state.path.st.st_size && lseek(fd, 0L, 1) > 0 && lseek(fd, 0L, 0) == 0); | ||||
| 		if (n == state.path.st.st_size || n > 0 && !state.path.st.st_size) | ||||
| 			return(n); | ||||
| 	} | ||||
| 	return(-1); | ||||
| } | ||||
|  | @ -1,67 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef pipe3d | ||||
| 
 | ||||
| int | ||||
| pipe3d(int* fds) | ||||
| { | ||||
| 	int		r; | ||||
| #if !_mangle_syscall | ||||
| 	int		fd; | ||||
| #endif | ||||
| 
 | ||||
| 	initialize(); | ||||
| #if !_mangle_syscall | ||||
| 	if (r = (state.fs[FS_option].flags & FS_ON) != 0) state.fs[FS_option].flags &= ~FS_ON; | ||||
| 	for (fd = 0; fd < OPEN_MAX; fd++) | ||||
| 		if ((fds[0] = DUP(fd)) >= 0) | ||||
| 		{ | ||||
| 			fds[1] = DUP(fds[0]); | ||||
| 			CLOSE(fds[1]); | ||||
| 			CLOSE(fds[0]); | ||||
| 			break; | ||||
| 		} | ||||
| 	if (r) state.fs[FS_option].flags |= FS_ON; | ||||
| #endif | ||||
| 	r = PIPE(fds); | ||||
| #if FS | ||||
| 	if (!r && !state.in_2d) | ||||
| 	{ | ||||
| 		Mount_t*	mp; | ||||
| 
 | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_pipe)) | ||||
| 				fscall(mp, MSG_pipe, 0, fds); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(pipe) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,73 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef	read3d | ||||
| 
 | ||||
| ssize_t | ||||
| read3d(int fd, void* buf, size_t n) | ||||
| { | ||||
| 	register ssize_t 	r; | ||||
| #if FS | ||||
| 	Mount_t*		mp; | ||||
| 	off_t			off; | ||||
| 	int			pos = 0; | ||||
| 	 | ||||
| 	if (!fscall(NiL, MSG_read, 0, fd, buf, n)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	r = READ(fd, buf, n); | ||||
| #if FS | ||||
| 	if (r >= 0) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 		{ | ||||
| 			if (!pos) | ||||
| 			{ | ||||
| 				pos = 1; | ||||
| 				off = LSEEK(fd, 0, SEEK_CUR) - r; | ||||
| 			} | ||||
| 			fscall(mp, r, MSG_read3d, fd, buf, n, off); | ||||
| 		} | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_read)) | ||||
| 			{ | ||||
| 				if (!pos) | ||||
| 				{ | ||||
| 					pos = 1; | ||||
| 					off = LSEEK(fd, 0, SEEK_CUR) - r; | ||||
| 				} | ||||
| 				fscall(mp, MSG_read3d, r, fd, buf, n, off); | ||||
| 			} | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(read) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,68 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| ssize_t | ||||
| readlink3d(const char* path, char* buf, register size_t size) | ||||
| { | ||||
| 	size_t		r; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.in_2d) | ||||
| 		return(READLINK(path, buf, size)); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_readlink, 0, path, buf, size)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!pathreal(path, P_READLINK, NiL)) | ||||
| 		return(-1); | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * see if link text is already in memory | ||||
| 	 */ | ||||
| 
 | ||||
| 	if (r = state.path.linksize) | ||||
| 	{ | ||||
| 		if (r > state.path.linksize) | ||||
| 			r = state.path.linksize; | ||||
| 		memcpy(buf, state.path.linkname, r); | ||||
| #if FS | ||||
| 		if (mp) fscall(mp, MSG_readlink, r, path, buf, size); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_readlink)) | ||||
| 				fscall(mp, MSG_readlink, r, path, buf, size); | ||||
| #endif | ||||
| 		return(r); | ||||
| 	} | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * exists but not a symbolic link | ||||
| 	 */ | ||||
| 
 | ||||
| 	errno = EINVAL; | ||||
| 	return(-1); | ||||
| } | ||||
|  | @ -1,85 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| rename3d(const char* path, const char* target) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	char*		t; | ||||
| 	int		oerrno; | ||||
| 	char		buf[PATH_MAX+1]; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_rename, 0, path, target)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_TOP|P_LSTAT, NiL))) | ||||
| 		return(-1); | ||||
| 	strncpy(buf, sp, PATH_MAX); | ||||
| 	if (!(sp = pathreal(target, P_PATHONLY|P_NOOPAQUE, NiL))) | ||||
| 		return(-1); | ||||
| 	oerrno = errno; | ||||
| 	if ((r = RENAME(buf, sp)) && errno == ENOENT && (t = strrchr(sp, '/'))) | ||||
| 	{ | ||||
| 		*t = 0; | ||||
| 		r = fs3d_mkdir(sp, S_IRWXU|S_IRWXG|S_IRWXO); | ||||
| 		*t = '/'; | ||||
| 		if (!r) | ||||
| 		{ | ||||
| 			errno = oerrno; | ||||
| 			r = RENAME(buf, sp); | ||||
| 		} | ||||
| 	} | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 		{ | ||||
| 			if (sp != buf) | ||||
| 			{ | ||||
| 				if (!(sp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_ABSOLUTE, NiL))) | ||||
| 					return(r); | ||||
| 				sp = strncpy(buf, sp, PATH_MAX); | ||||
| 			} | ||||
| 			fscall(mp, MSG_rename, 0, path, sp); | ||||
| 		} | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_rename)) | ||||
| 			{ | ||||
| 				if (sp != buf) | ||||
| 				{ | ||||
| 					if (!(sp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_ABSOLUTE, NiL))) | ||||
| 						return(r); | ||||
| 					sp = strncpy(buf, sp, PATH_MAX); | ||||
| 				} | ||||
| 				fscall(mp, MSG_rename, 0, path, sp); | ||||
| 			} | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,133 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #include "dir_3d.h" | ||||
| 
 | ||||
| static int | ||||
| rmfiles(char* path, char* endpath, ino_t ino) | ||||
| { | ||||
| 	register DIRDIR*		dp; | ||||
| 	register struct DIRdirent*	ep; | ||||
| 	register char*			s; | ||||
| 	register char*			t; | ||||
| 	int				pass = 0; | ||||
| 
 | ||||
| 	*endpath = 0; | ||||
| 	if (!(dp = OPENDIR(path))) return(0); | ||||
| 	*endpath++ = '/'; | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		if (!(ep = (struct DIRdirent*)READDIR(dp))) | ||||
| 		{ | ||||
| 			if (pass++) | ||||
| 			{ | ||||
| 				CLOSEDIR(dp); | ||||
| 				return(1); | ||||
| 			} | ||||
| 			SEEKDIR(dp, 0L); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| #ifdef D_FILENO | ||||
| 			if (D_FILENO(ep) != ino) | ||||
| #else | ||||
| 			struct stat	st; | ||||
| 
 | ||||
| 			strcpy(endpath, ep->d_name); | ||||
| 			if (STAT(path, &st)) break; | ||||
| 			if (st.st_ino != ino) | ||||
| #endif | ||||
| 			{ | ||||
| 				s = state.opaque; | ||||
| 				t = ep->d_name; | ||||
| 				while (*s && *s++ == *t) t++; | ||||
| 				if (*s || *t) break; | ||||
| 			} | ||||
| 			else if (pass) | ||||
| 			{ | ||||
| #ifdef D_FILENO | ||||
| 				strcpy(endpath, ep->d_name); | ||||
| #endif | ||||
| 				if (UNLINK(path)) break; | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 	CLOSEDIR(dp); | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| rmdir3d(const char* path) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	int		pass = 0; | ||||
| 	struct stat	st; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_rmdir, 0, path)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_PATHONLY, NiL))) | ||||
| 		return(-1); | ||||
| 	if (state.path.level) | ||||
| 		return(0); | ||||
|  retry: | ||||
| 	r = RMDIR(sp); | ||||
| 	if (!r) | ||||
| 	{ | ||||
| #if FS | ||||
| 		if (mp) fscall(mp, MSG_rmdir, 0, path); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_rmdir)) | ||||
| 				fscall(mp, MSG_rmdir, 0, path); | ||||
| #endif | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		if (errno == ENOENT && pathreal(path, 0, NiL)) | ||||
| 			return(0); | ||||
| 		if (errno == ENOTEMPTY && !pass++) | ||||
| 		{ | ||||
| 			register char*	slast = sp; | ||||
| 
 | ||||
| 			while (*slast) slast++; | ||||
| 			*slast = '/'; | ||||
| 			strcpy(slast+1, state.opaque); | ||||
| 			if (!LSTAT(sp, &st)) | ||||
| 			{ | ||||
| 				if (rmfiles(sp, slast, st.st_ino)) | ||||
| 				{ | ||||
| 					*slast = 0; | ||||
| 					goto retry; | ||||
| 				} | ||||
| 			} | ||||
| 			else errno = ENOTEMPTY; | ||||
| 		} | ||||
| 	} | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,50 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef	sbrk3d | ||||
| 
 | ||||
| void* | ||||
| sbrk3d(ssize_t i) | ||||
| { | ||||
| #if FS | ||||
| 	register Mount_t*	mp; | ||||
| 	void*			p; | ||||
| 
 | ||||
| 	initialize(); | ||||
| 	if ((p = SBRK(i)) != (void*)(-1)) | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_break)) | ||||
| 				fscall(mp, MSG_break, 0, p); | ||||
| 	return(p); | ||||
| #else | ||||
| 	return(SBRK(i)); | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(sbrk) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,138 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma noprototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| /* the 3 arg _xstat() disrupts our proto game -- every party needs one */ | ||||
| #if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) | ||||
| int stat3d(const char* path, struct stat* st) | ||||
| #else | ||||
| #if defined(_STAT) | ||||
| int _stat(path, st) char* path; struct stat* st; { return stat(path, st); } | ||||
| #endif | ||||
| int stat(path, st) char* path; struct stat* st; | ||||
| #endif | ||||
| { | ||||
| 	register char*	sp; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| #ifdef _3D_STAT_VER | ||||
| 	struct stat*	so; | ||||
| 	struct stat	sc; | ||||
| #endif | ||||
| 
 | ||||
| #ifdef _3D_STAT_VER | ||||
| 	if (_3d_ver != _3D_STAT_VER) | ||||
| 	{ | ||||
| 		so = st; | ||||
| 		st = ≻ | ||||
| 	} | ||||
| #endif | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_stat, 0, path, st)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, st))) | ||||
| 		return -1; | ||||
| 	if (S_ISLNK(st->st_mode)) | ||||
| 	{ | ||||
| #ifdef _3D_STAT_VER | ||||
| 		if (st == &sc) | ||||
| 			st = so; | ||||
| 		if (XSTAT(_3d_ver, sp, st)) | ||||
| 			return -1; | ||||
| #ifdef _3D_STAT64_VER | ||||
| 		if (_3d_ver == _3D_STAT64_VER) | ||||
| 			IVIEW(((struct stat64*)st), state.path.level); | ||||
| 		else | ||||
| #endif | ||||
| #else | ||||
| 		if (STAT(sp, st)) | ||||
| 			return -1; | ||||
| #endif | ||||
| 		IVIEW(st, state.path.level); | ||||
| 	} | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_stat, 0, state.path.name, st); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_stat)) | ||||
| 			fscall(mp, MSG_stat, 0, state.path.name, st); | ||||
| #endif | ||||
| #ifdef _3D_STAT_VER | ||||
| 	if (st == &sc) | ||||
| 	{ | ||||
| 		st = so; | ||||
| 		if (XSTAT(_3d_ver, sp, st)) | ||||
| 			return -1; | ||||
| #ifdef _3D_STAT64_VER | ||||
| 		if (_3d_ver == _3D_STAT64_VER) | ||||
| 			IVIEW(((struct stat64*)st), state.path.level); | ||||
| 		else | ||||
| #endif | ||||
| 		IVIEW(st, state.path.level); | ||||
| 	} | ||||
| #endif | ||||
| #if _mem_d_type_dirent | ||||
| 	if (S_ISDIR(st->st_mode)) | ||||
| 		st->st_nlink = _3D_LINK_MAX; | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #if defined(_LARGEFILE64_SOURCE) && defined(STAT643D) && !defined(_3D_STAT64_VER) | ||||
| 
 | ||||
| int | ||||
| stat643d(const char* path, struct stat64* st) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	struct stat	ss; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_stat, 0, path, &ss)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, &ss))) | ||||
| 		return -1; | ||||
| 	if (STAT64(sp, st)) | ||||
| 		return -1; | ||||
| 	IVIEW(st, state.path.level); | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_stat, 0, state.path.name, &ss); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_stat)) | ||||
| 			fscall(mp, MSG_stat, 0, state.path.name, &ss); | ||||
| #endif | ||||
| #if _mem_d_type_dirent | ||||
| 	if (S_ISDIR(st->st_mode)) | ||||
| 		st->st_nlink = _3D_LINK_MAX; | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,182 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide statfs | ||||
| #else | ||||
| #define statfs        ______statfs | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if defined(statfs3d) && ( _sys_statfs || _sys_vfs || _sys_mount && _mem_f_files_statfs ) | ||||
| 
 | ||||
| #include <cs_lib.h> | ||||
| 
 | ||||
| #if _sys_statfs | ||||
| #include <sys/statfs.h> | ||||
| #else | ||||
| #if _sys_vfs | ||||
| #include <sys/vfs.h> | ||||
| #define _vfs_statfs	1 | ||||
| #else | ||||
| #if _sys_mount | ||||
| #if _lib_getmntinfo | ||||
| #include <sys/param.h>		/* expect some macro redefinitions here */ | ||||
| #endif | ||||
| #include <sys/mount.h> | ||||
| #endif | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide statfs | ||||
| #else | ||||
| #undef  statfs | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| #if _vfs_statfs | ||||
| #define VFS	(fs) | ||||
| #else | ||||
| #define VFS	(&vfs) | ||||
| #endif | ||||
| 
 | ||||
| #if ARG3D_statfs == 4 | ||||
| 
 | ||||
| int | ||||
| statfs3d(const char* path, struct statfs* fs, int size, int type) | ||||
| { | ||||
| 	register char*	sp; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #if !_vfs_statfs | ||||
| 	struct statvfs	vfs; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_statfs, 0, path, VFS, size, type)) | ||||
| 	{ | ||||
| #if !_vfs_statfs | ||||
| 		if (!state.ret) | ||||
| 		{ | ||||
| 			memset(fs, 0, sizeof(*fs)); | ||||
| 			fs->f_bsize = vfs.f_bsize; | ||||
| 			fs->f_blocks = vfs.f_blocks; | ||||
| 			fs->f_bfree = vfs.f_bfree; | ||||
| 			fs->f_files = vfs.f_files; | ||||
| 			fs->f_ffree = vfs.f_ffree; | ||||
| 		} | ||||
| #endif | ||||
| 		return state.ret; | ||||
| 	} | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, NiL))) | ||||
| 		return -1; | ||||
| 	if (STATFS(sp, fs, size, type)) | ||||
| 		return -1; | ||||
| #if FS | ||||
| #if !_vfs_statfs | ||||
| 	if (mp || state.global) | ||||
| 	{ | ||||
| 		memset(&vfs, 0, sizeof(vfs)); | ||||
| 		vfs.f_bsize = fs->f_bsize; | ||||
| 		vfs.f_blocks = fs->f_blocks; | ||||
| 		vfs.f_bfree = fs->f_bfree; | ||||
| 		vfs.f_files = fs->f_files; | ||||
| 		vfs.f_ffree = fs->f_ffree; | ||||
| 	} | ||||
| #endif | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_statfs, 0, state.path.name, VFS, size, type); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_statfs)) | ||||
| 			fscall(mp, MSG_statfs, 0, state.path.name, VFS, size, type); | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| int | ||||
| statfs3d(const char* path, struct statfs* fs) | ||||
| { | ||||
| 	register char*	sp; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #if !_vfs_statfs | ||||
| 	struct statvfs	vfs; | ||||
| #endif | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_statfs, 0, path, VFS)) | ||||
| 	{ | ||||
| #if !_vfs_statfs | ||||
| 		if (!state.ret) | ||||
| 		{ | ||||
| 			memset(fs, 0, sizeof(*fs)); | ||||
| 			fs->f_bsize = vfs.f_bsize; | ||||
| 			fs->f_blocks = vfs.f_blocks; | ||||
| 			fs->f_bfree = vfs.f_bfree; | ||||
| 			fs->f_files = vfs.f_files; | ||||
| 			fs->f_ffree = vfs.f_ffree; | ||||
| 		} | ||||
| #endif | ||||
| 		return state.ret; | ||||
| 	} | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, NiL))) | ||||
| 		return -1; | ||||
| 	if (STATFS(sp, fs)) | ||||
| 		return -1; | ||||
| #if FS | ||||
| #if !_vfs_statfs | ||||
| 	if (mp || state.global) | ||||
| 	{ | ||||
| 		memset(&vfs, 0, sizeof(vfs)); | ||||
| 		vfs.f_bsize = fs->f_bsize; | ||||
| 		vfs.f_blocks = fs->f_blocks; | ||||
| 		vfs.f_bfree = fs->f_bfree; | ||||
| 		vfs.f_files = fs->f_files; | ||||
| 		vfs.f_ffree = fs->f_ffree; | ||||
| 	} | ||||
| #endif | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_statfs, 0, state.path.name, VFS); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_statfs)) | ||||
| 			fscall(mp, MSG_statfs, 0, state.path.name, VFS); | ||||
| #endif | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(statfs) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,57 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if defined(statvfs3d) && defined(_sys_statvfs) | ||||
| 
 | ||||
| int | ||||
| statvfs3d(const char* path, struct statvfs* fs) | ||||
| { | ||||
| 	register char*	sp; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_statfs, 0, path, fs)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, 0, NiL))) | ||||
| 		return(-1); | ||||
| 	if (STATVFS(sp, fs)) | ||||
| 		return(-1); | ||||
| #if FS | ||||
| 	if (mp) | ||||
| 		fscall(mp, MSG_statfs, 0, state.path.name, fs); | ||||
| 	for (mp = state.global; mp; mp = mp->global) | ||||
| 		if (fssys(mp, MSG_statfs)) | ||||
| 			fscall(mp, MSG_statfs, 0, state.path.name, fs); | ||||
| #endif | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(statvfs) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,34 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| /*
 | ||||
|  * std 3d symbol mappings | ||||
|  * | ||||
|  * NOTE: include once before std headers and once after | ||||
|  *	 to make sure our slimey tricks win | ||||
|  */ | ||||
| 
 | ||||
| #undef	remove | ||||
| #define remove		unlink | ||||
| 
 | ||||
| #undef	sfsprintf | ||||
| #define sfsprintf	_3d_sfsprintf | ||||
|  | @ -1,810 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * NOTE: obsolete strmatch() for 3d private use | ||||
|  *	 -last strmatch() based on <regex.h> for external use | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * D. G. Korn | ||||
|  * G. S. Fowler | ||||
|  * AT&T Research | ||||
|  * | ||||
|  * match shell file patterns -- derived from Bourne and Korn shell gmatch() | ||||
|  * | ||||
|  *	sh pattern	egrep RE	description | ||||
|  *	----------	--------	----------- | ||||
|  *	*		.*		0 or more chars | ||||
|  *	?		.		any single char | ||||
|  *	[.]		[.]		char class | ||||
|  *	[!.]		[^.]		negated char class | ||||
|  *	[[:.:]]		[[:.:]]		ctype class | ||||
|  *	[[=.=]]		[[=.=]]		equivalence class | ||||
|  *	[[...]]		[[...]]		collation element | ||||
|  *	*(.)		(.)*		0 or more of | ||||
|  *	+(.)		(.)+		1 or more of | ||||
|  *	?(.)		(.)?		0 or 1 of | ||||
|  *	(.)		(.)		1 of | ||||
|  *	@(.)		(.)		1 of | ||||
|  *	a|b		a|b		a or b | ||||
|  *	\#				() subgroup back reference [1-9] | ||||
|  *	a&b				a and b | ||||
|  *	!(.)				none of | ||||
|  * | ||||
|  * \ used to escape metacharacters | ||||
|  * | ||||
|  *	*, ?, (, |, &, ), [, \ must be \'d outside of [...] | ||||
|  *	only ] must be \'d inside [...] | ||||
|  * | ||||
|  * BUG: unbalanced ) terminates top level pattern | ||||
|  * | ||||
|  * BOTCH: collating element sort order and character class ranges apparently | ||||
|  *	  do not have strcoll() in common so we resort to fnmatch(), calling | ||||
|  *	  it up to COLL_MAX times to determine the matched collating | ||||
|  *	  element size | ||||
|  */ | ||||
| 
 | ||||
| #include <ast.h> | ||||
| #include <ctype.h> | ||||
| #include <hashkey.h> | ||||
| 
 | ||||
| #undef	_lib_fnmatch	/* 3d */ | ||||
| #undef	_lib_mbtowc	/* 3d */ | ||||
| 
 | ||||
| #define strgrpmatch	_3d_strgrpmatch | ||||
| 
 | ||||
| #if _hdr_wchar && _lib_wctype && _lib_iswctype | ||||
| 
 | ||||
| #include <stdio.h> /* because <wchar.h> includes it and we generate it */ | ||||
| #include <wchar.h> | ||||
| #if _hdr_wctype | ||||
| #include <wctype.h> | ||||
| #endif | ||||
| 
 | ||||
| #undef	isalnum | ||||
| #define isalnum(x)	iswalnum(x) | ||||
| #undef	isalpha | ||||
| #define isalpha(x)	iswalpha(x) | ||||
| #undef	iscntrl | ||||
| #define iscntrl(x)	iswcntrl(x) | ||||
| #undef	isblank | ||||
| #define isblank(x)	iswblank(x) | ||||
| #undef	isdigit | ||||
| #define isdigit(x)	iswdigit(x) | ||||
| #undef	isgraph | ||||
| #define isgraph(x)	iswgraph(x) | ||||
| #undef	islower | ||||
| #define islower(x)	iswlower(x) | ||||
| #undef	isprint | ||||
| #define isprint(x)	iswprint(x) | ||||
| #undef	ispunct | ||||
| #define ispunct(x)	iswpunct(x) | ||||
| #undef	isspace | ||||
| #define isspace(x)	iswspace(x) | ||||
| #undef	isupper | ||||
| #define isupper(x)	iswupper(x) | ||||
| #undef	isxdigit | ||||
| #define isxdigit(x)	iswxdigit(x) | ||||
| 
 | ||||
| #if !defined(iswblank) && !_lib_iswblank | ||||
| 
 | ||||
| static int | ||||
| iswblank(wint_t wc) | ||||
| { | ||||
| 	static int	initialized; | ||||
| 	static wctype_t	wt; | ||||
| 
 | ||||
| 	if (!initialized) | ||||
| 	{ | ||||
| 		initialized = 1; | ||||
| 		wt = wctype("blank"); | ||||
| 	} | ||||
| 	return iswctype(wc, wt); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| #undef	_lib_wctype | ||||
| 
 | ||||
| #ifndef	isblank | ||||
| #define	isblank(x)	((x)==' '||(x)=='\t') | ||||
| #endif | ||||
| 
 | ||||
| #ifndef isgraph | ||||
| #define	isgraph(x)	(isprint(x)&&!isblank(x)) | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #if _DEBUG_MATCH | ||||
| #include <error.h> | ||||
| #endif | ||||
| 
 | ||||
| #define MAXGROUP	10 | ||||
| 
 | ||||
| typedef struct Group_s | ||||
| { | ||||
| 	char*		beg[MAXGROUP]; | ||||
| 	char*		end[MAXGROUP]; | ||||
| 	char*		next_s; | ||||
| 	short		groups; | ||||
| } Group_t; | ||||
| 
 | ||||
| typedef struct Match_s | ||||
| { | ||||
| 	Group_t		current; | ||||
| 	Group_t		best; | ||||
| 	char*		last_s; | ||||
| 	char*		next_p; | ||||
| } Match_t; | ||||
| 
 | ||||
| #if _lib_mbtowc && MB_LEN_MAX > 1 | ||||
| #define mbgetchar(p)	((ast.locale.set&LC_SET_CTYPE)?((ast.tmp_int=mbtowc(&ast.tmp_wchar,p,MB_CUR_MAX))>=0?((p+=ast.tmp_int),ast.tmp_wchar):0):(*p++)) | ||||
| #else | ||||
| #define mbgetchar(p)	(*p++) | ||||
| #endif | ||||
| 
 | ||||
| #ifndef isxdigit | ||||
| #define isxdigit(c)	((c)>='0'&&(c)<='9'||(c)>='a'&&(c)<='f'||(c)>='A'&&(c)<='F') | ||||
| #endif | ||||
| 
 | ||||
| #define getsource(s,e)	(((s)>=(e))?0:mbgetchar(s)) | ||||
| 
 | ||||
| #define COLL_MAX	3 | ||||
| 
 | ||||
| #if !_lib_strcoll | ||||
| #undef	_lib_fnmatch | ||||
| #endif | ||||
| 
 | ||||
| #if _lib_fnmatch | ||||
| extern int		fnmatch(const char*, const char*, int); | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * gobble chars up to <sub> or ) keeping track of (...) and [...] | ||||
|  * sub must be one of { '|', '&', 0 } | ||||
|  * 0 returned if s runs out | ||||
|  */ | ||||
| 
 | ||||
| static char* | ||||
| gobble(Match_t* mp, register char* s, register int sub, int* g, int clear) | ||||
| { | ||||
| 	register int	p = 0; | ||||
| 	register char*	b = 0; | ||||
| 	int		c = 0; | ||||
| 	int		n; | ||||
| 
 | ||||
| 	for (;;) | ||||
| 		switch (mbgetchar(s)) | ||||
| 		{ | ||||
| 		case '\\': | ||||
| 			if (mbgetchar(s)) | ||||
| 				break; | ||||
| 			/*FALLTHROUGH*/ | ||||
| 		case 0: | ||||
| 			return 0; | ||||
| 		case '[': | ||||
| 			if (!b) | ||||
| 			{ | ||||
| 				if (*s == '!') | ||||
| 					mbgetchar(s); | ||||
| 				b = s; | ||||
| 			} | ||||
| 			else if (*s == '.' || *s == '=' || *s == ':') | ||||
| 				c = *s; | ||||
| 			break; | ||||
| 		case ']': | ||||
| 			if (b) | ||||
| 			{ | ||||
| 				if (*(s - 2) == c) | ||||
| 					c = 0; | ||||
| 				else if (b != (s - 1)) | ||||
| 					b = 0; | ||||
| 			} | ||||
| 			break; | ||||
| 		case '(': | ||||
| 			if (!b) | ||||
| 			{ | ||||
| 				p++; | ||||
| 				n = (*g)++; | ||||
| 				if (clear) | ||||
| 				{ | ||||
| 					if (!sub) | ||||
| 						n++; | ||||
| 					if (n < MAXGROUP) | ||||
| 						mp->current.beg[n] = mp->current.end[n] = 0; | ||||
| 				} | ||||
| 			} | ||||
| 			break; | ||||
| 		case ')': | ||||
| 			if (!b && p-- <= 0) | ||||
| 				return sub ? 0 : s; | ||||
| 			break; | ||||
| 		case '|': | ||||
| 			if (!b && !p && sub == '|') | ||||
| 				return s; | ||||
| 			break; | ||||
| 		} | ||||
| } | ||||
| 
 | ||||
| static int	grpmatch(Match_t*, int, char*, register char*, char*, int); | ||||
| 
 | ||||
| #if _DEBUG_MATCH | ||||
| static long		test; | ||||
| 
 | ||||
| #define return x)	do{error_info.indent--;return(x;}while(0) | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * match a single pattern | ||||
|  * e is the end (0) of the substring in s | ||||
|  * r marks the start of a repeated subgroup pattern | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| onematch(Match_t* mp, int g, char* s, char* p, char* e, char* r, int flags) | ||||
| { | ||||
| 	register int 	pc; | ||||
| 	register int 	sc; | ||||
| 	register int	n; | ||||
| 	register int	icase; | ||||
| 	char*		olds; | ||||
| 	char*		oldp; | ||||
| 
 | ||||
| #if _DEBUG_MATCH | ||||
| 	error_info.indent++; | ||||
| 	error(-1, "onematch g=%d s=%-.*s p=%s r=%p flags=%o", g, e - s, s, p, r, flags); | ||||
| #endif | ||||
| 	icase = flags & STR_ICASE; | ||||
| 	do | ||||
| 	{ | ||||
| 		olds = s; | ||||
| 		sc = getsource(s, e); | ||||
| 		if (icase && isupper(sc)) | ||||
| 			sc = tolower(sc); | ||||
| 		oldp = p; | ||||
| 		switch (pc = mbgetchar(p)) | ||||
| 		{ | ||||
| 		case '(': | ||||
| 		case '*': | ||||
| 		case '?': | ||||
| 		case '+': | ||||
| 		case '@': | ||||
| 		case '!': | ||||
| 			if (pc == '(' || *p == '(') | ||||
| 			{ | ||||
| 				char*	subp; | ||||
| 				int	oldg; | ||||
| 
 | ||||
| 				s = olds; | ||||
| 				subp = p + (pc != '('); | ||||
| 				oldg = g; | ||||
| 				n = ++g; | ||||
| 				if (g < MAXGROUP && (!r || g > mp->current.groups)) | ||||
| 					mp->current.beg[g] = mp->current.end[g] = 0; | ||||
| 				if (!(p = gobble(mp, subp, 0, &g, !r))) | ||||
| 					return 0; | ||||
| 				if (pc == '*' || pc == '?' || pc == '+' && oldp == r) | ||||
| 				{ | ||||
| 					if (onematch(mp, g, s, p, e, NiL, flags)) | ||||
| 						return 1; | ||||
| 					if (!sc || !getsource(s, e)) | ||||
| 					{ | ||||
| 						mp->current.groups = oldg; | ||||
| 						return 0; | ||||
| 					} | ||||
| 				} | ||||
| 				if (pc == '*' || pc == '+') | ||||
| 				{ | ||||
| 					p = oldp; | ||||
| 					sc = n - 1; | ||||
| 				} | ||||
| 				else | ||||
| 					sc = g; | ||||
| 				pc = (pc != '!'); | ||||
| 				do | ||||
| 				{ | ||||
| 					if (grpmatch(mp, n, olds, subp, s, flags) == pc) | ||||
| 					{ | ||||
| 						if (n < MAXGROUP) | ||||
| 						{ | ||||
| 							if (!mp->current.beg[n] || mp->current.beg[n] > olds) | ||||
| 								mp->current.beg[n] = olds; | ||||
| 							if (s > mp->current.end[n]) | ||||
| 								mp->current.end[n] = s; | ||||
| #if _DEBUG_MATCH | ||||
| 							error(-4, "subgroup#%d n=%d beg=%p end=%p len=%d", __LINE__, n, mp->current.beg[n], mp->current.end[n], mp->current.end[n] - mp->current.beg[n]); | ||||
| #endif | ||||
| 						} | ||||
| 						if (onematch(mp, sc, s, p, e, oldp, flags)) | ||||
| 						{ | ||||
| 							if (p == oldp && n < MAXGROUP) | ||||
| 							{ | ||||
| 								if (!mp->current.beg[n] || mp->current.beg[n] > olds) | ||||
| 									mp->current.beg[n] = olds; | ||||
| 								if (s > mp->current.end[n]) | ||||
| 									mp->current.end[n] = s; | ||||
| #if _DEBUG_MATCH | ||||
| 								error(-4, "subgroup#%d n=%d beg=%p end=%p len=%d", __LINE__, n, mp->current.beg[n], mp->current.end[n], mp->current.end[n] - mp->current.beg[n]); | ||||
| #endif | ||||
| 							} | ||||
| 							return 1; | ||||
| 						} | ||||
| 					} | ||||
| 				} while (s < e && mbgetchar(s)); | ||||
| 				mp->current.groups = oldg; | ||||
| 				return 0; | ||||
| 			} | ||||
| 			else if (pc == '*') | ||||
| 			{ | ||||
| 				/*
 | ||||
| 				 * several stars are the same as one | ||||
| 				 */ | ||||
| 
 | ||||
| 				while (*p == '*' && *(p + 1) != '(') | ||||
| 					p++; | ||||
| 				oldp = p; | ||||
| 				switch (pc = mbgetchar(p)) | ||||
| 				{ | ||||
| 				case '@': | ||||
| 				case '!': | ||||
| 				case '+': | ||||
| 					n = *p == '('; | ||||
| 					break; | ||||
| 				case '(': | ||||
| 				case '[': | ||||
| 				case '?': | ||||
| 				case '*': | ||||
| 					n = 1; | ||||
| 					break; | ||||
| 				case 0: | ||||
| 				case '|': | ||||
| 				case '&': | ||||
| 				case ')': | ||||
| 					mp->current.next_s = (flags & STR_MAXIMAL) ? e : olds; | ||||
| 					mp->next_p = oldp; | ||||
| 					mp->current.groups = g; | ||||
| 					if (!pc && (!mp->best.next_s || (flags & STR_MAXIMAL) && mp->current.next_s > mp->best.next_s || !(flags & STR_MAXIMAL) && mp->current.next_s < mp->best.next_s)) | ||||
| 					{ | ||||
| 						mp->best = mp->current; | ||||
| #if _DEBUG_MATCH | ||||
| 						error(-3, "best#%d groups=%d next=\"%s\"", __LINE__, mp->best.groups, mp->best.next_s); | ||||
| #endif | ||||
| 					} | ||||
| 					return 1; | ||||
| 				case '\\': | ||||
| 					if (!(pc = mbgetchar(p))) | ||||
| 						return 0; | ||||
| 					if (pc >= '0' && pc <= '9') | ||||
| 					{ | ||||
| 						n = pc - '0'; | ||||
| #if _DEBUG_MATCH | ||||
| 						error(-2, "backref#%d n=%d g=%d beg=%p end=%p len=%d", __LINE__, n, g, mp->current.beg[n], mp->current.end[n], mp->current.end[n] - mp->current.beg[n]); | ||||
| #endif | ||||
| 						if (n <= g && mp->current.beg[n]) | ||||
| 							pc = *mp->current.beg[n]; | ||||
| 					} | ||||
| 					/*FALLTHROUGH*/ | ||||
| 				default: | ||||
| 					if (icase && isupper(pc)) | ||||
| 						pc = tolower(pc); | ||||
| 					n = 0; | ||||
| 					break; | ||||
| 				} | ||||
| 				p = oldp; | ||||
| 				for (;;) | ||||
| 				{ | ||||
| 					if ((n || pc == sc) && onematch(mp, g, olds, p, e, NiL, flags)) | ||||
| 						return 1; | ||||
| 					if (!sc) | ||||
| 						return 0; | ||||
| 					olds = s; | ||||
| 					sc = getsource(s, e); | ||||
| 					if ((flags & STR_ICASE) && isupper(sc)) | ||||
| 						sc = tolower(sc); | ||||
| 				} | ||||
| 			} | ||||
| 			else if (pc != '?' && pc != sc) | ||||
| 				return 0; | ||||
| 			break; | ||||
| 		case 0: | ||||
| 			if (!(flags & STR_MAXIMAL)) | ||||
| 				sc = 0; | ||||
| 			/*FALLTHROUGH*/ | ||||
| 		case '|': | ||||
| 		case '&': | ||||
| 		case ')': | ||||
| 			if (!sc) | ||||
| 			{ | ||||
| 				mp->current.next_s = olds; | ||||
| 				mp->next_p = oldp; | ||||
| 				mp->current.groups = g; | ||||
| 			} | ||||
| 			if (!pc && (!mp->best.next_s || (flags & STR_MAXIMAL) && olds > mp->best.next_s || !(flags & STR_MAXIMAL) && olds < mp->best.next_s)) | ||||
| 			{ | ||||
| 				mp->best = mp->current; | ||||
| 				mp->best.next_s = olds; | ||||
| 				mp->best.groups = g; | ||||
| #if _DEBUG_MATCH | ||||
| 				error(-3, "best#%d groups=%d next=\"%s\"", __LINE__, mp->best.groups, mp->best.next_s); | ||||
| #endif | ||||
| 			} | ||||
| 			return !sc; | ||||
| 		case '[': | ||||
| 			{ | ||||
| 				/*UNDENT...*/ | ||||
| 
 | ||||
| 	int	invert; | ||||
| 	int	x; | ||||
| 	int	ok = 0; | ||||
| 	char*	range; | ||||
| 
 | ||||
| 	if (!sc) | ||||
| 		return 0; | ||||
| #if _lib_fnmatch | ||||
| 	if (ast.locale.set & LC_SET_COLLATE) | ||||
| 		range = p - 1; | ||||
| 	else | ||||
| #endif | ||||
| 	range = 0; | ||||
| 	n = 0; | ||||
| 	if (invert = *p == '!') | ||||
| 		p++; | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		oldp = p; | ||||
| 		if (!(pc = mbgetchar(p))) | ||||
| 			return 0; | ||||
| 		else if (pc == '[' && (*p == ':' || *p == '=' || *p == '.')) | ||||
| 		{ | ||||
| 			x = 0; | ||||
| 			n = mbgetchar(p); | ||||
| 			oldp = p; | ||||
| 			for (;;) | ||||
| 			{ | ||||
| 				if (!(pc = mbgetchar(p))) | ||||
| 					return 0; | ||||
| 				if (pc == n && *p == ']') | ||||
| 					break; | ||||
| 				x++; | ||||
| 			} | ||||
| 			mbgetchar(p); | ||||
| 			if (ok) | ||||
| 				/*NOP*/; | ||||
| 			else if (n == ':') | ||||
| 			{ | ||||
| 				switch (HASHNKEY5(x, oldp[0], oldp[1], oldp[2], oldp[3], oldp[4])) | ||||
| 				{ | ||||
| 				case HASHNKEY5(5,'a','l','n','u','m'): | ||||
| 					if (isalnum(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'a','l','p','h','a'): | ||||
| 					if (isalpha(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'b','l','a','n','k'): | ||||
| 					if (isblank(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'c','n','t','r','l'): | ||||
| 					if (iscntrl(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'d','i','g','i','t'): | ||||
| 					if (isdigit(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'g','r','a','p','h'): | ||||
| 					if (isgraph(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'l','o','w','e','r'): | ||||
| 					if (islower(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'p','r','i','n','t'): | ||||
| 					if (isprint(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'p','u','n','c','t'): | ||||
| 					if (ispunct(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'s','p','a','c','e'): | ||||
| 					if (isspace(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(5,'u','p','p','e','r'): | ||||
| 					if (icase ? islower(sc) : isupper(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| 				case HASHNKEY5(6,'x','d','i','g','i'): | ||||
| 					if (oldp[5] == 't' && isxdigit(sc)) | ||||
| 						ok = 1; | ||||
| 					break; | ||||
| #if _lib_wctype | ||||
| 				default: | ||||
| 					{ | ||||
| 						char	cc[32]; | ||||
| 
 | ||||
| 						if (x >= sizeof(cc)) | ||||
| 							x = sizeof(cc) - 1; | ||||
| 						strncpy(cc, oldp, x); | ||||
| 						cc[x] = 0; | ||||
| 						if (iswctype(sc, wctype(cc))) | ||||
| 							ok = 1; | ||||
| 					} | ||||
| 					break; | ||||
| #endif | ||||
| 				} | ||||
| 			} | ||||
| #if _lib_fnmatch | ||||
| 			else if (ast.locale.set & LC_SET_COLLATE) | ||||
| 				ok = -1; | ||||
| #endif | ||||
| 			else if (range) | ||||
| 				goto getrange; | ||||
| 			else if (*p == '-' && *(p + 1) != ']') | ||||
| 			{ | ||||
| 				mbgetchar(p); | ||||
| 				range = oldp; | ||||
| 			} | ||||
| 			else if (isalpha(*oldp) && isalpha(*olds) && tolower(*oldp) == tolower(*olds) || sc == mbgetchar(oldp)) | ||||
| 				ok = 1; | ||||
| 			n = 1; | ||||
| 		} | ||||
| 		else if (pc == ']' && n) | ||||
| 		{ | ||||
| #if _lib_fnmatch | ||||
| 			if (ok < 0) | ||||
| 			{ | ||||
| 				char	pat[2 * UCHAR_MAX]; | ||||
| 				char	str[COLL_MAX + 1]; | ||||
| 
 | ||||
| 				if (p - range > sizeof(pat) - 2) | ||||
| 					return 0; | ||||
| 				memcpy(pat, range, p - range); | ||||
| 				pat[p - range] = '*'; | ||||
| 				pat[p - range + 1] = 0; | ||||
| 				if (fnmatch(pat, olds, 0)) | ||||
| 					return 0; | ||||
| 				pat[p - range] = 0; | ||||
| 				ok = 0; | ||||
| 				for (x = 0; x < sizeof(str) - 1 && olds[x]; x++) | ||||
| 				{ | ||||
| 					str[x] = olds[x]; | ||||
| 					str[x + 1] = 0; | ||||
| 					if (!fnmatch(pat, str, 0)) | ||||
| 						ok = 1; | ||||
| 					else if (ok) | ||||
| 						break; | ||||
| 				} | ||||
| 				s = olds + x; | ||||
| 				break; | ||||
| 			} | ||||
| #endif | ||||
| 			if (ok != invert) | ||||
| 				break; | ||||
| 			return 0; | ||||
| 		} | ||||
| 		else if (pc == '\\' && (oldp = p, !(pc = mbgetchar(p)))) | ||||
| 			return 0; | ||||
| 		else if (ok) | ||||
| 			/*NOP*/; | ||||
| #if _lib_fnmatch | ||||
| 		else if (range && !(ast.locale.set & LC_SET_COLLATE)) | ||||
| #else | ||||
| 		else if (range) | ||||
| #endif | ||||
| 		{ | ||||
| 		getrange: | ||||
| #if _lib_mbtowc | ||||
| 			if (ast.locale.set & LC_SET_CTYPE) | ||||
| 			{ | ||||
| 				wchar_t	sw; | ||||
| 				wchar_t	bw; | ||||
| 				wchar_t	ew; | ||||
| 				int	sz; | ||||
| 				int	bz; | ||||
| 				int	ez; | ||||
| 
 | ||||
| 				sz = mbtowc(&sw, olds, MB_CUR_MAX); | ||||
| 				bz = mbtowc(&bw, range, MB_CUR_MAX); | ||||
| 				ez = mbtowc(&ew, oldp, MB_CUR_MAX); | ||||
| 				if (sw == bw || sw == ew) | ||||
| 					ok = 1; | ||||
| 				else if (sz > 1 || bz > 1 || ez > 1) | ||||
| 				{ | ||||
| 					if (sz == bz && sz == ez && sw > bw && sw < ew) | ||||
| 						ok = 1; | ||||
| 					else | ||||
| 						return 0; | ||||
| 				} | ||||
| 			} | ||||
| 			if (!ok) | ||||
| #endif | ||||
| 			if (icase && isupper(pc)) | ||||
| 				pc = tolower(pc); | ||||
| 			x = mbgetchar(range); | ||||
| 			if (icase && isupper(x)) | ||||
| 				x = tolower(x); | ||||
| 			if (sc == x || sc == pc || sc > x && sc < pc) | ||||
| 				ok = 1; | ||||
| 			if (*p == '-' && *(p + 1) != ']') | ||||
| 			{ | ||||
| 				mbgetchar(p); | ||||
| 				range = oldp; | ||||
| 			} | ||||
| 			else | ||||
| 				range = 0; | ||||
| 			n = 1; | ||||
| 		} | ||||
| 		else if (*p == '-' && *(p + 1) != ']') | ||||
| 		{ | ||||
| 			mbgetchar(p); | ||||
| #if _lib_fnmatch | ||||
| 			if (ast.locale.set & LC_SET_COLLATE) ok = -1; | ||||
| 			else | ||||
| #endif | ||||
| 			range = oldp; | ||||
| 			n = 1; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			if (icase && isupper(pc)) | ||||
| 				pc = tolower(pc); | ||||
| 			if (sc == pc) | ||||
| 				ok = 1; | ||||
| 			n = pc; | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 				/*...INDENT*/ | ||||
| 			} | ||||
| 			break; | ||||
| 		case '\\': | ||||
| 			if (!(pc = mbgetchar(p))) | ||||
| 				return 0; | ||||
| 			if (pc >= '0' && pc <= '9') | ||||
| 			{ | ||||
| 				n = pc - '0'; | ||||
| #if _DEBUG_MATCH | ||||
| 				error(-2, "backref#%d n=%d g=%d beg=%p end=%p len=%d", __LINE__, n, g, mp->current.beg[n], mp->current.end[n], mp->current.end[n] - mp->current.beg[n]); | ||||
| #endif | ||||
| 				if (n <= g && (oldp = mp->current.beg[n])) | ||||
| 				{ | ||||
| 					while (oldp < mp->current.end[n]) | ||||
| 						if (!*olds || *olds++ != *oldp++) | ||||
| 							return 0; | ||||
| 					s = olds; | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 			/*FALLTHROUGH*/ | ||||
| 		default: | ||||
| 			if (icase && isupper(pc)) | ||||
| 				pc = tolower(pc); | ||||
| 			if (pc != sc) | ||||
| 				return 0; | ||||
| 			break; | ||||
| 		} | ||||
| 	} while (sc); | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * match any pattern in a group | ||||
|  * | and & subgroups are parsed here | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| grpmatch(Match_t* mp, int g, char* s, register char* p, char* e, int flags) | ||||
| { | ||||
| 	register char*	a; | ||||
| 
 | ||||
| #if _DEBUG_MATCH | ||||
| 	error_info.indent++; | ||||
| 	error(-1, "grpmatch g=%d s=%-.*s p=%s flags=%o", g, e - s, s, p, flags); | ||||
| #endif | ||||
| 	do | ||||
| 	{ | ||||
| 		for (a = p; onematch(mp, g, s, a, e, NiL, flags); a++) | ||||
| 			if (*(a = mp->next_p) != '&') | ||||
| 				return 1; | ||||
| 	} while (p = gobble(mp, p, '|', &g, 1)); | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| #if _DEBUG_MATCH | ||||
| #undef	return | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * subgroup match | ||||
|  * 0 returned if no match | ||||
|  * otherwise number of subgroups matched returned | ||||
|  * match group begin offsets are even elements of sub | ||||
|  * match group end offsets are odd elements of sub | ||||
|  * the matched string is from s+sub[0] up to but not | ||||
|  * including s+sub[1] | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| strgrpmatch(const char* b, const char* p, ssize_t* sub, int n, int flags) | ||||
| { | ||||
| 	register int	i; | ||||
| 	register char*	s; | ||||
| 	char*		e; | ||||
| 	Match_t		match; | ||||
| 
 | ||||
| 	s = (char*)b; | ||||
| 	match.last_s = e = s + strlen(s); | ||||
| 	for (;;) | ||||
| 	{ | ||||
| 		match.best.next_s = 0; | ||||
| 		match.current.groups = 0; | ||||
| 		if ((i = grpmatch(&match, 0, s, (char*)p, e, flags)) || match.best.next_s) | ||||
| 		{ | ||||
| 			if (!i) | ||||
| 				match.current = match.best; | ||||
| 			match.current.groups++; | ||||
| 			match.current.end[0] = match.current.next_s; | ||||
| #if _DEBUG_MATCH | ||||
| 			error(-1, "match i=%d s=\"%s\" p=\"%s\" flags=%o groups=%d next=\"%s\"", i, s, p, flags, match.current.groups, match.current.next_s); | ||||
| #endif | ||||
| 			break; | ||||
| 		} | ||||
| 		if ((flags & STR_LEFT) || s >= e) | ||||
| 			return 0; | ||||
| 		s++; | ||||
| 	} | ||||
| 	if ((flags & STR_RIGHT) && match.current.next_s != e) | ||||
| 		return 0; | ||||
| 	if (!sub) | ||||
| 		return 1; | ||||
| 	match.current.beg[0] = s; | ||||
| 	s = (char*)b; | ||||
| 	if (n > match.current.groups) | ||||
| 		n = match.current.groups; | ||||
| 	for (i = 0; i < n; i++) | ||||
| 	{ | ||||
| 		sub[i * 2] = match.current.end[i] ? match.current.beg[i] - s : 0; | ||||
| 		sub[i * 2 + 1] = match.current.end[i] ? match.current.end[i] - s : 0; | ||||
| 	} | ||||
| 	return n; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * compare the string s with the shell pattern p | ||||
|  * returns 1 for match 0 otherwise | ||||
|  */ | ||||
| 
 | ||||
| int | ||||
| strmatch(const char* s, const char* p) | ||||
| { | ||||
| 	return strgrpmatch(s, p, NiL, 0, STR_MAXIMAL|STR_LEFT|STR_RIGHT); | ||||
| } | ||||
|  | @ -1,89 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| symlink3d(const char* path, const char* target) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register char*	tp; | ||||
| 	register int	r; | ||||
| 	char*		t; | ||||
| 	int		oerrno; | ||||
| 	char		buf[PATH_MAX + 1]; | ||||
| #if FS | ||||
| 	char		tmp[PATH_MAX + 1]; | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_symlink, 0, path, target)) | ||||
| 		return(state.ret); | ||||
| #endif | ||||
| 	if (!state.safe) sp = (char*)path; | ||||
| 	else if (!(sp = pathreal(path, P_PATHONLY|P_SAFE, NiL))) return(-1); | ||||
| 	else sp = strncpy(buf, sp, PATH_MAX); | ||||
| #if FS | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(tp = pathreal(target, P_PATHONLY|P_NOOPAQUE, NiL))) | ||||
| 		return(-1); | ||||
| 	oerrno = errno; | ||||
| 	if ((r = SYMLINK(sp, tp)) && errno == ENOENT && (t = strrchr(tp, '/'))) | ||||
| 	{ | ||||
| 		*t = 0; | ||||
| 		r = fs3d_mkdir(tp, S_IRWXU|S_IRWXG|S_IRWXO); | ||||
| 		*t = '/'; | ||||
| 		if (!r) | ||||
| 		{ | ||||
| 			errno = oerrno; | ||||
| 			r = SYMLINK(sp, tp); | ||||
| 		} | ||||
| 	} | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 		{ | ||||
| 			if (tp != tmp) | ||||
| 			{ | ||||
| 				if (!(tp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_ABSOLUTE, NiL))) | ||||
| 					return(r); | ||||
| 				tp = strncpy(tmp, tp, PATH_MAX); | ||||
| 			} | ||||
| 			fscall(mp, MSG_symlink, 0, sp, tp); | ||||
| 		} | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_symlink)) | ||||
| 			{ | ||||
| 				if (tp != tmp) | ||||
| 				{ | ||||
| 					if (!(tp = pathreal(target, P_PATHONLY|P_NOOPAQUE|P_ABSOLUTE, NiL))) | ||||
| 						return(r); | ||||
| 					tp = strncpy(tmp, tp, PATH_MAX); | ||||
| 				} | ||||
| 				fscall(mp, MSG_symlink, 0, sp, tp); | ||||
| 			} | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,88 +0,0 @@ | |||
| # | ||||
| # 3d system call intercept | ||||
| # | ||||
| # name # class # return type # arg prototype[s] # att # [bsd] # op ... | ||||
| # | ||||
| # NOTE: tab is the field separator, space is the subfield separator | ||||
| # | ||||
| #	if	test 1 = "$REPLICATE" -o 1 = "$SYSCALL3D" | ||||
| #	fi | ||||
| # | ||||
| _exit		exit	void		int				1 | ||||
| access		nop	int		const char*, int		33 | ||||
| acl		control	int		const char*, int, int, aclent_t*	185		sys/acl.h | ||||
| #brk		break	int		void*				17	0 | ||||
| chdir		nop	int		const char*			12 | ||||
| chmod		chmod	int		const char*, mode_t		15 | ||||
| chown		chown	int		const char*, uid_t, gid_t	16 | ||||
| close		close	int		int				6 | ||||
| closedir	nop	int		DIR* | ||||
| creat		open	int		const char*, mode_t		8 | ||||
| dup		dup	int		int				41 | ||||
| dup2		dup	int		int, int			90 | ||||
| execve		exec	int		const char*, char* const*, char* const*	59	59 | ||||
| facl		control	int		int, int, int, aclent_t*	200		sys/acl.h | ||||
| fchdir		nop	int		int				147 | ||||
| fchmod		chmod	int		int, mode_t			124 | ||||
| fchown		chown	int		int, uid_t, gid_t		123 | ||||
| fcntl		dup	int		int, int, ...			92 | ||||
| fork		fork	pid_t		void				2 | ||||
| fpathconf	pathconf	long		int, int			187	114 | ||||
| fstat		stat	int		int, struct stat*		62			version	sys/stat.h | ||||
| fstatfs		statfs	int		int, struct statfs*, int, int	158	38		variant	int, struct statfs*	sys/statfs.h | ||||
| fstatvfs	statfs	int		int, struct statvfs*		201	104 | ||||
| fsync		sync	int		int				95 | ||||
| ftruncate	truncate	int		int, off_t			130 | ||||
| getdents	getdents	ssize_t		int, void*, size_t		174 | ||||
| kill		kill	int		pid_t, int			37 | ||||
| link		link	int		const char*, const char*	9 | ||||
| lseek		seek	off_t		int, off_t, int			19 | ||||
| lstat		stat	int		const char*, struct stat*	48	88		alternate	stat								version	sys/stat.h | ||||
| mkdir		mkdir	int		const char*, mode_t		136	80 | ||||
| mknod		mknod	int		const char*, mode_t, dev_t	14	version	sys/stat.h | ||||
| mount		mount	int		const char*, char*, int, void*, void*, void*	167	21 | ||||
| open		open	int		const char*, int, ...		5 | ||||
| opendir		nop	DIR*		const char* | ||||
| pathconf	pathconf	long		const char*, int		186	113 | ||||
| pipe		pipe	bool		int*				42 | ||||
| read		read	ssize_t		int, void*, size_t		3 | ||||
| readdir		nop	struct dirent*	DIR* | ||||
| readlink	link	ssize_t		const char*, char*, size_t	58	90 | ||||
| rename		rename	int		const char*, const char*	128	134 | ||||
| rewinddir	nop	void		DIR* | ||||
| rmdir		rmdir	int		const char*			137	79 | ||||
| #sbrk		break	void*		ssize_t				0	69 | ||||
| seekdir		nop	void		DIR*, long	coupled	rewinddir telldir | ||||
| stat		stat	int		const char*, struct stat*	38	18		version	sys/stat.h | ||||
| statfs		statfs	int		const char*, struct statfs*, int, int	157	35	variant	const char*, struct statfs*	sys/statfs.h | ||||
| statvfs		statfs	int		const char*, struct statvfs*	202	103 | ||||
| symlink		link	int		const char*, const char*	57	89 | ||||
| telldir		nop	long		DIR* | ||||
| truncate	truncate	int		const char*, off_t		129	0 | ||||
| unlink		remove	int		const char*			10 | ||||
| utime		utime	int		const char*, const struct utimbuf*	30 | ||||
| utimensat	utime	int		int, const char*, const struct timespec*, int	236	0 | ||||
| utimes		utime	int		const char*, const struct timeval*	138	0 | ||||
| utimets		utime	int		const char*, const struct timespec*	235	0 | ||||
| vfork		fork	pid_t		void				66 | ||||
| write		write	ssize_t		int, const void*, size_t	4 | ||||
| # | ||||
| # now, these guys put padding in struct stat in preparation for 64 bit | ||||
| # dev_t,ino_t,off_t, and then ignored it, but even worse, the padding | ||||
| # was kept in struct stat64 | ||||
| # | ||||
| fstat64		stat		int	int, struct stat64*		255			version	sys/stat.h | ||||
| ftruncate64	truncate	int	int, off64_t			255 | ||||
| lseek64		seek		off64_t	int, off64_t, int		255 | ||||
| lstat64		stat		int	const char*, struct stat64*	255			version	sys/stat.h | ||||
| open64		open		int	const char*, int, ...		255 | ||||
| stat64		stat		int	const char*, struct stat64*	255			version	sys/stat.h | ||||
| truncate64	truncate	int	const char*, off64_t		255 | ||||
| # | ||||
| # dir got into the act too | ||||
| # | ||||
| getdents64	getdents	ssize_t		int, void*, size_t	255 | ||||
| readdir64	nop		struct dirent64*	DIR* | ||||
| rewinddir64	nop		void		DIR* | ||||
| seekdir64	nop		void		DIR*, off64_t	coupled	rewinddir64 telldir64 | ||||
| telldir64	nop		off64_t		DIR* | ||||
|  | @ -1,716 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * 3d system call trace | ||||
|  */ | ||||
| 
 | ||||
| #define SYSTRACE3D	1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if SYSTRACE3D | ||||
| 
 | ||||
| #define SYSCALL		syscall3d | ||||
| 
 | ||||
| #include "dir_3d.h" | ||||
| 
 | ||||
| #ifndef D_FILENO | ||||
| #define D_FILENO(d)	(1) | ||||
| #endif | ||||
| #ifndef D_TYPE | ||||
| #define D_TYPE(d)	(0) | ||||
| #endif | ||||
| 
 | ||||
| #define C_EXIT		(MSG_MASK(MSG_exit)) | ||||
| #define C_IO		(MSG_MASK(MSG_read)|MSG_MASK(MSG_write)) | ||||
| #define C_ZERO		(MSG_MASK(MSG_pipe)) | ||||
| 
 | ||||
| typedef union | ||||
| { | ||||
| 	void*		pointer; | ||||
| 	int		number; | ||||
| 	char*		string; | ||||
| 	char**		vector; | ||||
| } ARG; | ||||
| 
 | ||||
| static void*	dll; | ||||
| 
 | ||||
| #if _lib_strerror | ||||
| 
 | ||||
| #undef	strerror	/* otherwise it's _ast_strerror */ | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| extern int	sys_nerr; | ||||
| extern char*	sys_errlist[]; | ||||
| 
 | ||||
| char* | ||||
| strerror(int err) | ||||
| { | ||||
| 	static char	msg[28]; | ||||
| 
 | ||||
| 	if (err > 0 && err <= sys_nerr) | ||||
| 		return sys_errlist[err]; | ||||
| 	sfsprintf(msg, sizeof(msg), "Error %d", err); | ||||
| 	return msg; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #define MAXBUF	128 | ||||
| #define MAXLIN	79 | ||||
| #define MAXOUT	2048 | ||||
| 
 | ||||
| static void | ||||
| buffer(char** buf, char* end, register char* s, int n) | ||||
| { | ||||
| 	register char*	b; | ||||
| 	register char*	be; | ||||
| 	register char*	se; | ||||
| 	register int	c; | ||||
| 
 | ||||
| 	if (n < 0) | ||||
| 		bprintf(buf, end, " %p", s); | ||||
| 	else | ||||
| 	{ | ||||
| 		b = *buf; | ||||
| 		be = end; | ||||
| 		if (be - b > MAXBUF) | ||||
| 			be = b + MAXBUF; | ||||
| 		be -= 5; | ||||
| 		be = be; | ||||
| 		se = s + n; | ||||
| 		if (b < be - 1) | ||||
| 		{ | ||||
| 			*b++ = ' '; | ||||
| 			*b++ = '"'; | ||||
| 			while (b < be && s < se) | ||||
| 			{ | ||||
| 				if ((c = *((unsigned char*)s++)) < 040) | ||||
| 				{ | ||||
| 					*b++ = '\\'; | ||||
| 					switch (c) | ||||
| 					{ | ||||
| 					case '\007': | ||||
| 						c = 'a'; | ||||
| 						break; | ||||
| 					case '\b': | ||||
| 						c = 'b'; | ||||
| 						break; | ||||
| 					case '\f': | ||||
| 						c = 'f'; | ||||
| 						break; | ||||
| 					case '\n': | ||||
| 						c = 'n'; | ||||
| 						break; | ||||
| 					case '\r': | ||||
| 						c = 'r'; | ||||
| 						break; | ||||
| 					case '\t': | ||||
| 						c = 't'; | ||||
| 						break; | ||||
| 					case '\013': | ||||
| 						c = 'v'; | ||||
| 						break; | ||||
| 					case '\033': | ||||
| 						c = 'E'; | ||||
| 						break; | ||||
| 					default: | ||||
| 						if (b < be - 3) | ||||
| 						{ | ||||
| 							if (n = s < se && c >= '0' && c <= '9') | ||||
| 								*b++ = '0'; | ||||
| 							if (n || ((c >> 3) & 07)) | ||||
| 								*b++ = '0' + ((c >> 3) & 07); | ||||
| 							*b++ = '0' + (c & 07); | ||||
| 						} | ||||
| 						continue; | ||||
| 					} | ||||
| 					if (b < be) | ||||
| 						*b++ = c; | ||||
| 				} | ||||
| 				else if (c < 0177) | ||||
| 					*b++ = c; | ||||
| 				else if (c == 0177) | ||||
| 				{ | ||||
| 					*b++ = '^'; | ||||
| 					if (b >= be) | ||||
| 						break; | ||||
| 					*b++ = '?'; | ||||
| 				} | ||||
| 				else if (b < be - 4) | ||||
| 				{ | ||||
| 					*b++ = '\\'; | ||||
| 					*b++ = '0' + ((c >> 6) & 03); | ||||
| 					*b++ = '0' + ((c >> 3) & 07); | ||||
| 					*b++ = '0' + (c & 07); | ||||
| 				} | ||||
| 			} | ||||
| 			if ((b >= be || s < se) && (be - *buf) >= 4) | ||||
| 			{ | ||||
| 				b -= 4; | ||||
| 				*b++ = '"'; | ||||
| 				*b++ = '.'; | ||||
| 				*b++ = '.'; | ||||
| 				*b++ = '.'; | ||||
| 			} | ||||
| 			else if (b < be) | ||||
| 				*b++ = '"'; | ||||
| 		} | ||||
| 		*buf = b; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| #if __gnu_linux__ | ||||
| #undef	_no_exit_exit | ||||
| #endif | ||||
| 
 | ||||
| #if _lib_syscall && _sys_syscall | ||||
| 
 | ||||
| #include <sys/syscall.h> | ||||
| 
 | ||||
| #ifdef SYS_exit | ||||
| 
 | ||||
| static void | ||||
| sys_exit(int code) | ||||
| { | ||||
| 	syscall(SYS_exit, code); | ||||
| } | ||||
| 
 | ||||
| #define SYS_EXIT	sys_exit | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| /*
 | ||||
|  * initialize the 3d syscall table | ||||
|  */ | ||||
| 
 | ||||
| void | ||||
| callinit(void) | ||||
| { | ||||
| 	register Systrace_t*	cp; | ||||
| 
 | ||||
| #if defined(__sgi) && defined(_ABIO32) | ||||
| 	sys_trace[0].name = "_exit"; | ||||
| #endif | ||||
| #if sun && !_sun && _lib_on_exit | ||||
| 	sys_trace[0].name = "__exit"; | ||||
| #endif | ||||
| 	if (dll = dllnext(RTLD_LAZY)) | ||||
| 	{ | ||||
| 		for (cp = sys_trace; cp < &sys_trace[elementsof(sys_trace)]; cp++) | ||||
| 			if (!(cp->func = (Sysfunc_t)dlsym(dll, cp->name)) && (*cp->name != '_' || !(cp->func = (Sysfunc_t)dlsym(dll, cp->name + 1)) || !*cp->name++)) | ||||
| 				cp->func = (Sysfunc_t)nosys; | ||||
| #if !defined(SYS_EXIT) && _no_exit_exit | ||||
| 		state.libexit = (Exitfunc_t)dlsym(dll, "exit"); | ||||
| #endif | ||||
| 	} | ||||
| #ifdef SYS_EXIT | ||||
| 	sys_trace[0].func = (Sysfunc_t)sys_exit; | ||||
| #endif | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  * dump the 3d syscall table | ||||
|  */ | ||||
| 
 | ||||
| void | ||||
| calldump(char** b, char* e) | ||||
| { | ||||
| 	register Systrace_t*	cp; | ||||
| 	register int		m; | ||||
| 
 | ||||
| 	bprintf(b, e, "\nsystem calls total=%d nosys=%p exit=%p\n\n", elementsof(sys_trace), nosys, | ||||
| #if _no_exit_exit | ||||
| 		state.libexit | ||||
| #else | ||||
| 		(Sysfunc_t)0 | ||||
| #endif | ||||
| 		); | ||||
| 	for (cp = sys_trace; cp < &sys_trace[elementsof(sys_trace)]; cp++) | ||||
| 	{ | ||||
| 		bprintf(b, e, "  %03d%s %03d %12s", cp - sys_trace, (cp - sys_trace) == cp->index ? " " : "*", cp->call, cp->name); | ||||
| 		for (m = state.trap.size - 1; m >= 0; m--) | ||||
| 			if (MSG_MASK(cp->call) & state.trap.intercept[m].mask) | ||||
| 				bprintf(b, e, " %p[%d]", state.trap.intercept[m].call, m); | ||||
| 		bprintf(b, e, " %p\n", cp->func); | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| #if _no_exit_exit | ||||
| static int | ||||
| oksys(void) | ||||
| { | ||||
| 	return 0; | ||||
| } | ||||
| 
 | ||||
| void | ||||
| exit(int code) | ||||
| { | ||||
| 	if (state.libexit) | ||||
| 		sys_trace[SYS3D_exit].func = (Sysfunc_t)oksys; | ||||
| 	_exit(code); | ||||
| 	if (state.libexit) | ||||
| 	{ | ||||
| 		(*state.libexit)(code); | ||||
| 		state.libexit = 0; | ||||
| 	} | ||||
| } | ||||
| #endif | ||||
| 
 | ||||
| Sysfunc_t | ||||
| sysfunc(int call) | ||||
| { | ||||
| 	initialize(); | ||||
| 	return sys_trace[call].func; | ||||
| } | ||||
| 
 | ||||
| #if !_var_syscall | ||||
| long | ||||
| syscall3d(int call, void* a1, void* a2, void* a3, void* a4, void* a5, void* a6) | ||||
| { | ||||
| #if 0 /* to convince proto */
 | ||||
| } | ||||
| #endif | ||||
| #else | ||||
| long | ||||
| syscall3d(int call, ...) | ||||
| { | ||||
| #endif | ||||
| 	register int		n; | ||||
| 	register long		r; | ||||
| 	register Systrace_t*	cp; | ||||
| 	register ARG*		ap; | ||||
| 	register int		ac; | ||||
| 	int			a; | ||||
| 	int			m; | ||||
| 	int			on; | ||||
| 	char*			b; | ||||
| 	char*			e; | ||||
| 	char*			t; | ||||
| 	char**			p; | ||||
| 	int*			ip; | ||||
| 	ARG			arg[7]; | ||||
| 	char			buf[MAXOUT]; | ||||
| 	Sysfunc_t		func; | ||||
| #if _var_syscall | ||||
| 	va_list			vp; | ||||
| #endif | ||||
| 
 | ||||
| 	initialize(); | ||||
| #if _var_syscall | ||||
| 	va_start(vp, call); | ||||
| #endif | ||||
| 	cp = sys_trace + call; | ||||
| #if _var_syscall | ||||
| 	n = cp->args; | ||||
| 	for (r = 1; r <= elementsof(arg); r++) | ||||
| 		arg[r].pointer = (r <= n) ? va_arg(vp, void*) : (void*)0; | ||||
| 	va_end(vp); | ||||
| #else | ||||
| 	switch (cp->args) | ||||
| 	{ | ||||
| 	case 6: arg[6].pointer = a6; | ||||
| 	case 5: arg[5].pointer = a5; | ||||
| 	case 4: arg[4].pointer = a4; | ||||
| 	case 3: arg[3].pointer = a3; | ||||
| 	case 2: arg[2].pointer = a2; | ||||
| 	case 1: arg[1].pointer = a1; | ||||
| 	} | ||||
| #endif | ||||
| 	if (state.kernel || state.trace.pid <= 1 || (on = fsfd(&state.fs[FS_option])) <= 0 || !(state.test & 0100) && !(MSG_MASK(cp->call) & (state.trace.call & ~MSG_MASK(error_info.trace ? 0 : MSG_nop)))) | ||||
| 		on = 0; | ||||
| 	else | ||||
| 	{ | ||||
| 		state.kernel++; | ||||
| 		if (!state.trace.count) | ||||
| 		{ | ||||
| 			e = (b = buf) + elementsof(buf) - 1; | ||||
| 			if (state.trace.pid > 2) | ||||
| 				bprintf(&b, e, "[%d] ", state.trace.pid); | ||||
| 			bprintf(&b, e, "%s (", cp->name); | ||||
| 			a = A_INPUT; | ||||
| 			if (call == SYS3D_write) | ||||
| 			{ | ||||
| 				if ((m = arg[1].number) == on) | ||||
| 					a = 0; | ||||
| 				else if (m == 1 || m == 2) | ||||
| 				{ | ||||
| 					struct stat	st; | ||||
| 
 | ||||
| 					n = errno; | ||||
| 					if (!fstat(m, &st) && st.st_ino == state.fs[FS_option].st.st_ino && st.st_dev == state.fs[FS_option].st.st_dev) | ||||
| 						a = 0; | ||||
| 					errno = n; | ||||
| 				} | ||||
| 			} | ||||
| 			if ((state.test & 020) && call == SYS3D_close) bprintf(&b, e, "%s%s%s", state.file[arg[1].number].reserved ? " [RESERVED]" : "", arg[1].number == TABLE_FD ? " [TABLE]" : "", arg[1].number == state.table.fd ? " [table]" : ""); | ||||
| 			for (ac = 1; ac <= cp->args && (n = cp->type[ac]) >= a; ac++) | ||||
| 			{ | ||||
| 				ap = &arg[ac]; | ||||
| 				switch (n) | ||||
| 				{ | ||||
| 				case A_INPUT: | ||||
| 					if (a) | ||||
| 					{ | ||||
| 						buffer(&b, e, ap->string, arg[ac + 1].number); | ||||
| 						break; | ||||
| 					} | ||||
| 					/*FALLTHROUGH*/ | ||||
| 				case A_OUTPUT: | ||||
| 				case A_POINTER: | ||||
| 					bprintf(&b, e, " %p", ap->number); | ||||
| 					break; | ||||
| 				case A_MODE: | ||||
| 					bprintf(&b, e, " 0%o", ap->number); | ||||
| 					break; | ||||
| 				case A_STRING: | ||||
| 					if (t = ap->string) | ||||
| 						buffer(&b, e, t, strlen(t)); | ||||
| 					else | ||||
| 						bprintf(&b, e, " (null)"); | ||||
| 					break; | ||||
| 				case A_VECTOR: | ||||
| 					bprintf(&b, e, " ["); | ||||
| 					for (p = ap->vector; *p && p < ap->vector + 8; p++) | ||||
| 						buffer(&b, e, *p, strlen(*p)); | ||||
| 					if (*p) | ||||
| 						bprintf(&b, e, "..."); | ||||
| 					bprintf(&b, e, " ]"); | ||||
| 					break; | ||||
| 				default: | ||||
| 					bprintf(&b, e, " %d", ap->number); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| 			if (!a) | ||||
| 				*b++ = '\n'; | ||||
| 			else if (MSG_MASK(cp->call) & C_EXIT) | ||||
| 			{ | ||||
| 				bprintf(&b, e, " ) = ?\n"); | ||||
| 				state.kernel++; | ||||
| 			} | ||||
| 			n = errno; | ||||
| 			write(on, buf, b - buf); | ||||
| 			errno = n; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			if (MSG_MASK(cp->call) & C_EXIT) | ||||
| 			{ | ||||
| 				e = (b = buf) + elementsof(buf) - 1; | ||||
| 				*b++ = '\n'; | ||||
| 				if (state.trace.pid > 2) | ||||
| 					bprintf(&b, e, "         [%d] %s\n", state.trace.pid, state.cmd); | ||||
| 				for (n  = 0; n < elementsof(sys_trace); n++) | ||||
| 					if (sys_trace[n].count) | ||||
| 					{ | ||||
| 						if (MSG_MASK(sys_trace[n].call) & C_IO) | ||||
| 						{ | ||||
| 							bprintf(&b, e, "   %5d %-10s", sys_trace[n].count, sys_trace[n].name); | ||||
| 							if (sys_trace[n].megs) | ||||
| 								bprintf(&b, e, "%5lu.%dm", sys_trace[n].megs, (sys_trace[n].units * 10) >> 20); | ||||
| 							else | ||||
| 								bprintf(&b, e, "%5lu.%dk", sys_trace[n].units >> 10, ((sys_trace[n].units & ((1<<10)-1)) * 10) >> 10); | ||||
| 						} | ||||
| 						else | ||||
| 							bprintf(&b, e, "   %5d %s", sys_trace[n].count, sys_trace[n].name); | ||||
| 						if (b < e) | ||||
| 							*b++ = '\n'; | ||||
| 					} | ||||
| 				*b++ = '\n'; | ||||
| 				n = errno; | ||||
| 				write(on, buf, b - buf); | ||||
| 				errno = n; | ||||
| 				state.kernel++; | ||||
| 			} | ||||
| 			cp->count++; | ||||
| 		} | ||||
| 	} | ||||
| 	for (m = state.trap.size - 1; m >= 0; m--) | ||||
| 		if (MSG_MASK(cp->call) & state.trap.intercept[m].mask) | ||||
| 			break; | ||||
| 	if (m >= 0) | ||||
| 	{ | ||||
| 		n = state.trap.size; | ||||
| 		state.trap.size = m; | ||||
| 		r = (*state.trap.intercept[m].call)(&state.trap.intercept[m], cp->call, call, arg[1].pointer, arg[2].pointer, arg[3].pointer, arg[4].pointer, arg[5].pointer, arg[6].pointer); | ||||
| 		state.trap.size = n; | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| #if _dynamic_syscall || _static_syscall | ||||
| #if _dynamic_syscall | ||||
| 		if (dll && cp->func) | ||||
| #else | ||||
| 		if (dll && cp->func && cp->index < 0) | ||||
| #endif | ||||
| 		{ | ||||
| 			switch (cp->active++) | ||||
| 			{ | ||||
| 			case 0: | ||||
| 				func = cp->func; | ||||
| 				break; | ||||
| 			case 1: | ||||
| 				if (!(func = cp->last)) | ||||
| 				{ | ||||
| 					if (!(cp->last = (Sysfunc_t)dlsym(dll, cp->name)) && (*cp->name != '_' || !(cp->last = (Sysfunc_t)dlsym(dll, cp->name + 1)) || !*cp->name++)) | ||||
| 						cp->last = (Sysfunc_t)nosys; | ||||
| 					func = cp->last; | ||||
| 					if (func == cp->func) | ||||
| 					{ | ||||
| 						/*
 | ||||
| 						 * longjmp gets you here | ||||
| 						 */ | ||||
| 
 | ||||
| 						cp->active = 3; | ||||
| 					} | ||||
| 					else if (cp->func != (Sysfunc_t)nosys && func == (Sysfunc_t)nosys) | ||||
| 					{ | ||||
| 						cp->active = 10; | ||||
| 						e = (b = buf) + elementsof(buf) - 1; | ||||
| 						bprintf(&b, e, "3d: %s: system call loop -- cannot determine the real system call\n", cp->name); | ||||
| 						write(2, buf, b - buf); | ||||
| 					} | ||||
| 				} | ||||
| 				break; | ||||
| 			case 2: | ||||
| 			case 3: | ||||
| 				cp->active = 3; | ||||
| 				func = cp->func; | ||||
| 				break; | ||||
| 			default: | ||||
| 				cp->active = 10; | ||||
| 				func = (Sysfunc_t)nosys; | ||||
| 				break; | ||||
| 			} | ||||
| 			r = (*func)(arg[1].pointer, arg[2].pointer, arg[3].pointer, arg[4].pointer, arg[5].pointer, arg[6].pointer); | ||||
| 			cp->active--; | ||||
| 		} | ||||
| 		else | ||||
| #endif | ||||
| #if _lib_syscall | ||||
| 		if (cp->index >= 0) | ||||
| 			r = syscall(cp->index, arg[1].pointer, arg[2].pointer, arg[3].pointer, arg[4].pointer, arg[5].pointer, arg[6].pointer); | ||||
| 		else if (cp->nov >= 0) | ||||
| 			r = syscall(cp->nov, arg[2].pointer, arg[3].pointer, arg[4].pointer, arg[5].pointer, arg[6].pointer, 0); | ||||
| 		else | ||||
| #endif | ||||
| 		{ | ||||
| #ifndef ENOSYS | ||||
| #define ENOSYS	EINVAL | ||||
| #endif | ||||
| 			errno = ENOSYS; | ||||
| 			r = -1; | ||||
| 		} | ||||
| 	} | ||||
| #if !_mangle_syscall | ||||
| 	if (r > 0 && (MSG_MASK(cp->call) & C_ZERO)) | ||||
| 		r = 0; | ||||
| #endif | ||||
| 	if (on && state.kernel <= 1) | ||||
| 	{ | ||||
| 		if (!state.trace.count) | ||||
| 		{ | ||||
| 			if ((m = MAXLIN - (b - buf)) < 0) | ||||
| 				m = 0; | ||||
| 			b = buf; | ||||
| 			for (; ac <= cp->args; ac++) | ||||
| 			{ | ||||
| 				ap = &arg[ac]; | ||||
| 				switch (n = cp->type[ac]) | ||||
| 				{ | ||||
| 				case A_OUTPUT: | ||||
| 					switch (call) | ||||
| 					{ | ||||
| 					case SYS3D_fstat: | ||||
| #ifdef SYS3D_lstat | ||||
| 					case SYS3D_lstat: | ||||
| #endif | ||||
| 					case SYS3D_stat: | ||||
| 						if (!r) | ||||
| 						{ | ||||
| 							/*UNDENT...*/ | ||||
| #ifdef _3D_STAT_VER | ||||
| 	switch (arg[1].number) | ||||
| 	{ | ||||
| 	case _3D_STAT_VER: | ||||
| #endif | ||||
| 		{ | ||||
| 			struct stat*	sp = (struct stat*)ap->pointer; | ||||
| 			bprintf(&b, e, " [ dev=%d ino=%d view=%d mode=0%o nlink=%d uid=%d gid=%d size=%u atime=%u mtime=%u ctime=%u ]", sp->st_dev, sp->st_ino, iview(sp), sp->st_mode, sp->st_nlink, sp->st_uid, sp->st_gid, sp->st_size, sp->st_atime, sp->st_mtime, sp->st_ctime); | ||||
| 			continue; | ||||
| 		} | ||||
| #ifdef _3D_STAT_VER | ||||
| #ifdef _3D_STAT64_VER | ||||
| 	case _3D_STAT64_VER: | ||||
| 		{ | ||||
| 			struct stat64*	sp = (struct stat64*)ap->pointer; | ||||
| 			bprintf(&b, e, " [ dev=%d ino=%lld view=%d mode=0%o nlink=%d uid=%d gid=%d size=%llu atime=%u mtime=%u ctime=%u ]", sp->st_dev, sp->st_ino, iview(sp), sp->st_mode, sp->st_nlink, sp->st_uid, sp->st_gid, sp->st_size, sp->st_atime, sp->st_mtime, sp->st_ctime); | ||||
| 			continue; | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
| #endif | ||||
| 						} | ||||
| 						break; | ||||
| #ifdef SYS3D_getdents | ||||
| 					case SYS3D_getdents: | ||||
| 						if (r > 0) | ||||
| 						{ | ||||
| 							struct DIRdirent*	dp = (struct DIRdirent*)ap->pointer; | ||||
| 							struct DIRdirent*	de = (struct DIRdirent*)((char*)dp + r); | ||||
| 
 | ||||
| 							bprintf(&b, e, " ["); | ||||
| 							while (dp < de) | ||||
| 							{ | ||||
| #ifdef DIRdirent | ||||
| 								bprintf(&b, e, " %lu \"%s\"", D_FILENO(dp), dp->d_name); | ||||
| #else | ||||
| 								bprintf(&b, e, " %02d %lu \"%s\"", D_TYPE(dp), D_FILENO(dp), dp->d_name); | ||||
| #endif | ||||
| 								dp = (struct DIRdirent*)((char*)dp + dp->d_reclen); | ||||
| 							} | ||||
| 							bprintf(&b, e, " ]"); | ||||
| 							continue; | ||||
| 						} | ||||
| 						break; | ||||
| #endif | ||||
| 					case SYS3D_pipe: | ||||
| 						if (!r) | ||||
| 						{ | ||||
| 							ip = (int*)ap->pointer; | ||||
| 							bprintf(&b, e, " [ %d %d ]", ip[0], ip[1]); | ||||
| 							continue; | ||||
| 						} | ||||
| 						break; | ||||
| 					} | ||||
| 					/*FALLTHROUGH*/ | ||||
| 				case A_INPUT: | ||||
| 					if (n == A_OUTPUT && cp->type[n = 0] == A_SIZE || ac < (elementsof(cp->type) - 1) && cp->type[n = ac + 1] == A_SIZE) | ||||
| 					{ | ||||
| 						buffer(&b, e, ap->string, n ? arg[n].number : r); | ||||
| 						break; | ||||
| 					} | ||||
| 					goto pointer; | ||||
| 				case A_MODE: | ||||
| 					bprintf(&b, e, " 0%o", ap->number); | ||||
| 					break; | ||||
| 				case A_POINTER: | ||||
| 				pointer: | ||||
| 					bprintf(&b, e, " %p", ap->pointer); | ||||
| 					break; | ||||
| 				case A_STRING: | ||||
| 					if (r == -1) | ||||
| 						goto pointer; | ||||
| 					buffer(&b, e, ap->string, strlen(ap->string)); | ||||
| 					break; | ||||
| 				default: | ||||
| 					bprintf(&b, e, " %d", ap->number); | ||||
| 					break; | ||||
| 				} | ||||
| 			} | ||||
| #if DEBUG_dirent | ||||
| 			switch (call) | ||||
| 			{ | ||||
| #ifdef SYS3D_readdir | ||||
| #undef	DIRdirent | ||||
| 			case SYS3D_readdir: | ||||
| 				if (r && (state.test & 0100)) | ||||
| 				{ | ||||
| 					struct DIRdirent*	dp = (struct DIRdirent*)pointerof(r); | ||||
| 
 | ||||
| 					bprintf(&b, e, " ) = [ %02d %lu \"%s\" ]", D_TYPE(dp), D_FILENO(dp), dp->d_name); | ||||
| 					break; | ||||
| 				} | ||||
| 				goto number; | ||||
| #endif | ||||
| #ifdef SYS3D_readdir64 | ||||
| 			case SYS3D_readdir64: | ||||
| 				if (r && (state.test & 0100)) | ||||
| 				{ | ||||
| 					struct dirent64*	dp = (struct dirent64*)pointerof(r); | ||||
| 
 | ||||
| 					bprintf(&b, e, " ) = [ %02d %llu \"%s\" ]", D_TYPE(dp), D_FILENO(dp), dp->d_name); | ||||
| 					break; | ||||
| 				} | ||||
| 				goto number; | ||||
| #endif | ||||
| 			default: | ||||
| 			number: | ||||
| 				bprintf(&b, e, "%s) = %d", a ? " " : "\t", r); | ||||
| 				break; | ||||
| 			} | ||||
| #else | ||||
| 			bprintf(&b, e, "%s) = %d", a ? " " : "\t", r); | ||||
| #endif | ||||
| 			if (r == -1) | ||||
| 				bprintf(&b, e, " [%s]", strerror(errno)); | ||||
| 			n = errno; | ||||
| 			t = buf; | ||||
| 			while ((b - t) >= m) | ||||
| 			{ | ||||
| 				char*	w; | ||||
| 				char*	x; | ||||
| 				char*	z; | ||||
| 				int	c1; | ||||
| 				int	c2; | ||||
| 
 | ||||
| 				x = w = t + m; | ||||
| 				z = t + m / 2; | ||||
| 				while (x > z && *x != ' ') x--; | ||||
| 				if (x <= z) | ||||
| 					x = w; | ||||
| 				c1 = *x; | ||||
| 				*x++ = '\n'; | ||||
| 				c2 = *x; | ||||
| 				*x++ = '\t'; | ||||
| 				write(on, t, x - t); | ||||
| 				*--x = c2; | ||||
| 				if ((*--x = c1) == ' ') | ||||
| 					x++; | ||||
| 				t = x; | ||||
| 				m = MAXLIN - 8; | ||||
| 			} | ||||
| 			*b++ = '\n'; | ||||
| 			write(on, t, b - t); | ||||
| 			errno = n; | ||||
| 		} | ||||
| 		else if (r >= 0 && (MSG_MASK(cp->call) & C_IO) && (cp->units += r) >= (1<<20)) | ||||
| 		{ | ||||
| 			cp->megs += cp->units >> 20; | ||||
| 			cp->units &= ((1<<20)-1); | ||||
| 		} | ||||
| 		state.kernel--; | ||||
| 	} | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(syscall) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,47 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * any 3d library function `declaring' PULL_IN_3D will pull in all of 3d | ||||
|  * exit seems to be the best candidate | ||||
|  * | ||||
|  * guess where bsd4.4 puts the lseek prototype | ||||
|  */ | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide lseek | ||||
| #else | ||||
| #define lseek        ______lseek | ||||
| #endif | ||||
| 
 | ||||
| #include <sys/types.h> | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide lseek | ||||
| #else | ||||
| #undef  lseek | ||||
| #endif | ||||
| 
 | ||||
| #define SYSENT3D	1 | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
|  | @ -1,194 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * NOTE: obsolete touch() for 3d private use | ||||
|  *	 -last touch() handles subsecond times | ||||
|  *	 via tvtouch() | ||||
|  */ | ||||
| 
 | ||||
| /*
 | ||||
|  * Glenn Fowler | ||||
|  * AT&T Research | ||||
|  * | ||||
|  * touch file access and modify times of file | ||||
|  * if force>0 then file will be created if it doesn't exist | ||||
|  * if force<0 then times are taken verbatim | ||||
|  * times have one second granularity | ||||
|  * | ||||
|  *	(time_t)(-1)	retain old time | ||||
|  *	0		use current time | ||||
|  */ | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide utime | ||||
| #else | ||||
| #define utime		______utime | ||||
| #endif | ||||
| 
 | ||||
| #include <ast.h> | ||||
| #include <ls.h> | ||||
| #include <times.h> | ||||
| #include <error.h> | ||||
| 
 | ||||
| #if _hdr_utime && _lib_utime | ||||
| #include <utime.h> | ||||
| #endif | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide utime | ||||
| #else | ||||
| #undef	utime | ||||
| #endif | ||||
| 
 | ||||
| #if _lib_utime | ||||
| #if _hdr_utime | ||||
| extern int	utime(const char*, const struct utimbuf*); | ||||
| #else | ||||
| extern int	utime(const char*, const time_t*); | ||||
| #endif | ||||
| #endif | ||||
| 
 | ||||
| int | ||||
| touch(const char* file, time_t atime, time_t mtime, int force) | ||||
| { | ||||
| 	int		n; | ||||
| 	int		fd; | ||||
| 	int		oerrno = errno; | ||||
| 	int		mode; | ||||
| #if _lib_utime | ||||
| 	time_t		now; | ||||
| 	struct stat	st; | ||||
| #if _hdr_utime | ||||
| 	struct utimbuf	ut; | ||||
| #else | ||||
| 	time_t		ut[2]; | ||||
| #endif | ||||
| 
 | ||||
| 	if (force >= 0) | ||||
| 	{ | ||||
| 		if (atime == (time_t)(-1) || mtime == (time_t)(-1)) | ||||
| 		{ | ||||
| 			if (stat(file, &st)) st.st_atime = st.st_mtime = 0; | ||||
| 			if (atime == (time_t)(-1)) atime = st.st_atime; | ||||
| 			if (mtime == (time_t)(-1)) mtime = st.st_mtime; | ||||
| 		} | ||||
| 		if (!atime || !mtime) | ||||
| #if _hdr_utime && _lib_utime_now | ||||
| 		if (atime || mtime) | ||||
| #endif | ||||
| 		{ | ||||
| 			time(&now); | ||||
| 			if (!atime) atime = now; | ||||
| 			if (!mtime) mtime = now; | ||||
| 		} | ||||
| 	} | ||||
| #if _hdr_utime | ||||
| 	ut.actime = atime; | ||||
| 	ut.modtime = mtime; | ||||
| #if _lib_utime_now | ||||
| 	n = utime(file, (force < 0 || atime || mtime) ? &ut : (struct utimbuf*)0); | ||||
| #else | ||||
| 	n = utime(file, &ut); | ||||
| #endif | ||||
| #else | ||||
| 	ut[0] = atime; | ||||
| 	ut[1] = mtime; | ||||
| 	n = utime(file, ut); | ||||
| #endif | ||||
| 	if (n) | ||||
| #else | ||||
| 	if (mtime) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 * NOTE: the emulation allows atime to change | ||||
| 		 *	 for mtime only requests | ||||
| 		 */ | ||||
| 
 | ||||
| 		errno = EINVAL; | ||||
| 		return(-1); | ||||
| 	} | ||||
| #endif | ||||
| 	{ | ||||
| #if _lib_utime | ||||
| 		if (errno == ENOENT || errno == EPERM) | ||||
| #else | ||||
| 
 | ||||
| 		if (access(file, F_OK)) | ||||
| #endif | ||||
| 		{ | ||||
| 			if (!force) return(-1); | ||||
| 			umask(mode = umask(0)); | ||||
| 			mode = (~mode) & (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); | ||||
| 			if ((fd = open(file, O_WRONLY|O_CREAT|O_TRUNC|O_cloexec, mode)) < 0) return(-1); | ||||
| 			close(fd); | ||||
| 			errno = oerrno; | ||||
| #if _lib_utime | ||||
| #if _hdr_utime | ||||
| #if _lib_utime_now | ||||
| 			return((force < 0 || atime || mtime) ? utime(file, &ut) : 0); | ||||
| #else | ||||
| 			return(0); | ||||
| #endif | ||||
| #else | ||||
| 			return((atime != now || mtime != now) ? utime(file, ut) : 0); | ||||
| #endif | ||||
| #else | ||||
| 			return(0); | ||||
| #endif | ||||
| 		} | ||||
| #if !_hdr_utime || !_lib_utime | ||||
| #if _lib_utime | ||||
| 		if (atime == now && mtime == now && (fd = open(file, O_RDWR|O_cloexec)) >= 0) | ||||
| #else | ||||
| 		if ((fd = open(file, O_RDWR|O_cloexec)) >= 0) | ||||
| #endif | ||||
| 		{ | ||||
| 			char	c; | ||||
| 
 | ||||
| 			if (read(fd, &c, 1) == 1) | ||||
| 			{ | ||||
| 				if (lseek(fd, 0L, 0) == 0L && write(fd, &c, 1) == 1) | ||||
| 				{ | ||||
| 					errno = oerrno; | ||||
| 					n = 0; | ||||
| 				} | ||||
| 				close(fd); | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				close(fd); | ||||
| 				umask(mode = umask(0)); | ||||
| 				mode = (~mode) & (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH); | ||||
| 				if ((fd = open(file, O_WRONLY|O_CREAT|O_TRUNC|O_cloexec, mode)) >= 0) | ||||
| 				{ | ||||
| 					close(fd); | ||||
| 					errno = oerrno; | ||||
| 					n = 0; | ||||
| 				} | ||||
| 			} | ||||
| 		} | ||||
| #endif | ||||
| 	} | ||||
| 	return(n); | ||||
| } | ||||
|  | @ -1,113 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #ifdef truncate3d | ||||
| 
 | ||||
| #if !_nosys_truncate64 && _typ_off64_t | ||||
| 
 | ||||
| #undef	off_t | ||||
| #undef	ftruncate | ||||
| 
 | ||||
| typedef int (*Real_f)(const char*, off64_t); | ||||
| 
 | ||||
| int | ||||
| truncate643d(const char* path, off64_t size) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	int		n; | ||||
| 	int		m; | ||||
| 	static Real_f	realf; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_truncate, 0, path, size)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_TOP, NiL))) | ||||
| 		return -1; | ||||
| 	if (!realf) | ||||
| 		realf = (Real_f)sysfunc(SYS3D_truncate64); | ||||
| 	for (m = state.trap.size - 1; m >= 0; m--) | ||||
| 		if (MSG_MASK(MSG_truncate) & state.trap.intercept[m].mask) | ||||
| 			break; | ||||
| 	if (m >= 0) | ||||
| 	{ | ||||
| 		n = state.trap.size; | ||||
| 		state.trap.size = m; | ||||
| 		r = (*state.trap.intercept[m].call)(&state.trap.intercept[m], MSG_truncate, SYS3D_truncate64, (void*)sp, (void*)&size, NiL, NiL, NiL, NiL); | ||||
| 		state.trap.size = n; | ||||
| 	} | ||||
| 	else | ||||
| 		r = (*realf)(sp, size); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_truncate, 0, path, size); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_truncate)) | ||||
| 				fscall(NiL, MSG_truncate, 0, path, size); | ||||
| 	} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
| 
 | ||||
| int | ||||
| truncate3d(const char* path, off_t size) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_truncate, 0, path, size)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_TOP, NiL))) | ||||
| 		return -1; | ||||
| 	r = TRUNCATE(sp, size); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(NiL, MSG_truncate, 0, path, size); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_truncate)) | ||||
| 				fscall(NiL, MSG_truncate, 0, path, size); | ||||
| 	} | ||||
| #endif | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(truncate) | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,77 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| int | ||||
| unlink3d(register const char* path) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| 
 | ||||
| 	if (!fscall(NiL, MSG_remove, 0, path)) | ||||
| 		return state.ret; | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_PATHONLY|P_SAFE, NiL))) | ||||
| 		return -1; | ||||
| 	if (state.path.level) | ||||
| 		return 0; | ||||
| 	if (!(r = LSTAT(sp, &state.path.st))) | ||||
| 	{ | ||||
| 		if (S_ISLNK(state.path.st.st_mode) && !checklink(sp, &state.path.st, P_PATHONLY|P_LSTAT) && state.path.linksize > 0) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * remove instance if not default | ||||
| 			 */ | ||||
| 
 | ||||
| 			r = strlen(sp) - (sizeof(state.vdefault) - 1); | ||||
| 			if (r > 3 && streq(sp + r, state.vdefault)) | ||||
| 				return 0; | ||||
| 		} | ||||
| 		r = UNLINK(sp); | ||||
| 	} | ||||
| 	if (!r) | ||||
| 	{ | ||||
| #if FS | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_remove, 0, path); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_remove)) | ||||
| 				fscall(mp, MSG_remove, 0, path); | ||||
| #endif | ||||
| 	} | ||||
| 	else if (errno == ENOENT && pathreal(path, 0, NiL)) | ||||
| 		r = 0; | ||||
| 	return r; | ||||
| } | ||||
| 
 | ||||
| #undef	remove | ||||
| 
 | ||||
| int | ||||
| remove(const char* path) | ||||
| { | ||||
| 	return unlink(path); | ||||
| } | ||||
|  | @ -1,93 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:hide utime | ||||
| #else | ||||
| #define utime        ______utime | ||||
| #endif | ||||
| #define _def_syscall_3d	1 | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if _hdr_utime | ||||
| #include <utime.h> | ||||
| #else | ||||
| struct utimbuf | ||||
| { | ||||
| 	time_t		actime; | ||||
| 	time_t		modtime; | ||||
| }; | ||||
| #endif | ||||
| 
 | ||||
| #undef	_def_syscall_3d | ||||
| #if defined(__STDPP__directive) && defined(__STDPP__hide) | ||||
| __STDPP__directive pragma pp:nohide utime | ||||
| #else | ||||
| #undef  utime | ||||
| #endif | ||||
| 
 | ||||
| #include "FEATURE/syscall" | ||||
| 
 | ||||
| #define atimeof(p)	((p)->actime) | ||||
| #define mtimeof(p)	((p)->modtime) | ||||
| 
 | ||||
| int | ||||
| utime3d(const char* path, const struct utimbuf* tms) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	time_t		atime; | ||||
| 	time_t		mtime; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.in_2d) | ||||
| 		return(UTIME(path, tms)); | ||||
| 	if (tms) | ||||
| 	{ | ||||
| 		atime = atimeof(tms); | ||||
| 		mtime = mtimeof(tms); | ||||
| 	} | ||||
| 	else atime = mtime = time((time_t*)0); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_utime, 0, path, atime, mtime)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	r = UTIME(sp, tms); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_utime)) | ||||
| 				fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,77 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if _nosys_utimensat | ||||
| 
 | ||||
| NoN(utimensat) | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| #define atimeof(p)	(((p)+0)->tv_sec) | ||||
| #define mtimeof(p)	(((p)+1)->tv_sec) | ||||
| 
 | ||||
| int | ||||
| utimensat3d(int dir, const char* path, const struct timespec* tms, int flags) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	time_t		atime; | ||||
| 	time_t		mtime; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.in_2d) | ||||
| 		return(UTIMETS(path, tms)); | ||||
| 	if (tms) | ||||
| 	{ | ||||
| 		atime = atimeof(tms); | ||||
| 		mtime = mtimeof(tms); | ||||
| 	} | ||||
| 	else atime = mtime = time((time_t*)0); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_utime, 0, path, atime, mtime)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (dir != AT_FDCWD && *path != '/') | ||||
| 		sp = (char*)path; | ||||
| 	else if (!(sp = pathreal(path, P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	r = UTIMENSAT(dir, sp, tms, flags); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_utime)) | ||||
| 				fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,67 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #define atimeof(p)	(((p)+0)->tv_sec) | ||||
| #define mtimeof(p)	(((p)+1)->tv_sec) | ||||
| 
 | ||||
| int | ||||
| utimes3d(const char* path, const struct timeval* tms) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	time_t		atime; | ||||
| 	time_t		mtime; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.in_2d) | ||||
| 		return(UTIMES(path, tms)); | ||||
| 	if (tms) | ||||
| 	{ | ||||
| 		atime = atimeof(tms); | ||||
| 		mtime = mtimeof(tms); | ||||
| 	} | ||||
| 	else atime = mtime = time((time_t*)0); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_utime, 0, path, atime, mtime)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	r = UTIMES(sp, tms); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_utime)) | ||||
| 				fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
|  | @ -1,75 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if _nosys_utimets | ||||
| 
 | ||||
| NoN(utimets) | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| #define atimeof(p)	(((p)+0)->tv_sec) | ||||
| #define mtimeof(p)	(((p)+1)->tv_sec) | ||||
| 
 | ||||
| int | ||||
| utimets3d(const char* path, const struct timespec* tms) | ||||
| { | ||||
| 	register char*	sp; | ||||
| 	register int	r; | ||||
| 	time_t		atime; | ||||
| 	time_t		mtime; | ||||
| #if FS | ||||
| 	Mount_t*	mp; | ||||
| #endif | ||||
| 
 | ||||
| 	if (state.in_2d) | ||||
| 		return(UTIMETS(path, tms)); | ||||
| 	if (tms) | ||||
| 	{ | ||||
| 		atime = atimeof(tms); | ||||
| 		mtime = mtimeof(tms); | ||||
| 	} | ||||
| 	else atime = mtime = time((time_t*)0); | ||||
| #if FS | ||||
| 	if (!fscall(NiL, MSG_utime, 0, path, atime, mtime)) | ||||
| 		return(state.ret); | ||||
| 	mp = monitored(); | ||||
| #endif | ||||
| 	if (!(sp = pathreal(path, P_TOP, NiL))) | ||||
| 		return(-1); | ||||
| 	r = UTIMETS(sp, tms); | ||||
| #if FS | ||||
| 	if (!r) | ||||
| 	{ | ||||
| 		if (mp) | ||||
| 			fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 		for (mp = state.global; mp; mp = mp->global) | ||||
| 			if (fssys(mp, MSG_utime)) | ||||
| 				fscall(mp, MSG_utime, 0, path, atime, mtime); | ||||
| 	} | ||||
| #endif | ||||
| 	return(r); | ||||
| } | ||||
| 
 | ||||
| #endif | ||||
							
								
								
									
										501
									
								
								src/cmd/3d/vcs.c
									
										
									
									
									
								
							
							
						
						
									
										501
									
								
								src/cmd/3d/vcs.c
									
										
									
									
									
								
							|  | @ -1,501 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2012 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped  | ||||
| /*
 | ||||
|  * Herman Rao | ||||
|  * AT&T Research | ||||
|  * 3d version control system interface | ||||
|  */ | ||||
| 
 | ||||
| #include "3d.h" | ||||
| 
 | ||||
| #if VCS | ||||
| 
 | ||||
| #define MAXVID		256 | ||||
| 
 | ||||
| #define MAGIC_STRING	"\026\003\023\006" | ||||
| #define MAGIC_LEN	4 | ||||
| 
 | ||||
| #define DELTA		(1 << 0) | ||||
| #define COMPRESS	(1 << 1) | ||||
| #define CPIO		(1 << 2) | ||||
| 
 | ||||
| typedef struct			/* unique id for a sfile in WAN */ | ||||
| { | ||||
| 	unsigned long	host; | ||||
| 	dev_t		dev; | ||||
| 	ino_t		ino; | ||||
| } Rno_t; | ||||
| 
 | ||||
| /*
 | ||||
|  *	structure of sfile  | ||||
|  * | ||||
|  *	attr	tags_region	delta_region	log_region | ||||
|  *	__________________________________________________________ | ||||
|  *	|      |T|T|T|T| ......|D  |D  |.....   |T|D    |T|D     | | ||||
|  *	---------------------------------------------------------- | ||||
|  *              | ||||
|  */ | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	char		magic[4]; | ||||
| 	int		type;		/* type of file, i.e., DELTA */ | ||||
| 	int		version;	/* RSCS version number */ | ||||
| 	Rno_t		rno;		/* rnode */ | ||||
| 	int		tag_reg;	/* tags region		*/ | ||||
| 	int		del_reg;	/* delta region		*/ | ||||
| 	int		log_reg;	/* log region		*/ | ||||
| 	int		basetag;	/* base tag 		*/ | ||||
| 	int		base;		/* base delta 		*/ | ||||
| 	int		basesize;	/* base delta size	*/ | ||||
| } Attr_t; | ||||
| 
 | ||||
| #define LOG		(1<<0) | ||||
| #define HASH		(1<<1) | ||||
| #define VCSLINK		(1<<2) | ||||
| #define VOBJ		(1<<3) | ||||
| #define BASE		(1<<4) | ||||
| #define MARKER		(1<<5) | ||||
| 
 | ||||
| typedef struct | ||||
| { | ||||
| 	int		length;			/* length of tag */ | ||||
| 	int		type;			/* type of data */ | ||||
| 	int		del;			/* addr of data */ | ||||
| 	int		dsize;			/* size of data */ | ||||
| 	struct stat 	stat;			/* stat info    */ | ||||
| 	int		domain;			/* domain of the creator */ | ||||
| 	char 		version[MAXVID];	/* version id */ | ||||
| } Tag_t; | ||||
| 
 | ||||
| #define ISBASE(tp)	(((tp)->type) & BASE) | ||||
| #define ISROOT(me)	(me == (uid_t)(0)) | ||||
| #define R_ISLINK(tp)	(((tp)->type) & VCSLINK) | ||||
| #define R_ISMARKER(tp)	(((tp)->type) & MARKER) | ||||
| 
 | ||||
| #define CHRLINK		'>' | ||||
| #define CHRMARKER	'<' | ||||
| #define MAXLINKS	10 | ||||
| 
 | ||||
| /*
 | ||||
|  * used by lookup_tag() | ||||
|  */ | ||||
| 
 | ||||
| #define L_LOG		(1<<0) | ||||
| #define L_HASH		(1<<1) | ||||
| #define G_LINK		(1<<2) | ||||
| 
 | ||||
| typedef struct Rdirent | ||||
| { | ||||
| 	Tag_t*	 		tag; | ||||
| 	int			oldaddr;	/* for reconf used */ | ||||
| 	char*			link;		/* used by the link */ | ||||
| 	struct Rdirent*		next; | ||||
| } Rdirent_t; | ||||
| 
 | ||||
| #define ISRSCS(ap)	(!strncmp(ap->magic, MAGIC_STRING, MAGIC_LEN)) | ||||
| #define KEYEQ(t,v,r)	(streq(t->version, v) && (!r || t->domain == r)) | ||||
| 
 | ||||
| /* 
 | ||||
|  *	list of error codes | ||||
|  */ | ||||
| 
 | ||||
| #define ERRARG		1 | ||||
| #define NOVFILE		2 | ||||
| #define NOTRSCS		3 | ||||
| #define NOVERSION	4 | ||||
| #define NOBASE		5 | ||||
| #define ERRSTRUCT	6 | ||||
| #define ERRBASE		7 | ||||
| #define ERRDELTA	8 | ||||
| #define NOMEM 		9 | ||||
| #define ERRUPDATE	10 | ||||
| #define ERRACCESS	11 | ||||
| #define ERRWRITE	12 | ||||
| #define NOENTIES	13 | ||||
| 
 | ||||
| #define DEFAULT		"default" | ||||
| #define LATEST		"latest" | ||||
| 
 | ||||
| #define VCS_RDIR	"VCS" | ||||
| #define VCS_MDIR	"..." | ||||
| #define VCS_MDIRLEN	(sizeof(VCS_MDIR)-1) | ||||
| 
 | ||||
| int | ||||
| vcs_checkout(const char* path, struct stat* st) | ||||
| { | ||||
| 	char*		b; | ||||
| 	char*		e; | ||||
| 	int 		fd; | ||||
| 	int		n; | ||||
| 	char		buf[3 * PATH_MAX]; | ||||
| 	int		synfd; | ||||
| 	char		synpath[PATH_MAX]; | ||||
| 
 | ||||
| 	NoP(st); | ||||
| 	message((-2, "vcs: checkout: %s", path)); | ||||
| 	if ((fd = fsfd(state.vcs.fs)) < 0) | ||||
| 	{ | ||||
| 		message((-2, "vcs: connect error")); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	e = (b = buf) + elementsof(buf) - 1; | ||||
| 	bprintf(&b, e, "out %s %s %s\n", state.path.vcs.rfile, state.path.vcs.version, state.path.vcs.rfile); | ||||
| 	n = b - buf; | ||||
| 	message((-2, "vsc: sendout msg %s", buf)); | ||||
| 	cancel(&state.vcs.fd); | ||||
| 	if (WRITE(fd, buf, n) != n) | ||||
| 	{ | ||||
| 		message((-2, "vcs: checkout: can't send the message %s", buf)); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	e = (b = synpath) + elementsof(synpath) - 1; | ||||
| 	bprintf(&b, e, "%s__%d", state.path.vcs.rfile, state.pid); | ||||
| 	if ((synfd = OPEN(synpath, O_CREAT | O_WRONLY, 0666)) < 0) | ||||
| 		return(-1); | ||||
| 	CLOSE(synfd); | ||||
| 	if ((n = READ(fd, buf, sizeof(buf) - 1)) > 0) | ||||
| 	{ | ||||
| 		buf[n - 1] = 0; | ||||
| 		message((-2, "vcs: checkout return msg %s", buf)); | ||||
| 		UNLINK(synpath); | ||||
| 		return(0); | ||||
| 	} | ||||
| 	return(-1); | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  *	path:		prefix/.../file_name/version_name | ||||
|  *	rfile:		prefix/.../file_name/default | ||||
|  *	version:	version_name | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| vcs_map(const char* path, char* rfile, char* version) | ||||
| { | ||||
| 	register const char*	s; | ||||
| 	const char*		p[3]; | ||||
| 	int			i; | ||||
| 
 | ||||
| 	for (s = path; *s; s++); | ||||
| 	for (i = 0; s != path && i < 3; s--) | ||||
| 		if (*s == '/') | ||||
| 			p[i++] = s + 1; | ||||
| 	s++; | ||||
| 	if (i < 3 || s == path || !strneq(p[2], VCS_MDIR, VCS_MDIRLEN)) | ||||
| 		return(-1); | ||||
| 	strcpy(version, p[0]); | ||||
| 	strcpy(rfile, path); | ||||
| 	message((-2, "vcs: map path=%s rfile=%s version=%s", path, rfile, version)); | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| static Rdirent_t*  | ||||
| add_entry(Rdirent_t* head, Tag_t* tp) | ||||
| { | ||||
| 	register Rdirent_t*	ndp; | ||||
| 	register Rdirent_t*	dp; | ||||
| 	register Rdirent_t**	prev_posn; | ||||
| 	int			result; | ||||
| 	Tag_t*			ntp; | ||||
| 	char*			link = 0; | ||||
| 	int			marker; | ||||
| 	 | ||||
| 
 | ||||
| 	if (R_ISLINK(tp) && (link = strrchr(tp->version, CHRLINK))) | ||||
| 		*link++ = 0;		 | ||||
| 	marker = R_ISMARKER(tp) ? 1 : 0; | ||||
| 	dp = head; | ||||
| 	prev_posn = &head; | ||||
| 	while (dp) | ||||
| 	{ | ||||
| 		/*
 | ||||
| 		 *	no marker as this point | ||||
| 		 */ | ||||
| 
 | ||||
| #if 0 | ||||
| 		if (!marker && R_ISMARKER(dp->tag)) | ||||
| 		{ | ||||
| 			if ((dp->tag->stat.st_ctime < tp->stat.st_ctime) && markermatch(dp->tag->version, tp->version)) | ||||
| 			{ | ||||
| 				*prev_posn = dp->next; | ||||
| 				ndp = dp->next; | ||||
| 				free(dp->tag); | ||||
| 				free(dp); | ||||
| 				dp = ndp; | ||||
| 				continue; | ||||
| 			} | ||||
| 		} | ||||
| #endif | ||||
| 		if ((result = strcmp(dp->tag->version, tp->version)) == 0) | ||||
| 		{ | ||||
| 			/*
 | ||||
| 			 * check if the minor key (domain) is the same | ||||
| 			 */ | ||||
| 
 | ||||
| 			if (dp->tag->domain == tp->domain) | ||||
| 			{ | ||||
| 				if (dp->tag->stat.st_ctime > tp->stat.st_ctime) | ||||
| 					return(head); | ||||
| 				ntp = newof(0, Tag_t, 0, tp->length); | ||||
| 				memcpy((char*)ntp, (char*)tp, tp->length); | ||||
| 				free(dp->tag); | ||||
| 				dp->tag = ntp; | ||||
| 				if (R_ISLINK(tp) && link) | ||||
| 					dp->link = strdup(link); | ||||
| 				return(head); | ||||
| 			} | ||||
| 		} | ||||
| 		else if (result > 0) | ||||
| 		{ | ||||
| 			ndp = newof(0, Rdirent_t, 1, 0); | ||||
| 			ntp = newof(0, Tag_t, 0, tp->length); | ||||
| 			memcpy((char*)ntp, (char*)tp, tp->length); | ||||
| 			ndp->tag = ntp; | ||||
| 			ndp->next = dp; | ||||
| 			if (R_ISLINK(tp) && link) | ||||
| 				ndp->link = strdup(link); | ||||
| 			*prev_posn = ndp; | ||||
| 			return(head); | ||||
| 		} | ||||
| 		prev_posn = &(dp->next); | ||||
| 		dp = dp->next; | ||||
| 	} | ||||
| 	ndp = newof(0, Rdirent_t, 1, 0); | ||||
| 	ntp = newof(0, Tag_t, 0, tp->length); | ||||
| 	memcpy((char*)ntp, (char*)tp, tp->length); | ||||
| 	ndp->tag = ntp; | ||||
| 	ndp->next = 0; | ||||
| 	if (R_ISLINK(tp) && link) | ||||
| 		ndp->link = strdup(link); | ||||
| 	*prev_posn = ndp; | ||||
| 	return(head); | ||||
| } | ||||
| 
 | ||||
| static Tag_t*	 | ||||
| get_tag(int f, register Tag_t* tp) | ||||
| { | ||||
| 	register char*	s; | ||||
| 	int		len; | ||||
| 
 | ||||
| 	s = (char *)tp + sizeof(int); | ||||
| 	memset((char *)tp, 0, sizeof(Tag_t)); | ||||
| 	if (!READ(f, (char *)&(tp->length), sizeof(int)) || (len = tp->length - sizeof(int)) && READ(f, (char *)s, len) != len) | ||||
| 		return(0); | ||||
| 	if (tp->type & LOG) | ||||
| 	{ | ||||
| 		tp->del = lseek(f, 0, SEEK_CUR); | ||||
| 		lseek(f, tp->dsize, SEEK_CUR); | ||||
| 	} | ||||
| 	return(tp); | ||||
| } | ||||
| 
 | ||||
| static Rdirent_t*  | ||||
| rs_dir(register int fd, register Attr_t* ap) | ||||
| { | ||||
| 	Tag_t			tag; | ||||
| 	register Tag_t*		tp; | ||||
| 	Rdirent_t*		head; | ||||
| 	register Rdirent_t*	dp; | ||||
| 	register Rdirent_t*	ndp; | ||||
| 	register Rdirent_t**	prev_posn; | ||||
| 
 | ||||
| 	state.vcs.now = time(NiL); | ||||
| 	 | ||||
| 	tp = &tag; | ||||
| 	head = 0; | ||||
| 	lseek(fd, ap->log_reg, SEEK_SET); | ||||
| 	while(get_tag(fd, tp)) | ||||
| 		head = add_entry(head, tp); | ||||
| 
 | ||||
| 	lseek(fd, ap->tag_reg, SEEK_SET); | ||||
| 	while((lseek(fd, 0, SEEK_CUR)<ap->del_reg) && get_tag(fd, tp)) | ||||
| 		head = add_entry(head, tp); | ||||
| 
 | ||||
| 	/*
 | ||||
| 	 * remove expired marker  | ||||
| 	 */ | ||||
| 
 | ||||
| 	dp = head; | ||||
| 	prev_posn = &head; | ||||
| 	while (dp) | ||||
| 	{ | ||||
| 		if (R_ISMARKER(dp->tag) && dp->tag->stat.st_mtime < state.vcs.now) | ||||
| 		{ | ||||
| 			*prev_posn = dp->next; | ||||
| 			ndp = dp->next; | ||||
| 			free(dp->tag); | ||||
| 			free(dp); | ||||
| 			dp = ndp; | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			prev_posn = &(dp->next); | ||||
| 			dp = dp->next; | ||||
| 		} | ||||
| 
 | ||||
| 	} | ||||
| 	 | ||||
| 	return(head); | ||||
| } | ||||
| 
 | ||||
| static Tag_t*  | ||||
| locate(register Rdirent_t* rdir, register char* version, int level) | ||||
| { | ||||
| 
 | ||||
| 	register Rdirent_t* rd; | ||||
| 	register time_t	    mtime; | ||||
| 	register Rdirent_t* p; | ||||
| 
 | ||||
| 	if (level > MAXLINKS) | ||||
| 		return(0); | ||||
| 
 | ||||
| 	if (streq(version, DEFAULT) || streq(version, LATEST)) | ||||
| 	{ | ||||
| 		for (rd = rdir, mtime = 0L; rd; rd = rd->next) | ||||
| 		{ | ||||
| 			if (rd->tag->stat.st_mtime > mtime) | ||||
| 			{ | ||||
| 				p = rd; | ||||
| 				mtime = rd->tag->stat.st_mtime; | ||||
| 			} | ||||
| 		} | ||||
| 		if (mtime) | ||||
| 			return(p->tag); | ||||
| 	} | ||||
| 
 | ||||
| 	rd = rdir; | ||||
| 	for (rd = rdir; rd; rd = rd->next) | ||||
| 	{ | ||||
| 		if (streq(rd->tag->version, version)) | ||||
| 		{ | ||||
| 			if (R_ISLINK(rd->tag)) | ||||
| 				return(locate(rdir, rd->link, level +1)); | ||||
| 			return(rd->tag); | ||||
| 		} | ||||
| 	} | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| static void  | ||||
| free_dir(register Rdirent_t* rdir) | ||||
| { | ||||
| 	Rdirent_t* rnext; | ||||
| 
 | ||||
| 	while(rdir) | ||||
| 	{ | ||||
| 		rnext = rdir->next; | ||||
| 		free(rdir->tag); | ||||
| 		if (rdir->link) | ||||
| 			free(rdir->link); | ||||
| 		free(rdir); | ||||
| 		rdir = rnext; | ||||
| 	} | ||||
| 	return; | ||||
| } | ||||
| 
 | ||||
| /*
 | ||||
|  *	return 	 0 if found it; | ||||
|  *		-1 if error | ||||
|  *		 1 if not found. | ||||
|  */ | ||||
| 
 | ||||
| static int | ||||
| vcs_stat(int fd, char* version, struct stat* st, off_t size) | ||||
| { | ||||
| 	static Attr_t*		ap = 0; | ||||
| 	static Attr_t		apbuf; | ||||
| 	static Rdirent_t*	rdir = 0; | ||||
| 	register Tag_t*		tag; | ||||
| 
 | ||||
| 	NoP(size); | ||||
| 	if (fd != state.vcs.fd || !ap) | ||||
| 	{ | ||||
| 		ap = &apbuf; | ||||
| 		if (READ(fd, (char *)ap, sizeof(Attr_t)) != sizeof(Attr_t)) | ||||
| 			return(-1); | ||||
| 		if (!rdir)	 | ||||
| 			free_dir(rdir); | ||||
| 		if (!(rdir = rs_dir(fd, ap))) | ||||
| 			return(1); | ||||
| 	} | ||||
| 	if (tag = locate(rdir, version, 0)) | ||||
| 	{ | ||||
| 		*st = tag->stat; | ||||
| 		return(0); | ||||
| 	} | ||||
| 	return(1); | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| int | ||||
| vcs_real(const char* path, struct stat* st) | ||||
| { | ||||
| 	int	n; | ||||
| 	int	fd; | ||||
| 
 | ||||
| 	message((-2, "vcs: path=%s", path)); | ||||
| 	if (st->st_nlink <= 1 || vcs_map(path, state.path.vcs.rfile, state.path.vcs.version)) | ||||
| 		return(-1); | ||||
| 
 | ||||
| 	message((-2, "vcs: real  path=%s rfile=%s version=%s", path, state.path.vcs.rfile, state.path.vcs.version)); | ||||
| 
 | ||||
| 	if (state.vcs.fd && state.vcs.dev == st->st_dev && state.vcs.ino == st->st_ino) | ||||
| 		fd = state.vcs.fd; | ||||
| 	else if ((fd = OPEN(path, O_RDONLY, 0)) < 0) | ||||
| 		return(-1); | ||||
| 	if (n = vcs_stat(fd, state.path.vcs.version, st, st->st_size)) | ||||
| 	{ | ||||
| 		if (fd != state.vcs.fd) CLOSE(fd); | ||||
| 		else if (n == -1) cancel(&state.vcs.fd); | ||||
| 		return(-1); | ||||
| 	} | ||||
| 	if (fd != state.vcs.fd) | ||||
| 	{ | ||||
| 		cancel(&state.vcs.fd); | ||||
| 		state.vcs.fd = fd; | ||||
| 		reserve(&state.vcs.fd); | ||||
| 		state.vcs.dev = st->st_dev; | ||||
| 		state.vcs.ino = st->st_ino; | ||||
| 		FCNTL(fd, F_SETFD, FD_CLOEXEC); | ||||
| 	} | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| vcs_set(Fs_t* fs, const char* arg, int argsize, const char* op, int opsize) | ||||
| { | ||||
| 	NoP(arg); | ||||
| 	NoP(argsize); | ||||
| 	NoP(op); | ||||
| 	NoP(opsize); | ||||
| 	state.vcs.fs = fs; | ||||
| 	return(0); | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| NoN(vcs) | ||||
| 	 | ||||
| #endif | ||||
|  | @ -1,78 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| /*
 | ||||
|  * 3D interface to version control system | ||||
|  * | ||||
|  * Herman Rao | ||||
|  * AT&T Research | ||||
|  */ | ||||
| 
 | ||||
| #ifndef _VCS3D_H | ||||
| #define _VCS3D_H | ||||
| 
 | ||||
| #define vcs_checkout	_3d_vcs_checkout | ||||
| #define vcs_real	_3d_vcs_real | ||||
| #define vcs_set		_3d_vcs_set | ||||
| 
 | ||||
| #define VCS_STATE				\ | ||||
| 	struct					\ | ||||
| 	{					\ | ||||
| 	dev_t		dev;			\ | ||||
| 	ino_t		ino;			\ | ||||
| 	Fs_t*		fs;			\ | ||||
| 	short		fd;			\ | ||||
| 	time_t		now;			\ | ||||
| 	}		vcs | ||||
| 
 | ||||
| #define VCS_PATH_STATE				\ | ||||
| 	struct					\ | ||||
| 	{					\ | ||||
| 	char 		rfile[PATH_MAX]; 	\ | ||||
| 	char		version[PATH_MAX];	\ | ||||
| 	}		vcs | ||||
| 
 | ||||
| #define VCS_FS							\ | ||||
| 	FSINIT("vcs", 0, vcs_set, FS_CLOSE, HASHKEY3('v','c','s')) | ||||
| 
 | ||||
| #define VCS_OPEN(p,f,m,s) 					\ | ||||
| 	do 							\ | ||||
| 	{ 							\ | ||||
| 		if (!(f & O_CREAT) && (f & O_ACCMODE != O_WRONLY) && state.vcs.fd)\ | ||||
| 		{						\ | ||||
| 			if (vcs_checkout(p, s) < 0) 		\ | ||||
| 			{ 					\ | ||||
| 				errno = ENOENT; 		\ | ||||
| 				return(-1); 			\ | ||||
| 			}					\ | ||||
| 			p = state.path.name;			\ | ||||
| 		} 						\ | ||||
| 	} while (0) | ||||
| 
 | ||||
| #define VCS_REAL(p,s) 						\ | ||||
| 	(fson(state.vcs.fs) ? vcs_real(p,s) : 0) | ||||
| 
 | ||||
| extern int	vcs_checkout(const char*, struct stat*); | ||||
| extern int	vcs_real(const char*, struct stat*); | ||||
| extern int	vcs_set(Fs_t*, const char*, int, const char*, int); | ||||
| 
 | ||||
| #endif | ||||
|  | @ -1,54 +0,0 @@ | |||
| ######################################################################## | ||||
| #                                                                      # | ||||
| #               This software is part of the ast package               # | ||||
| #          Copyright (c) 1989-2011 AT&T Intellectual Property          # | ||||
| #                      and is licensed under the                       # | ||||
| #                 Eclipse Public License, Version 1.0                  # | ||||
| #                    by AT&T Intellectual Property                     # | ||||
| #                                                                      # | ||||
| #                A copy of the License is available at                 # | ||||
| #          http://www.eclipse.org/org/documents/epl-v10.html           # | ||||
| #         (with md5 checksum b35adb5213ca9657e911e9befb180842)         # | ||||
| #                                                                      # | ||||
| #              Information and Software Systems Research               # | ||||
| #                            AT&T Research                             # | ||||
| #                           Florham Park NJ                            # | ||||
| #                                                                      # | ||||
| #                 Glenn Fowler <gsf@research.att.com>                  # | ||||
| #                  David Korn <dgk@research.att.com>                   # | ||||
| #                   Eduardo Krell <ekrell@adexus.cl>                   # | ||||
| #                                                                      # | ||||
| ######################################################################## | ||||
| : vex skip expand command ... | ||||
| # vpath expand args matching pattern | ||||
| # @(#)vex (AT&T Bell Laboratories) 04/01/93 | ||||
| case $# in | ||||
| [012])	print -u2 "Usage: $0 skip expand command ..."; exit 1 ;; | ||||
| esac | ||||
| skip=$1 | ||||
| shift | ||||
| expand=$1 | ||||
| shift | ||||
| command=$1 | ||||
| shift | ||||
| integer argc=0 noexpand=0 | ||||
| for arg | ||||
| do	if	((noexpand)) | ||||
| 	then	noexpand=0 | ||||
| 	else	case $arg in | ||||
| 		-[$skip]) | ||||
| 			noexpand=1 | ||||
| 			;; | ||||
| 		-*)	;; | ||||
| 		$expand) | ||||
| 			x=$(vpath "$arg" 2>/dev/null) | ||||
| 			case $x in | ||||
| 			?*)	arg=${x#$PWD/} ;; | ||||
| 			esac | ||||
| 			;; | ||||
| 		esac | ||||
| 	fi | ||||
| 	argv[argc]=$arg | ||||
| 	((argc+=1)) | ||||
| done | ||||
| "$command" "${argv[@]}" | ||||
|  | @ -1,52 +0,0 @@ | |||
| /***********************************************************************
 | ||||
| *                                                                      * | ||||
| *               This software is part of the ast package               * | ||||
| *          Copyright (c) 1989-2011 AT&T Intellectual Property          * | ||||
| *                      and is licensed under the                       * | ||||
| *                 Eclipse Public License, Version 1.0                  * | ||||
| *                    by AT&T Intellectual Property                     * | ||||
| *                                                                      * | ||||
| *                A copy of the License is available at                 * | ||||
| *          http://www.eclipse.org/org/documents/epl-v10.html           *
 | ||||
| *         (with md5 checksum b35adb5213ca9657e911e9befb180842)         * | ||||
| *                                                                      * | ||||
| *              Information and Software Systems Research               * | ||||
| *                            AT&T Research                             * | ||||
| *                           Florham Park NJ                            * | ||||
| *                                                                      * | ||||
| *                 Glenn Fowler <gsf@research.att.com>                  * | ||||
| *                  David Korn <dgk@research.att.com>                   * | ||||
| *                   Eduardo Krell <ekrell@adexus.cl>                   * | ||||
| *                                                                      * | ||||
| ***********************************************************************/ | ||||
| #pragma prototyped | ||||
| 
 | ||||
| /*
 | ||||
|  * vfork == fork | ||||
|  * cross your fingers | ||||
|  * csh loses | ||||
|  */ | ||||
| 
 | ||||
| #include <ast_lib.h> | ||||
| 
 | ||||
| #if _lib_vfork && 0 | ||||
| 
 | ||||
| extern int	fork(void); | ||||
| 
 | ||||
| int | ||||
| _vfork(void) | ||||
| { | ||||
| 	return(fork()); | ||||
| } | ||||
| 
 | ||||
| int | ||||
| vfork(void) | ||||
| { | ||||
| 	return(fork()); | ||||
| } | ||||
| 
 | ||||
| #else | ||||
| 
 | ||||
| int	_STUB_vfork; | ||||
| 
 | ||||
| #endif | ||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue