X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmkdir-label.c;h=221dd67eb2f139346370cc21bdd68af34f30261b;hb=5484fc17a125fd9ced214aefc000d337f77ace35;hp=ee11ac06ff6b88c4289ccc415dee64b32c27865d;hpb=c34255bdb217c2a1d3ac6348252437ab8be9ca46;p=elogind.git
diff --git a/src/shared/mkdir-label.c b/src/shared/mkdir-label.c
index ee11ac06f..221dd67eb 100644
--- a/src/shared/mkdir-label.c
+++ b/src/shared/mkdir-label.c
@@ -3,8 +3,7 @@
/***
This file is part of systemd.
- Copyright 2010 Lennart Poettering
- Copyright 2013 Kay Sievers
+ Copyright 2014 Zbigniew JÄdrzejewski-Szmek
systemd is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by
@@ -20,26 +19,32 @@
along with systemd; If not, see .
***/
-#include
-#include
+#include
#include
-#include
#include
#include
-#include "label.h"
#include "util.h"
-#include "path-util.h"
-#include "mkdir.h"
+#include "formats-util.h"
-int mkdir_safe_label(const char *path, mode_t mode, uid_t uid, gid_t gid) {
- return mkdir_safe_internal(path, mode, uid, gid, mkdir_label);
-}
+int main(int argc, char** argv) {
+ const char *p = argv[1] ?: "/tmp";
+ char *pattern = strjoina(p, "/systemd-test-XXXXXX");
+ _cleanup_close_ int fd, fd2;
+ _cleanup_free_ char *cmd, *cmd2;
-int mkdir_parents_label(const char *path, mode_t mode) {
- return mkdir_parents_internal(NULL, path, mode, mkdir_label);
-}
+ fd = open_tmpfile(p, O_RDWR|O_CLOEXEC);
+ assert_se(fd >= 0);
+
+ assert_se(asprintf(&cmd, "ls -l /proc/"PID_FMT"/fd/%d", getpid(), fd) > 0);
+ system(cmd);
+
+ fd2 = mkostemp_safe(pattern, O_RDWR|O_CLOEXEC);
+ assert_se(fd >= 0);
+ assert_se(unlink(pattern) == 0);
+
+ assert_se(asprintf(&cmd2, "ls -l /proc/"PID_FMT"/fd/%d", getpid(), fd2) > 0);
+ system(cmd2);
-int mkdir_p_label(const char *path, mode_t mode) {
- return mkdir_p_internal(NULL, path, mode, mkdir_label);
+ return 0;
}