summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-misc.c
diff options
context:
space:
mode:
Diffstat (limited to 'openbsd-compat/bsd-misc.c')
-rw-r--r--openbsd-compat/bsd-misc.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/openbsd-compat/bsd-misc.c b/openbsd-compat/bsd-misc.c
index 7bf46dd75..237f93931 100644
--- a/openbsd-compat/bsd-misc.c
+++ b/openbsd-compat/bsd-misc.c
@@ -24,7 +24,7 @@
24 24
25#include "includes.h" 25#include "includes.h"
26 26
27RCSID("$Id: bsd-misc.c,v 1.5 2001/10/10 20:38:56 mouring Exp $"); 27RCSID("$Id: bsd-misc.c,v 1.6 2002/05/08 02:51:32 tim Exp $");
28 28
29char *get_progname(char *argv0) 29char *get_progname(char *argv0)
30{ 30{
@@ -99,3 +99,22 @@ int utimes(char *filename, struct timeval *tvp)
99 return(utime(filename, &ub)); 99 return(utime(filename, &ub));
100} 100}
101#endif 101#endif
102
103#ifndef HAVE_TRUNCATE
104int truncate (const char *path, off_t length)
105{
106 int fd, ret, saverrno;
107
108 fd = open(path, O_WRONLY);
109 if (fd < 0)
110 return -1;
111
112 ret = ftruncate(fd, length);
113 saverrno = errno;
114 (void) close (fd);
115 if (ret == -1)
116 errno = saverrno;
117 return(ret);
118}
119#endif /* HAVE_TRUNCATE */
120