summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2005-05-16 18:45:19 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:55 -0500
commitd101da235bebfedc773e2f1be824df926891cc1a (patch)
tree4ad6e716546e2abbe80e5070be086e5015e25b16
parent32f374cb3feff9b929509216f6586e9053108cde (diff)
downloadsamba-d101da235bebfedc773e2f1be824df926891cc1a.tar.gz
samba-d101da235bebfedc773e2f1be824df926891cc1a.tar.bz2
samba-d101da235bebfedc773e2f1be824df926891cc1a.zip
r6822: Use chsize if we don't have ftruncate. From Steven Edwards <steven_ed4153@yahoo.com>.
Jeremy. (This used to be commit 2f78ba5ea71504c2c9bb44c36000b3cab1227f78)
-rw-r--r--source3/configure.in2
-rw-r--r--source3/lib/replace.c19
2 files changed, 12 insertions, 9 deletions
diff --git a/source3/configure.in b/source3/configure.in
index 9b53e65c65..b86d3f2501 100644
--- a/source3/configure.in
+++ b/source3/configure.in
@@ -1034,7 +1034,7 @@ AC_CHECK_FUNCS(fstat strchr utime utimes getrlimit fsync memset strlcpy strlcat
AC_CHECK_FUNCS(memmove vsnprintf snprintf asprintf vasprintf setsid glob strpbrk pipe crypt16 getauthuid)
AC_CHECK_FUNCS(strftime sigprocmask sigblock sigaction sigset innetgr setnetgrent getnetgrent endnetgrent)
AC_CHECK_FUNCS(initgroups select poll rdchk getgrnam getgrent pathconf realpath)
-AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate stat64 fstat64)
+AC_CHECK_FUNCS(setpriv setgidx setuidx setgroups sysconf mktime rename ftruncate chsize stat64 fstat64)
AC_CHECK_FUNCS(lstat64 fopen64 atexit grantpt dup2 lseek64 ftruncate64 readdir64)
AC_CHECK_FUNCS(fseek64 fseeko64 ftell64 ftello64 setluid getpwanam setlinebuf)
AC_CHECK_FUNCS(srandom random srand rand setenv usleep strcasecmp fcvt fcvtl symlink readlink)
diff --git a/source3/lib/replace.c b/source3/lib/replace.c
index 298707727e..b7695bd8dd 100644
--- a/source3/lib/replace.c
+++ b/source3/lib/replace.c
@@ -29,17 +29,20 @@ ftruncate for operating systems that don't have it
********************************************************************/
int ftruncate(int f,SMB_OFF_T l)
{
- struct flock fl;
-
- fl.l_whence = 0;
- fl.l_len = 0;
- fl.l_start = l;
- fl.l_type = F_WRLCK;
- return fcntl(f, F_FREESP, &fl);
+#ifdef HAVE_CHSIZE
+ return chsize(f,l);
+#else
+ struct flock fl;
+
+ fl.l_whence = 0;
+ fl.l_len = 0;
+ fl.l_start = l;
+ fl.l_type = F_WRLCK;
+ return fcntl(f, F_FREESP, &fl);
+#endif
}
#endif /* HAVE_FTRUNCATE */
-
#ifndef HAVE_STRLCPY
/* like strncpy but does not 0 fill the buffer and always null
terminates. bufsize is the size of the destination buffer */