PERFORCE change 116875 for review
Roman Divacky
rdivacky at FreeBSD.org
Thu Mar 29 20:39:07 UTC 2007
http://perforce.freebsd.org/chv.cgi?CH=116875
Change 116875 by rdivacky at rdivacky_witten on 2007/03/29 20:38:55
Fix a mismerge of linux_file.c
Affected files ...
.. //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#18 edit
Differences ...
==== //depot/projects/linuxolator/src/sys/compat/linux/linux_file.c#18 (text+ko) ====
@@ -234,116 +234,6 @@
return error;
}
-/*
- * common code for linux *at set of syscalls
- *
- * works like this:
- * if filename is absolute
- * ignore dirfd
- * else
- * if dirfd == AT_FDCWD
- * return CWD/filename
- * else
- * return DIRFD/filename
- */
-static int
-linux_at(struct thread *td, int dirfd, char *filename, char **newpath, char **freebuf)
-{
- struct file *fp;
- int error = 0;
- struct vnode *dvp;
- struct filedesc *fdp = td->td_proc->p_fd;
- char *fullpath = "unknown";
- char *freepath = NULL;
-
- /* don't do anything if the pathname is absolute */
- if (*filename == '/') {
- *newpath= filename;
- return (0);
- }
-
- /* check for AT_FDWCD */
- if (dirfd == LINUX_AT_FDCWD) {
- FILEDESC_LOCK(fdp);
- dvp = fdp->fd_cdir;
- FILEDESC_UNLOCK(fdp);
- } else {
- error = fget(td, dirfd, &fp);
- if (error)
- return (error);
- dvp = fp->f_vnode;
- /* only a dir can be dfd */
- if (dvp->v_type != VDIR) {
- fdrop(fp, td);
- return (ENOTDIR);
- }
- fdrop(fp, td);
- }
-
- error = vn_fullpath(td, dvp, &fullpath, &freepath);
- if (!error) {
- *newpath = malloc(strlen(fullpath) + strlen(filename) + 2, M_TEMP, M_WAITOK | M_ZERO);
- *freebuf = freepath;
- sprintf(*newpath, "%s/%s", fullpath, filename);
- }
-
- return (error);
-}
-
-int
-linux_openat(struct thread *td, struct linux_openat_args *args)
-{
- char *newpath, *oldpath, *freebuf = NULL, *path;
- int error;
-
- oldpath = malloc(MAXPATHLEN, M_TEMP, M_WAITOK);
- error = copyinstr(args->filename, oldpath, MAXPATHLEN, NULL);
-
-#ifdef DEBUG
- if (ldebug(openat))
- printf(ARGS(openat, "%i, %s, 0x%x, 0x%x"), args->dfd,
- oldpath, args->flags, args->mode);
-#endif
-
- error = linux_at(td, args->dfd, oldpath, &newpath, &freebuf);
- if (error)
- return (error);
-#ifdef DEBUG
- printf(LMSG("newpath: %s"), newpath);
-#endif
- if (args->flags & LINUX_O_CREAT)
- LCONVPATH_SEG(td, newpath, &path, 1, UIO_SYSSPACE);
- else
- LCONVPATH_SEG(td, newpath, &path, 0, UIO_SYSSPACE);
- if (freebuf)
- free(freebuf, M_TEMP);
- if (*oldpath != '/')
- free(newpath, M_TEMP);
-
- error = linux_common_open(td, path, args->flags, args->mode, 1);
- free(oldpath, M_TEMP);
- return (error);
-}
-
-int
-linux_open(struct thread *td, struct linux_open_args *args)
-{
- char *path;
-
- if (args->flags & LINUX_O_CREAT)
- LCONVPATHCREAT(td, args->path, &path);
- else
- LCONVPATHEXIST(td, args->path, &path);
-
-#ifdef DEBUG
- if (ldebug(open))
- printf(ARGS(open, "%s, 0x%x, 0x%x"),
- path, args->flags, args->mode);
-#endif
-
- return linux_common_open(td, path, args->flags, args->mode, 0);
-}
-
int
linux_openat(struct thread *td, struct linux_openat_args *args)
{
More information about the p4-projects
mailing list