From 040e64cd9770955113ddffda73fff7b62dd5959b Mon Sep 17 00:00:00 2001 From: mckusick Date: Tue, 4 Jul 2000 03:34:11 +0000 Subject: 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 --- sys/kern/link_elf_obj.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'sys/kern/link_elf_obj.c') diff --git a/sys/kern/link_elf_obj.c b/sys/kern/link_elf_obj.c index 833f12e..18e32b2 100644 --- a/sys/kern/link_elf_obj.c +++ b/sys/kern/link_elf_obj.c @@ -504,7 +504,7 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu Elf_Addr base_vaddr; Elf_Addr base_vlimit; int error = 0; - int resid; + int resid, flags; elf_file_t ef; linker_file_t lf; Elf_Shdr *shdr; @@ -517,7 +517,8 @@ link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* resu lf = NULL; NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, p); - error = vn_open(&nd, FREAD, 0); + flags = FREAD; + error = vn_open(&nd, &flags, 0); if (error) return error; NDFREE(&nd, NDF_ONLY_PNBUF); -- cgit v1.1