summaryrefslogtreecommitdiffstats
path: root/daemon/file.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/file.c')
-rw-r--r--daemon/file.c69
1 files changed, 0 insertions, 69 deletions
diff --git a/daemon/file.c b/daemon/file.c
index cdf6b1bc..2ea8b738 100644
--- a/daemon/file.c
+++ b/daemon/file.c
@@ -85,75 +85,6 @@ do_touch (const char *path)
return 0;
}
-char *
-do_cat (const char *path)
-{
- int fd;
- size_t alloc, size, max;
- ssize_t r;
- char *buf, *buf2;
-
- CHROOT_IN;
- fd = open (path, O_RDONLY|O_CLOEXEC);
- CHROOT_OUT;
-
- if (fd == -1) {
- reply_with_perror ("open: %s", path);
- return NULL;
- }
-
- /* Read up to GUESTFS_MESSAGE_MAX - <overhead> bytes. If it's
- * larger than that, we need to return an error instead (for
- * correctness).
- */
- max = GUESTFS_MESSAGE_MAX - 1000;
- buf = NULL;
- size = alloc = 0;
-
- for (;;) {
- if (size >= alloc) {
- alloc += 8192;
- if (alloc > max) {
- reply_with_error ("%s: file is too large for message buffer",
- path);
- free (buf);
- close (fd);
- return NULL;
- }
- buf2 = realloc (buf, alloc);
- if (buf2 == NULL) {
- reply_with_perror ("realloc");
- free (buf);
- close (fd);
- return NULL;
- }
- buf = buf2;
- }
-
- r = read (fd, buf + size, alloc - size);
- if (r == -1) {
- reply_with_perror ("read: %s", path);
- free (buf);
- close (fd);
- return NULL;
- }
- if (r == 0) {
- buf[size] = '\0';
- break;
- }
- if (r > 0)
- size += r;
- }
-
- if (close (fd) == -1) {
- reply_with_perror ("close: %s", path);
- free (buf);
- return NULL;
- }
-
- return buf; /* caller will free */
-}
-
char **
do_read_lines (const char *path)
{