diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-08-17 11:07:33 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-08-17 16:08:13 +0100 |
commit | 735ce57cda24e2e2f41418d9a9ad34944fefdfb9 (patch) | |
tree | e320bcbf51dad6e798260601b62685e46e281b1d /daemon/file.c | |
parent | 96d3ac28d636290e9478ac27226862e627682025 (diff) | |
download | libguestfs-735ce57cda24e2e2f41418d9a9ad34944fefdfb9.tar.gz libguestfs-735ce57cda24e2e2f41418d9a9ad34944fefdfb9.tar.xz libguestfs-735ce57cda24e2e2f41418d9a9ad34944fefdfb9.zip |
guestfs_read_lines: Reimplement to avoid protocol limits.
This also makes a larger test suite for this command.
Diffstat (limited to 'daemon/file.c')
-rw-r--r-- | daemon/file.c | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/daemon/file.c b/daemon/file.c index 42c13c9c..0b197412 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -85,54 +85,6 @@ do_touch (const char *path) return 0; } -char ** -do_read_lines (const char *path) -{ - DECLARE_STRINGSBUF (r); - FILE *fp; - char *line = NULL; - size_t len = 0; - ssize_t n; - - CHROOT_IN; - fp = fopen (path, "r"); - CHROOT_OUT; - - if (!fp) { - reply_with_perror ("fopen: %s", path); - return NULL; - } - - while ((n = getline (&line, &len, fp)) != -1) { - /* Remove either LF or CRLF. */ - if (n >= 2 && line[n-2] == '\r' && line[n-1] == '\n') - line[n-2] = '\0'; - else if (n >= 1 && line[n-1] == '\n') - line[n-1] = '\0'; - - if (add_string (&r, line) == -1) { - free (line); - fclose (fp); - return NULL; - } - } - - free (line); - - if (end_stringsbuf (&r) == -1) { - fclose (fp); - return NULL; - } - - if (fclose (fp) == EOF) { - reply_with_perror ("fclose: %s", path); - free_stringslen (r.argv, r.size); - return NULL; - } - - return r.argv; -} - int do_rm (const char *path) { |