Some filesystem magics are too big to fit in 31 bits,
and are wrapped to negative. f_type is an int on 32 bits, so
it is signed, and we get a warning on comparison.
- log_debug("%s: wrote %u items, with %zu bytes of strings, %zu total size.",
+ log_debug("%s: wrote %u items, with %zu bytes of strings, %ld total size.",
CATALOG_DATABASE, n, sb->len, ftell(w));
free(p);
CATALOG_DATABASE, n, sb->len, ftell(w));
free(p);
- sfs.f_type == CIFS_MAGIC_NUMBER ||
+ (long)sfs.f_type == (long)CIFS_MAGIC_NUMBER ||
sfs.f_type == CODA_SUPER_MAGIC ||
sfs.f_type == NCP_SUPER_MAGIC ||
sfs.f_type == NFS_SUPER_MAGIC ||
sfs.f_type == CODA_SUPER_MAGIC ||
sfs.f_type == NCP_SUPER_MAGIC ||
sfs.f_type == NFS_SUPER_MAGIC ||
+static int is_temporary_fs(struct statfs *s) {
+ assert(s);
+ return s->f_type == TMPFS_MAGIC ||
+ (long)s->f_type == (long)RAMFS_MAGIC;
+}
+
int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) {
struct statfs s;
int rm_rf_children(int fd, bool only_dirs, bool honour_sticky, struct stat *root_dev) {
struct statfs s;
/* We refuse to clean disk file systems with this call. This
* is extra paranoia just to be sure we never ever remove
* non-state data */
/* We refuse to clean disk file systems with this call. This
* is extra paranoia just to be sure we never ever remove
* non-state data */
-
- if (s.f_type != TMPFS_MAGIC &&
- s.f_type != RAMFS_MAGIC) {
+ if (!is_temporary_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
close_nointr_nofail(fd);
return -EPERM;
log_error("Attempted to remove disk file system, and we can't allow that.");
close_nointr_nofail(fd);
return -EPERM;
if (statfs(path, &s) < 0)
return -errno;
if (statfs(path, &s) < 0)
return -errno;
- if (s.f_type != TMPFS_MAGIC &&
- s.f_type != RAMFS_MAGIC) {
+ if (!is_temporary_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
return -EPERM;
}
log_error("Attempted to remove disk file system, and we can't allow that.");
return -EPERM;
}
- if (s.f_type != TMPFS_MAGIC &&
- s.f_type != RAMFS_MAGIC) {
+ if (!is_temporary_fs(&s)) {
log_error("Attempted to remove disk file system, and we can't allow that.");
close_nointr_nofail(fd);
return -EPERM;
log_error("Attempted to remove disk file system, and we can't allow that.");
close_nointr_nofail(fd);
return -EPERM;
saved = access("/etc/initrd-release", F_OK) >= 0 &&
statfs("/", &s) >= 0 &&
saved = access("/etc/initrd-release", F_OK) >= 0 &&
statfs("/", &s) >= 0 &&
- (s.f_type == TMPFS_MAGIC || s.f_type == RAMFS_MAGIC);