Deleted Added
full compact
vfs_lookup.c (177785) vfs_lookup.c (177997)
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)vfs_lookup.c 8.4 (Berkeley) 2/16/94
35 */
36
37#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.

--- 21 unchanged lines hidden (view full) ---

30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * @(#)vfs_lookup.c 8.4 (Berkeley) 2/16/94
35 */
36
37#include <sys/cdefs.h>
38__FBSDID("$FreeBSD: head/sys/kern/vfs_lookup.c 177785 2008-03-31 12:01:21Z kib $");
38__FBSDID("$FreeBSD: head/sys/kern/vfs_lookup.c 177997 2008-04-08 09:45:49Z kib $");
39
40#include "opt_ktrace.h"
41#include "opt_mac.h"
42#include "opt_vfs.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/kernel.h>

--- 980 unchanged lines hidden (view full) ---

1027 * alternate prefix will be used so long as the parent directory exists.
1028 * This is used by the various compatiblity ABIs so that Linux binaries prefer
1029 * files under /compat/linux for example. The chosen path (whether under
1030 * the prefix or under /) is returned in a kernel malloc'd buffer pointed
1031 * to by pathbuf. The caller is responsible for free'ing the buffer from
1032 * the M_TEMP bucket if one is returned.
1033 */
1034int
39
40#include "opt_ktrace.h"
41#include "opt_mac.h"
42#include "opt_vfs.h"
43
44#include <sys/param.h>
45#include <sys/systm.h>
46#include <sys/kernel.h>

--- 980 unchanged lines hidden (view full) ---

1027 * alternate prefix will be used so long as the parent directory exists.
1028 * This is used by the various compatiblity ABIs so that Linux binaries prefer
1029 * files under /compat/linux for example. The chosen path (whether under
1030 * the prefix or under /) is returned in a kernel malloc'd buffer pointed
1031 * to by pathbuf. The caller is responsible for free'ing the buffer from
1032 * the M_TEMP bucket if one is returned.
1033 */
1034int
1035kern_alternate_path(struct thread *td, const char *prefix, char *path,
1036 enum uio_seg pathseg, char **pathbuf, int create)
1035kern_alternate_path(struct thread *td, const char *prefix, const char *path,
1036 enum uio_seg pathseg, char **pathbuf, int create, int dirfd)
1037{
1038 struct nameidata nd, ndroot;
1039 char *ptr, *buf, *cp;
1040 size_t len, sz;
1041 int error;
1042
1043 buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
1044 *pathbuf = buf;

--- 21 unchanged lines hidden (view full) ---

1066 }
1067
1068 /* Only use a prefix with absolute pathnames. */
1069 if (*ptr != '/') {
1070 error = EINVAL;
1071 goto keeporig;
1072 }
1073
1037{
1038 struct nameidata nd, ndroot;
1039 char *ptr, *buf, *cp;
1040 size_t len, sz;
1041 int error;
1042
1043 buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
1044 *pathbuf = buf;

--- 21 unchanged lines hidden (view full) ---

1066 }
1067
1068 /* Only use a prefix with absolute pathnames. */
1069 if (*ptr != '/') {
1070 error = EINVAL;
1071 goto keeporig;
1072 }
1073
1074 if (dirfd != AT_FDCWD) {
1075 /*
1076 * We want the original because the "prefix" is
1077 * included in the already opened dirfd.
1078 */
1079 bcopy(ptr, buf, len);
1080 return (0);
1081 }
1082
1074 /*
1075 * We know that there is a / somewhere in this pathname.
1076 * Search backwards for it, to find the file's parent dir
1077 * to see if it exists in the alternate tree. If it does,
1078 * and we want to create a file (cflag is set). We don't
1079 * need to worry about the root comparison in this case.
1080 */
1081

--- 49 unchanged lines hidden ---
1083 /*
1084 * We know that there is a / somewhere in this pathname.
1085 * Search backwards for it, to find the file's parent dir
1086 * to see if it exists in the alternate tree. If it does,
1087 * and we want to create a file (cflag is set). We don't
1088 * need to worry about the root comparison in this case.
1089 */
1090

--- 49 unchanged lines hidden ---