chiark / gitweb /
machined: add new GetImage() bus call for retrieving the bus path for an image
[elogind.git] / src / shared / util.c
index 1ad82b27dd737d0ca056544f67056c7de9d00119..06b6077843249ecd1b287aa4b50c097fd0433b49 100644 (file)
@@ -4257,6 +4257,23 @@ bool machine_name_is_valid(const char *s) {
         return true;
 }
 
         return true;
 }
 
+bool image_name_is_valid(const char *s) {
+        if (!filename_is_valid(s))
+                return false;
+
+        if (string_has_cc(s, NULL))
+                return false;
+
+        if (!utf8_is_valid(s))
+                return false;
+
+        /* Temporary files for atomically creating new files */
+        if (startswith(s, ".#"))
+                return false;
+
+        return true;
+}
+
 int pipe_eof(int fd) {
         struct pollfd pollfd = {
                 .fd = fd,
 int pipe_eof(int fd) {
         struct pollfd pollfd = {
                 .fd = fd,