+int
+do_mkdir_mode (const char *path, int mode)
+{
+ int r;
+
+ if (mode < 0) {
+ reply_with_error ("%s: mode is negative", path);
+ return -1;
+ }
+
+ CHROOT_IN;
+ r = mkdir (path, mode);
+ CHROOT_OUT;
+
+ if (r == -1) {
+ reply_with_perror ("%s", path);
+ return -1;
+ }
+
+ return 0;
+}
+
+/* Returns:
+ * 0 if everything was OK,
+ * -1 for a general error (sets errno),
+ * -2 if an existing path element was not a directory.
+ */