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);
char *buf;
int len;
- if (strncmp (path, "/dev/", 5) == 0)
+ if (STREQLEN (path, "/dev/", 5))
buf = (char *) path;
else {
buf = sysroot_path (path);
FILE *fp;
char line[256];
- if (strcmp (method, "gzip") == 0 || strcmp (method, "compress") == 0)
+ if (STREQ (method, "gzip") || STREQ (method, "compress"))
zcat = "zcat";
- else if (strcmp (method, "bzip2") == 0)
+ else if (STREQ (method, "bzip2"))
zcat = "bzcat";
else {
reply_with_error ("zfile: unknown method");
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 ("filesize: %s", path);
+ return -1;
+ }
+
+ return buf.st_size;
+}