X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Ftmpfiles%2Ftmpfiles.c;h=6e0c093a82c58174ccfeb44efad79e69e32d96e2;hb=e7aee75932e8a5bee54eefcc77f4702a3ea79db2;hp=12ec0b2f1bec9c1982f7e4f36f4f76d817d0590d;hpb=ca2e894bdbd06b43800b57074be0e499a3539b0d;p=elogind.git diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 12ec0b2f1..6e0c093a8 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -744,10 +744,11 @@ static int create_item(Item *i) { case CREATE_BLOCK_DEVICE: case CREATE_CHAR_DEVICE: { + mode_t file_type = (i->type == CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR); u = umask(0); - label_context_set(i->path, CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR); - r = mknod(i->path, i->mode | (i->type == CREATE_BLOCK_DEVICE ? S_IFBLK : S_IFCHR), i->major_minor); + label_context_set(i->path, file_type); + r = mknod(i->path, i->mode | file_type, i->major_minor); e = errno; label_context_clear(); umask(u); @@ -763,7 +764,7 @@ static int create_item(Item *i) { return -errno; } - if (i->type == CREATE_BLOCK_DEVICE ? !S_ISBLK(st.st_mode) : !S_ISCHR(st.st_mode)) { + if ((st.st_mode & S_IFMT) != file_type) { log_error("%s is not a device node.", i->path); return -EEXIST; } @@ -1321,7 +1322,7 @@ int main(int argc, char *argv[]) { fragment = resolve_fragment(argv[j], conf_file_dirs); if (!fragment) { - log_error("Failed to find any: %s file: %m", argv[j]); + log_error("Failed to find a %s file: %m", argv[j]); r = EXIT_FAILURE; goto finish; }