if (*endp == '\0') return idx;
find_file (const char *s){  int level = 1;  long int idx = 0;  if (strcmp (s, ".") == 0)    return 0;  while (*s != '\0')    {      char *endp = strchrnul (s, '/');      PRINTF ("looking for %.*s, level %d\n", (int) (endp - s), s, level);      while (idx < nfiles && filesystem[idx].level >= level)	{	  if (filesystem[idx].level == level	      && memcmp (s, filesystem[idx].name, endp - s) == 0	      && filesystem[idx].name[endp - s] == '\0')	    break;	  ++idx;	}      if (idx == nfiles || filesystem[idx].level < level)	{	  errno = ENOENT;	  return -1;	}      if (filesystem[idx].type != DT_DIR	  && (idx + 1 >= nfiles	      || filesystem[idx].level >= filesystem[idx + 1].level))	{	  errno = ENOTDIR;	  return -1;	}      ++idx;      if (*endp == '\0')	return idx;      s = endp + 1;      ++level;    }  errno = ENOENT;  return -1;}