summaryrefslogtreecommitdiffstats
path: root/src/fat_adv.c
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2016-04-10 19:17:27 +0200
committerChristophe Grenier <grenier@cgsecurity.org>2016-04-10 19:17:27 +0200
commitb5ec147d4663cf73fba8c1fa082aedfda4c09dd4 (patch)
treef6cebf77b089b5f72143aeeef9aebd7196da8252 /src/fat_adv.c
parentdcd998ca2a96ca7ae8a01e5d52214a35d0f7460e (diff)
src/fat_adv.c: create new function is_root_cluster_candidat() for better code readability
Diffstat (limited to 'src/fat_adv.c')
-rw-r--r--src/fat_adv.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/fat_adv.c b/src/fat_adv.c
index 77aa3df..7561dd6 100644
--- a/src/fat_adv.c
+++ b/src/fat_adv.c
@@ -310,6 +310,13 @@ static int ask_root_directory(disk_t *disk_car, const partition_t *partition, co
}
#endif
+static int is_root_cluster_candidat(const file_info_t *dir_list)
+{
+ const file_info_t *file1=td_list_entry_const(dir_list->list.next, const file_info_t, list);
+ const file_info_t *file2=td_list_entry_const(file1->list.next, const file_info_t, list);
+ return (!td_list_empty(&dir_list->list) && (&file2->list==&dir_list->list || file1->st_ino!=file2->st_ino));
+}
+
static unsigned int fat32_find_root_cluster(disk_t *disk_car,const partition_t *partition,const unsigned int sectors_per_cluster, const unsigned long int no_of_cluster,const unsigned int reserved, const unsigned int fat_length, const int interface, const int verbose, const unsigned int expert, const unsigned int first_free_cluster, const unsigned int fats)
{
unsigned long int root_cluster=0;
@@ -505,10 +512,8 @@ static unsigned int fat32_find_root_cluster(disk_t *disk_car,const partition_t *
.list = TD_LIST_HEAD_INIT(dir_list.list),
.name = NULL
};
- const file_info_t *file1=td_list_entry_const(dir_list.list.next, const file_info_t, list);
- const file_info_t *file2=td_list_entry_const(file1->list.next, const file_info_t, list);
dir_fat_aux(buffer, cluster_size, 0, &dir_list);
- if(!td_list_empty(&dir_list.list) && (&file2->list==&dir_list.list || file1->st_ino!=file2->st_ino))
+ if(is_root_cluster_candidat(&dir_list))
{
int test_date=1;
if(verbose>0)