This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch master updated. glibc-2.17-608-gc740583
- From: roland at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 6 May 2013 21:57:02 -0000
- Subject: GNU C Library master sources branch master updated. glibc-2.17-608-gc740583
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, master has been updated
via c74058300c76d7afa316453c03e5776b3a9155a8 (commit)
from 9ea3513c917e04ba6cb4a6ce0b9d455f566a1d3f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=c74058300c76d7afa316453c03e5776b3a9155a8
commit c74058300c76d7afa316453c03e5776b3a9155a8
Author: Roland McGrath <roland@hack.frob.com>
Date: Mon May 6 14:56:13 2013 -0700
Clean up POSIX.1 implementation of truncate.
diff --git a/ChangeLog b/ChangeLog
index 50d9e9c..9d2a25d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-05-06 Roland McGrath <roland@hack.frob.com>
+
+ * sysdeps/posix/truncate.c (__truncate): Renamed from truncate.
+ Call __ names for open, ftruncate, and close.
+ For LENGTH==0 case, just use O_TRUNC rather than calling ftruncate.
+ (truncate): Define as weak alias.
+
2013-05-06 Joseph Myers <joseph@codesourcery.com>
* math/gen-libm-test.pl (parse_args): Initialize x before each
diff --git a/sysdeps/posix/truncate.c b/sysdeps/posix/truncate.c
index ae29be8..7ef1400 100644
--- a/sysdeps/posix/truncate.c
+++ b/sysdeps/posix/truncate.c
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-2013 Free Software Foundation, Inc.
+/* Truncate a file given by name. Generic POSIX.1 version.
+ Copyright (C) 1995-2013 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -22,20 +23,22 @@
/* Truncate PATH to LENGTH bytes. */
int
-truncate (path, length)
- const char *path;
- off_t length;
+__truncate (const char *path, off_t length)
{
int fd, ret, save;
- fd = open (path, O_WRONLY);
+ fd = __open (path, O_WRONLY | (length == 0 ? O_TRUNC : 0));
if (fd < 0)
return -1;
- ret = ftruncate (fd, length);
+ if (length == 0)
+ ret = 0;
+ else
+ ret = __ftruncate (fd, length);
save = errno;
- (void) close (fd);
+ (void) __close (fd);
if (ret < 0)
__set_errno (save);
return ret;
}
+weak_alias (__truncate, truncate)
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 7 +++++++
sysdeps/posix/truncate.c | 17 ++++++++++-------
2 files changed, 17 insertions(+), 7 deletions(-)
hooks/post-receive
--
GNU C Library master sources