summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_linker.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2000-07-04 03:34:11 +0000
committermckusick <mckusick@FreeBSD.org>2000-07-04 03:34:11 +0000
commit040e64cd9770955113ddffda73fff7b62dd5959b (patch)
tree4d2f06b02c643384c981cf2399da8d136ee8a568 /sys/kern/kern_linker.c
parent806786489f486969418422381048f277d86e0a20 (diff)
downloadFreeBSD-src-040e64cd9770955113ddffda73fff7b62dd5959b.zip
FreeBSD-src-040e64cd9770955113ddffda73fff7b62dd5959b.tar.gz
Move the truncation code out of vn_open and into the open system call
after the acquisition of any advisory locks. This fix corrects a case in which a process tries to open a file with a non-blocking exclusive lock. Even if it fails to get the lock it would still truncate the file even though its open failed. With this change, the truncation is done only after the lock is successfully acquired. Obtained from: BSD/OS
Diffstat (limited to 'sys/kern/kern_linker.c')
-rw-r--r--sys/kern/kern_linker.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c
index f81e000..e066924 100644
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -1175,7 +1175,7 @@ linker_search_path(const char *name)
struct nameidata nd;
struct proc *p = curproc; /* XXX */
char *cp, *ep, *result, **cpp;
- int error, extlen, len;
+ int error, extlen, len, flags;
enum vtype type;
/* qualified at all? */
@@ -1211,7 +1211,8 @@ linker_search_path(const char *name)
* and it's a regular file.
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, p);
- error = vn_open(&nd, FREAD, 0);
+ flags = FREAD;
+ error = vn_open(&nd, &flags, 0);
if (error == 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
type = nd.ni_vp->v_type;
OpenPOWER on IntegriCloud