diff options
author | Julian Elischer <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
---|---|---|
committer | Julian Elischer <julian@FreeBSD.org> | 1996-01-22 00:02:33 +0000 |
commit | f70177e76e605ec6e6cd5b938fa77ade5d380e87 (patch) | |
tree | a89c7f50ec371cef4418259b9dccdd31ebb2f61f /lib/libc/sys/ftruncate.c | |
parent | 61de51cad66df0d565233915f856932159d33a4a (diff) |
Reviewed by: julian and (hsu?)
Submitted by: John Birrel(L?)
changes for threadsafe operations
Notes
Notes:
svn path=/head/; revision=13545
Diffstat (limited to 'lib/libc/sys/ftruncate.c')
-rw-r--r-- | lib/libc/sys/ftruncate.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/libc/sys/ftruncate.c b/lib/libc/sys/ftruncate.c index 2f3ae6d5a024..72a6a9158153 100644 --- a/lib/libc/sys/ftruncate.c +++ b/lib/libc/sys/ftruncate.c @@ -37,6 +37,11 @@ static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93"; #include <sys/types.h> #include <sys/syscall.h> +#include <unistd.h> +#ifdef _THREAD_SAFE +#include <pthread.h> +#include "pthread_private.h" +#endif /* * This function provides 64-bit offset padding that @@ -48,5 +53,16 @@ ftruncate(fd, length) off_t length; { +#ifdef _THREAD_SAFE + int retval; + if (_thread_fd_lock(fd, FD_RDWR, NULL,__FILE__,__LINE__) != 0) { + retval = -1; + } else { + retval = __syscall((quad_t)SYS_ftruncate, fd, 0, length); + _thread_fd_unlock(fd, FD_RDWR); + } + return(retval); +#else return(__syscall((quad_t)SYS_ftruncate, fd, 0, length)); +#endif } |