New API: get-umask, returns the current umask (RHBZ#582891).
[libguestfs.git] / daemon / umask.c
index 22d2cc9..a9ddeab 100644 (file)
@@ -44,3 +44,20 @@ do_umask (int mask)
 
   return r;
 }
+
+int
+do_get_umask (void)
+{
+  int r;
+
+  r = umask (022);
+  if (r == -1) {
+    reply_with_perror ("umask");
+    return -1;
+  }
+
+  /* Restore the umask, since the call above corrupted it. */
+  umask (r);
+
+  return r;
+}