From 872cbe6466bdbf155142ffe55950c757ad888707 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Wed, 9 Apr 2008 16:42:50 +0000 Subject: [PATCH] Remove using magic value of -1 to distinguish between linux_open() and linux_openat(). Instead just pass AT_FDCWD into linux_common_open() for the linux_open() case. This prevents passing -1 as a dirfd to openat() from succeeding which is wrong. Suggested by: rwatson, kib Approved by: kib (mentor) --- sys/compat/linux/linux_file.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 646f6ebfb5e8..49e9cd20375f 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -131,10 +131,8 @@ linux_common_open(struct thread *td, int dirfd, char *path, int l_flags, int mod bsd_flags |= O_NOFOLLOW; /* XXX LINUX_O_NOATIME: unable to be easily implemented. */ - if (dirfd != -1) - error = kern_openat(td, dirfd, path, UIO_SYSSPACE, bsd_flags, mode); - else - error = kern_open(td, path, UIO_SYSSPACE, bsd_flags, mode); + error = kern_openat(td, dirfd, path, UIO_SYSSPACE, bsd_flags, mode); + if (!error) { fd = td->td_retval[0]; /* @@ -215,7 +213,7 @@ linux_open(struct thread *td, struct linux_open_args *args) path, args->flags, args->mode); #endif - return (linux_common_open(td, -1, path, args->flags, args->mode)); + return (linux_common_open(td, AT_FDCWD, path, args->flags, args->mode)); } int