memcpy(dentptr->name, shortname, SHORT_NAME_SIZE);
}
-/*
- * Find a directory entry based on filename or start cluster number
- * If the directory entry is not found,
- * the new position for writing a directory entry will be returned
+/**
+ * find_directory_entry() - find a directory entry by filename
+ *
+ * @itr: directory iterator
+ * @filename: name of file to find
+ * Return: directory entry or NULL
*/
static dir_entry *find_directory_entry(fat_itr *itr, char *filename)
{
return itr->dent;
}
- /* allocate a cluster for more entries */
- if (!itr->dent &&
- (!itr->is_root || itr->fsdata->fatsize == 32) &&
- new_dir_table(itr))
- /* indicate that allocating dent failed */
- itr->dent = NULL;
-
return NULL;
}
}
}
- if (!itr->dent) {
- printf("Error: allocating new dir entry\n");
- ret = -EIO;
- goto exit;
- }
-
if (pos) {
/* No hole allowed */
ret = -EINVAL;
}
}
- if (!itr->dent) {
- printf("Error: allocating new dir entry\n");
- ret = -EIO;
- goto exit;
- }
-
/* Check if long name is needed */
ndent = set_name(itr, dirname, shortname);
if (ndent < 0) {