- if (stat ((path), &statbuf) == -1) { \
- reply_with_perror ("%s: %s", __func__, (path)); \
- return (errcode); \
+ if (device_name_translation ((path), __func__) == -1) \
+ fail_stmt; \
+ } while (0)
+
+/* Helper for functions which need either an absolute path in the
+ * mounted filesystem, OR a /dev/ device which exists.
+ *
+ * NB. Cannot be used for FileIn functions.
+ *
+ * NB #2: Functions which mix filenames and device paths should be
+ * avoided, and existing functions should be deprecated. This is
+ * because we intend in future to make device parameters a distinct
+ * type from filenames.
+ */
+#define REQUIRE_ROOT_OR_RESOLVE_DEVICE(path,fail_stmt) \
+ do { \
+ if (strncmp ((path), "/dev/", 5) == 0) \
+ RESOLVE_DEVICE ((path), fail_stmt); \
+ else { \
+ NEED_ROOT (fail_stmt); \
+ ABS_PATH ((path),fail_stmt); \