]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - repair/da_util.c
libxfs: refactor manage_zones()
[thirdparty/xfsprogs-dev.git] / repair / da_util.c
index 1450767fba08931771141f15db5fca5412ff14db..4a258e584e2a1b3a486e0db8c766ec223f83c052 100644 (file)
 #include "da_util.h"
 
 /*
- * takes a name and length (name need not be null-terminated)
- * and returns 1 if the name contains a '/' or a \0, returns 0
- * otherwise
+ * Takes a name and length (name need not be null-terminated) and whether
+ * we are checking a dir (as opposed to an attr).
+ * Returns 1 if the name contains a NUL or if a directory entry contains a '/'.
+ * Returns 0 if the name checks out.
  */
 int
-namecheck(char *name, int length)
+namecheck(
+       char    *name,
+       int     length,
+       bool    isadir)
 {
-       char *c;
-       int i;
+       char    *c;
+       int     i;
 
        ASSERT(length < MAXNAMELEN);
 
        for (c = name, i = 0; i < length; i++, c++) {
-               if (*c == '/' || *c == '\0')
+               if (isadir && *c == '/')
+                       return 1;
+               if (*c == '\0')
                        return 1;
        }