return -1;
}
-#ifdef HAVE_FUTIMENS
r = futimens (fd, NULL);
-#else
- r = futimes (fd, NULL);
-#endif
if (r == -1) {
reply_with_perror ("futimens: %s", path);
close (fd);
if (size >= alloc) {
alloc += 8192;
if (alloc > max) {
- reply_with_error ("cat: %s: file is too large for message buffer",
+ reply_with_error ("%s: file is too large for message buffer",
path);
free (buf);
close (fd);
CHROOT_OUT;
if (r == -1) {
- reply_with_perror ("unlink: %s", path);
+ reply_with_perror ("%s", path);
return -1;
}
CHROOT_OUT;
if (r == -1) {
- reply_with_perror ("chmod: %s: 0%o", path, mode);
+ reply_with_perror ("%s: 0%o", path, mode);
return -1;
}
CHROOT_OUT;
if (r == -1) {
- reply_with_perror ("chown: %s: %d.%d", path, owner, group);
+ reply_with_perror ("%s: %d.%d", path, owner, group);
return -1;
}
CHROOT_OUT;
if (r == -1) {
- reply_with_perror ("lchown: %s: %d.%d", path, owner, group);
+ reply_with_perror ("%s: %d.%d", path, owner, group);
return -1;
}
* be caught later when we try to serialize the message.
*/
if (*size_r >= GUESTFS_MESSAGE_MAX) {
- reply_with_error ("read_file: %s: file is too large for the protocol, use guestfs_download instead", path);
+ reply_with_error ("%s: file is too large for the protocol, use guestfs_download instead", path);
close (fd);
return NULL;
}
* will be caught later when we try to serialize the message.
*/
if (count >= GUESTFS_MESSAGE_MAX) {
- reply_with_error ("pread: %s: count is too large for the protocol, use smaller reads", path);
+ reply_with_error ("%s: count is too large for the protocol, use smaller reads", path);
return NULL;
}
if (r == -1) {
free (out);
- reply_with_error ("file: %s: %s", path, err);
+ reply_with_error ("%s: %s", path, err);
free (err);
return NULL;
}
else if (STREQ (method, "bzip2"))
zcat = "bzcat";
else {
- reply_with_error ("zfile: unknown method");
+ reply_with_error ("unknown method");
return NULL;
}
free (cmd);
if (fgets (line, sizeof line, fp) == NULL) {
- reply_with_perror ("zfile: fgets");
+ reply_with_perror ("fgets");
fclose (fp);
return NULL;
}
if (fclose (fp) == -1) {
- reply_with_perror ("zfile: fclose");
+ reply_with_perror ("fclose");
return NULL;
}
return strdup (line);
}
+
+int64_t
+do_filesize (const char *path)
+{
+ int r;
+ struct stat buf;
+
+ CHROOT_IN;
+ r = stat (path, &buf); /* follow symlinks */
+ CHROOT_OUT;
+
+ if (r == -1) {
+ reply_with_perror ("%s", path);
+ return -1;
+ }
+
+ return buf.st_size;
+}