[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox-cvs
Subject: [BusyBox-cvs] busybox.stable/libbb safe_write.c, NONE, 1.1 safe_read.c, 1.2, 1.3 libbb.h, 1.75, 1.76
From: andersen () busybox ! net (Erik Andersen)
Date: 2003-12-23 14:48:16
Message-ID: 20031223214811.B95AAB40D7 () codepoet ! org
[Download RAW message or body]
Update of /var/cvs/busybox.stable/libbb
In directory nail:/tmp/cvs-serv7731/libbb
Modified Files:
safe_read.c libbb.h full_write.c full_read.c
Added Files:
safe_write.c
Log Message:
Backport a few bits from 1.0.0-pre
Index: full_read.c
===================================================================
RCS file: /var/cvs/busybox.stable/libbb/full_read.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- full_read.c 6 Dec 2001 08:10:07 -0000 1.2
+++ full_read.c 23 Dec 2003 21:48:09 -0000 1.3
@@ -2,7 +2,7 @@
/*
* Utility routines.
*
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,30 +23,29 @@
#include <unistd.h>
#include "libbb.h"
-
/*
* Read all of the supplied buffer from a file.
* This does multiple reads as necessary.
* Returns the amount read, or -1 on an error.
* A short read is returned on an end of file.
*/
-int full_read(int fd, char *buf, int len)
+ssize_t full_read(int fd, void *buf, size_t len)
{
- int cc;
- int total;
+ ssize_t cc;
+ ssize_t total;
total = 0;
while (len > 0) {
- cc = read(fd, buf, len);
+ cc = safe_read(fd, buf, len);
if (cc < 0)
- return -1;
+ return cc; /* read() returns -1 on failure. */
if (cc == 0)
break;
- buf += cc;
+ buf = ((char *)buf) + cc;
total += cc;
len -= cc;
}
Index: safe_read.c
===================================================================
RCS file: /var/cvs/busybox.stable/libbb/safe_read.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- safe_read.c 6 Dec 2001 08:10:08 -0000 1.2
+++ safe_read.c 23 Dec 2003 21:48:09 -0000 1.3
@@ -2,7 +2,7 @@
/*
* Utility routines.
*
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Index: full_write.c
===================================================================
RCS file: /var/cvs/busybox.stable/libbb/full_write.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- full_write.c 6 Dec 2001 08:10:07 -0000 1.2
+++ full_write.c 23 Dec 2003 21:48:09 -0000 1.3
@@ -2,7 +2,7 @@
/*
* Utility routines.
*
- * Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
+ * Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,21 +28,21 @@
* This does multiple writes as necessary.
* Returns the amount written, or -1 on an error.
*/
-int full_write(int fd, const char *buf, int len)
+ssize_t full_write(int fd, const void *buf, size_t len)
{
- int cc;
- int total;
+ ssize_t cc;
+ ssize_t total;
total = 0;
while (len > 0) {
- cc = write(fd, buf, len);
+ cc = safe_write(fd, buf, len);
if (cc < 0)
- return -1;
+ return cc; /* write() returns -1 on failure. */
- buf += cc;
total += cc;
+ buf = ((const char *)buf) + cc;
len -= cc;
}
Index: libbb.h
===================================================================
RCS file: /var/cvs/busybox.stable/libbb/libbb.h,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- libbb.h 23 Dec 2003 21:36:55 -0000 1.75
+++ libbb.h 23 Dec 2003 21:48:09 -0000 1.76
@@ -99,8 +99,8 @@
char *chunkstrdup(const char *str);
void freeChunks(void);
ssize_t safe_read(int fd, void *buf, size_t count);
-int full_write(int fd, const char *buf, int len);
-int full_read(int fd, char *buf, int len);
+ssize_t full_write(int fd, const void *buf, size_t len);
+ssize_t full_read(int fd, void *buf, size_t len);
int recursive_action(const char *fileName, int recurse, int followLinks, int depthFirst,
int (*fileAction) (const char *fileName, struct stat* statbuf, void* userData),
int (*dirAction) (const char *fileName, struct stat* statbuf, void* userData),
--- NEW FILE: safe_write.c ---
/* vi: set sw=4 ts=4: */
/*
* Utility routines.
*
* Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include "libbb.h"
ssize_t safe_write(int fd, const void *buf, size_t count)
{
ssize_t n;
do {
n = write(fd, buf, count);
} while (n < 0 && errno == EINTR);
return n;
}
/* END CODE */
/*
Local Variables:
c-file-style: "linux"
c-basic-offset: 4
tab-width: 4
End:
*/
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic