summaryrefslogtreecommitdiffstats
path: root/lib/libbb.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2014-07-30 10:43:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2014-08-07 06:13:51 +0200
commit3cfa4bc00c61eca4c0986c793dd21b8b5271fd8f (patch)
tree01b10c6fa35134394d170696c5c14c67b20b87b3 /lib/libbb.c
parent2fd4f0fbe93ec7e6e10b3475257521dd8418f8e7 (diff)
downloadbarebox-3cfa4bc00c61eca4c0986c793dd21b8b5271fd8f.tar.gz
barebox-3cfa4bc00c61eca4c0986c793dd21b8b5271fd8f.tar.xz
move file helper functions to separate file
We have our file helper functions in several places. Move them all to lib/libfile.c. With this we no longer have file helpers in fs/fs.c which contains the core fs functions and no functions in lib/libbb.c which are not from busybox. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'lib/libbb.c')
-rw-r--r--lib/libbb.c93
1 files changed, 0 insertions, 93 deletions
diff --git a/lib/libbb.c b/lib/libbb.c
index dd42e662b4..239611c27b 100644
--- a/lib/libbb.c
+++ b/lib/libbb.c
@@ -126,96 +126,3 @@ char *simple_itoa(unsigned int i)
return p + 1;
}
EXPORT_SYMBOL(simple_itoa);
-
-/*
- * write_full - write to filedescriptor
- *
- * Like write, but guarantees to write the full buffer out, else
- * it returns with an error.
- */
-int write_full(int fd, void *buf, size_t size)
-{
- size_t insize = size;
- int now;
-
- while (size) {
- now = write(fd, buf, size);
- if (now <= 0)
- return now;
- size -= now;
- buf += now;
- }
-
- return insize;
-}
-EXPORT_SYMBOL(write_full);
-
-/*
- * read_full - read from filedescriptor
- *
- * Like read, but this function only returns less bytes than
- * requested when the end of file is reached.
- */
-int read_full(int fd, void *buf, size_t size)
-{
- size_t insize = size;
- int now;
- int total = 0;
-
- while (size) {
- now = read(fd, buf, size);
- if (now == 0)
- return total;
- if (now < 0)
- return now;
- total += now;
- size -= now;
- buf += now;
- }
-
- return insize;
-}
-EXPORT_SYMBOL(read_full);
-
-/*
- * read_file_line - read a line from a file
- *
- * Used to compose a filename from a printf format and to read a line from this
- * file. All leading and trailing whitespaces (including line endings) are
- * removed. The returned buffer must be freed with free(). This function is
- * supposed for reading variable like content into a buffer, so files > 1024
- * bytes are ignored.
- */
-char *read_file_line(const char *fmt, ...)
-{
- va_list args;
- char *filename;
- char *buf, *line = NULL;
- size_t size;
- int ret;
- struct stat s;
-
- va_start(args, fmt);
- filename = vasprintf(fmt, args);
- va_end(args);
-
- ret = stat(filename, &s);
- if (ret)
- goto out;
-
- if (s.st_size > 1024)
- goto out;
-
- buf = read_file(filename, &size);
- if (!buf)
- goto out;
-
- line = strim(buf);
-
- line = xstrdup(line);
- free(buf);
-out:
- free(filename);
- return line;
-}
-EXPORT_SYMBOL_GPL(read_file_line);