int nffs_dir_open(const char *path, struct nffs_dir **out_dir) { struct nffs_inode_entry *parent_inode_entry; struct nffs_dir *dir; int rc; rc = nffs_path_find_inode_entry(path, &parent_inode_entry); if (rc != 0) { return rc; } if (!nffs_hash_id_is_dir(parent_inode_entry->nie_hash_entry.nhe_id)) { return FS_EINVAL; } dir = nffs_dir_alloc(); if (dir == NULL) { return FS_ENOMEM; } dir->nd_parent_inode_entry = parent_inode_entry; dir->nd_parent_inode_entry->nie_refcnt++; memset(&dir->nd_dirent, 0, sizeof dir->nd_dirent); *out_dir = dir; return 0; }
int nffs_misc_create_lost_found_dir(void) { int rc; rc = nffs_path_new_dir("/lost+found", &nffs_lost_found_dir); switch (rc) { case 0: return 0; case FS_EEXIST: rc = nffs_path_find_inode_entry("/lost+found", &nffs_lost_found_dir); return rc; default: return rc; } }