MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / ntfs_dir

Function ntfs_dir

src/ntfs_dir.c:304–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

302}
303
304static int ntfs_dir(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const unsigned long int cluster, file_info_t *dir_list)
305{
306 ntfs_inode *inode;
307 s64 pos;
308 struct ntfs_dir_struct *ls=(struct ntfs_dir_struct*)dir_data->private_dir_data;
309 ls->dir_list=dir_list;
310
311 inode = ntfs_inode_open (ls->vol, cluster);
312 if (!inode) {
313 log_error("ntfs_dir: ntfs_inode_open failed\n");
314 return -1;
315 }
316
317 /*
318 * We now are at the final path component. If it is a file just
319 * list it. If it is a directory, list its contents.
320 */
321 pos = 0;
322 if (inode->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
323 if(ntfs_readdir(inode, &pos, ls, (ntfs_filldir_t)ntfs_td_list_entry)<0)
324 {
325 log_error("ntfs_readdir failed for cluster %lu: %s\n", cluster,
326 strerror(errno));
327 }
328 }
329 else
330 log_critical("ntfs_readdir BUG not MFT_RECORD_IS_DIRECTORY\n");
331 /* Finished with the inode; release it. */
332 ntfs_inode_close(inode);
333 td_list_sort(&dir_list->list, filesort);
334 return 0;
335}
336
337enum { bufsize = 4096 };
338

Callers

nothing calls this directly

Calls 1

td_list_sortFunction · 0.85

Tested by

no test coverage detected