Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F102006647
D40093.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D40093.diff
View Options
diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c
+++ b/sys/kern/vfs_lookup.c
@@ -1597,117 +1597,3 @@
}
#endif
-
-/*
- * Determine if there is a suitable alternate filename under the specified
- * prefix for the specified path. If the create flag is set, then the
- * alternate prefix will be used so long as the parent directory exists.
- * This is used by the various compatibility ABIs so that Linux binaries prefer
- * files under /compat/linux for example. The chosen path (whether under
- * the prefix or under /) is returned in a kernel malloc'd buffer pointed
- * to by pathbuf. The caller is responsible for free'ing the buffer from
- * the M_TEMP bucket if one is returned.
- */
-int
-kern_alternate_path(const char *prefix, const char *path, enum uio_seg pathseg,
- char **pathbuf, int create, int dirfd)
-{
- struct nameidata nd, ndroot;
- char *ptr, *buf, *cp;
- size_t len, sz;
- int error;
-
- buf = (char *) malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- *pathbuf = buf;
-
- /* Copy the prefix into the new pathname as a starting point. */
- len = strlcpy(buf, prefix, MAXPATHLEN);
- if (len >= MAXPATHLEN) {
- *pathbuf = NULL;
- free(buf, M_TEMP);
- return (EINVAL);
- }
- sz = MAXPATHLEN - len;
- ptr = buf + len;
-
- /* Append the filename to the prefix. */
- if (pathseg == UIO_SYSSPACE)
- error = copystr(path, ptr, sz, &len);
- else
- error = copyinstr(path, ptr, sz, &len);
-
- if (error) {
- *pathbuf = NULL;
- free(buf, M_TEMP);
- return (error);
- }
-
- /* Only use a prefix with absolute pathnames. */
- if (*ptr != '/') {
- error = EINVAL;
- goto keeporig;
- }
-
- if (dirfd != AT_FDCWD) {
- /*
- * We want the original because the "prefix" is
- * included in the already opened dirfd.
- */
- bcopy(ptr, buf, len);
- return (0);
- }
-
- /*
- * We know that there is a / somewhere in this pathname.
- * Search backwards for it, to find the file's parent dir
- * to see if it exists in the alternate tree. If it does,
- * and we want to create a file (cflag is set). We don't
- * need to worry about the root comparison in this case.
- */
-
- if (create) {
- for (cp = &ptr[len] - 1; *cp != '/'; cp--);
- *cp = '\0';
-
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf);
- error = namei(&nd);
- *cp = '/';
- if (error != 0)
- goto keeporig;
- } else {
- NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, buf);
-
- error = namei(&nd);
- if (error != 0)
- goto keeporig;
-
- /*
- * We now compare the vnode of the prefix to the one
- * vnode asked. If they resolve to be the same, then we
- * ignore the match so that the real root gets used.
- * This avoids the problem of traversing "../.." to find the
- * root directory and never finding it, because "/" resolves
- * to the emulation root directory. This is expensive :-(
- */
- NDINIT(&ndroot, LOOKUP, FOLLOW, UIO_SYSSPACE, prefix);
-
- /* We shouldn't ever get an error from this namei(). */
- error = namei(&ndroot);
- if (error == 0) {
- if (nd.ni_vp == ndroot.ni_vp)
- error = ENOENT;
-
- NDFREE_PNBUF(&ndroot);
- vrele(ndroot.ni_vp);
- }
- }
-
- NDFREE_PNBUF(&nd);
- vrele(nd.ni_vp);
-
-keeporig:
- /* If there was an error, use the original path name. */
- if (error)
- bcopy(ptr, buf, len);
- return (error);
-}
diff --git a/sys/sys/syscallsubr.h b/sys/sys/syscallsubr.h
--- a/sys/sys/syscallsubr.h
+++ b/sys/sys/syscallsubr.h
@@ -94,8 +94,6 @@
enum uio_seg pathseg, int flags, int mode);
int kern_adjtime(struct thread *td, struct timeval *delta,
struct timeval *olddelta);
-int kern_alternate_path(const char *prefix, const char *path,
- enum uio_seg pathseg, char **pathbuf, int create, int dirfd);
int kern_bindat(struct thread *td, int dirfd, int fd, struct sockaddr *sa);
int kern_break(struct thread *td, uintptr_t *addr);
int kern_cap_ioctls_limit(struct thread *td, int fd, u_long *cmds,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 7, 11:30 AM (22 h, 32 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14511103
Default Alt Text
D40093.diff (3 KB)
Attached To
Mode
D40093: vfs: Retire kern_alternate_path() as unused anymore
Attached
Detach File
Event Timeline
Log In to Comment