+int yaffsfs_CheckNameLength(const char *name)
+{
+ int retVal = 0;
+
+ int nameLength = yaffs_strnlen(name, YAFFS_MAX_NAME_LENGTH + 1);
+
+ if (nameLength == 0) {
+ yaffsfs_SetError(-ENOENT);
+ retVal = -1;
+ } else if (nameLength > YAFFS_MAX_NAME_LENGTH) {
+ yaffsfs_SetError(-ENAMETOOLONG);
+ retVal = -1;
+ }
+
+ return retVal;
+}
+
+static int yaffsfs_alt_dir_path(const YCHAR *path, YCHAR **ret_path)
+{
+ YCHAR *alt_path = NULL;
+ int path_length;
+ int i;
+
+ /*
+ * We don't have a definition for max path length.
+ * We will use 3 * max name length instead.
+ */
+ *ret_path = NULL;
+ path_length = yaffs_strnlen(path, (YAFFS_MAX_NAME_LENGTH + 1) * 3 + 1);
+
+ /* If the last character is a path divider, then we need to
+ * trim it back so that the name look-up works properly.
+ * eg. /foo/new_dir/ -> /foo/newdir
+ * Curveball: Need to handle multiple path dividers:
+ * eg. /foof/sdfse///// -> /foo/sdfse
+ */
+ if (path_length > 0 && yaffsfs_IsPathDivider(path[path_length - 1])) {
+ alt_path = kmalloc(path_length + 1, 0);
+ if (!alt_path)
+ return -1;
+ yaffs_strcpy(alt_path, path);
+ for (i = path_length - 1;
+ i >= 0 && yaffsfs_IsPathDivider(alt_path[i]); i--)
+ alt_path[i] = (YCHAR) 0;
+ }
+ *ret_path = alt_path;
+ return 0;
+}
+
+LIST_HEAD(yaffsfs_deviceList);
+