[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r6742 - in /fsf/trunk/libc: ChangeLog NEWS libio/fmemopen.c login/utmp_file.c
- To: commits@xxxxxxxxxx
- Subject: [commits] r6742 - in /fsf/trunk/libc: ChangeLog NEWS libio/fmemopen.c login/utmp_file.c
- From: eglibc@xxxxxxxxxx
- Date: Thu, 14 Aug 2008 07:05:55 -0000
Author: eglibc
Date: Thu Aug 14 00:05:53 2008
New Revision: 6742
Log:
Import glibc-mainline for 2008-08-14
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/NEWS
fsf/trunk/libc/libio/fmemopen.c
fsf/trunk/libc/login/utmp_file.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Thu Aug 14 00:05:53 2008
@@ -1,3 +1,17 @@
+2008-08-13 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ [BZ #6544]
+ * libio/fmemopen.c: Implement binary mode. In this mode no NUL
+ byte gets added to writes and seeks from the end use the length of
+ the buffer and not the currently terminating NUL byte.
+
+ [BZ #6634]
+ * login/utmp_file.c (getutent_r_file): Take additional parameter.
+ Set to true if locking failed.
+ (getutid_r_file): Adjust caller.
+ (pututline_file): Likewise. Return NULL in this case.
+ Patch mostly by halesh.s@xxxxxxxxxx
+
2008-08-12 Ulrich Drepper <drepper@xxxxxxxxxx>
[BZ #6589]
Modified: fsf/trunk/libc/NEWS
==============================================================================
--- fsf/trunk/libc/NEWS (original)
+++ fsf/trunk/libc/NEWS Thu Aug 14 00:05:53 2008
@@ -27,6 +27,11 @@
* Implement "e" option for popen to open file descriptor with the
close-on-exec flag set. Implemented by Ulrich Drepper.
+
+* Implement "b" mode for fmemopen. In this mode writes writes don't
+ implicitly add a NUL byte and seeks from the end of the buffer really
+ use the buffer end, not the string length as the basis.
+ Implemented by Ulrich Drepper.
* Many functions, exported and internal, now atomically set the close-on-exec
flag when run on a sufficiently new kernel. Implemented by Ulrich Drepper.
Modified: fsf/trunk/libc/libio/fmemopen.c
==============================================================================
--- fsf/trunk/libc/libio/fmemopen.c (original)
+++ fsf/trunk/libc/libio/fmemopen.c Thu Aug 14 00:05:53 2008
@@ -1,7 +1,7 @@
/* Fmemopen implementation.
- Copyright (C) 2000, 2002, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2000, 2002, 2005, 2006, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
- Contributed by Hanno Mueller, kontakt@xxxxxxxx, 2000.
+ Contributed by Hanno Mueller, kontakt@xxxxxxxx, 2000.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@@ -82,6 +82,7 @@
{
char *buffer;
int mybuffer;
+ int binmode;
size_t size;
_IO_off64_t pos;
size_t maxpos;
@@ -120,7 +121,7 @@
c = (fmemopen_cookie_t *) cookie;
- addnullc = s == 0 || b[s - 1] != '\0';
+ addnullc = c->binmode == 0 && (s == 0 || b[s - 1] != '\0');
if (c->pos + s + addnullc > c->size)
{
@@ -165,7 +166,7 @@
break;
case SEEK_END:
- np = c->maxpos - *p;
+ np = (c->binmode ? c->size : c->maxpos) - *p;
break;
default:
@@ -248,6 +249,8 @@
else
c->pos = 0;
+ c->binmode = mode[0] != '\0' && mode[1] == 'b';
+
iof.read = fmemopen_read;
iof.write = fmemopen_write;
iof.seek = fmemopen_seek;
Modified: fsf/trunk/libc/login/utmp_file.c
==============================================================================
--- fsf/trunk/libc/login/utmp_file.c (original)
+++ fsf/trunk/libc/login/utmp_file.c Thu Aug 14 00:05:53 2008
@@ -22,6 +22,7 @@
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
@@ -244,12 +245,16 @@
static int
-internal_getut_r (const struct utmp *id, struct utmp *buffer)
+internal_getut_r (const struct utmp *id, struct utmp *buffer,
+ bool *lock_failed)
{
int result = -1;
LOCK_FILE (file_fd, F_RDLCK)
- LOCKING_FAILED ();
+ {
+ *lock_failed = true;
+ LOCKING_FAILED ();
+ }
#if _HAVE_UT_TYPE - 0
if (id->ut_type == RUN_LVL || id->ut_type == BOOT_TIME
@@ -320,7 +325,10 @@
return -1;
}
- if (internal_getut_r (id, &last_entry) < 0)
+ /* We don't have to distinguish whether we can lock the file or
+ whether there is no entry. */
+ bool lock_failed = false;
+ if (internal_getut_r (id, &last_entry, &lock_failed) < 0)
{
*result = NULL;
return -1;
@@ -410,7 +418,16 @@
__utmp_equal (&last_entry, data)))
found = 1;
else
- found = internal_getut_r (data, &buffer);
+ {
+ bool lock_failed = false;
+ found = internal_getut_r (data, &buffer, &lock_failed);
+
+ if (__builtin_expect (lock_failed, false))
+ {
+ __set_errno (EAGAIN);
+ return NULL;
+ }
+ }
LOCK_FILE (file_fd, F_WRLCK)
{