+/* Helper for functions that need an argument ("path") that is absolute. */
+#define ABS_PATH(path,errcode) \
+ do { \
+ if ((path)[0] != '/') { \
+ reply_with_error ("%s: path must start with a / character", __func__); \
+ return (errcode); \
+ } \
+ } while (0)
+
+/* Helper for functions that need an argument ("path") that is a device. */
+#define IS_DEVICE(path,errcode) \
+ do { \
+ struct stat statbuf; \
+ if (strncmp ((path), "/dev/", 5) != 0) { \
+ reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \
+ return (errcode); \
+ } \
+ if (stat ((path), &statbuf) == -1) { \
+ reply_with_perror ("%s: %s", __func__, (path)); \
+ return (errcode); \
+ } \
+ } while (0)
+