Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 194346
Collapse All | Expand All

(-)testdisk-6.8.org/src/dir.h (-1 / +1 lines)
Lines 51-57 Link Here
51
};
51
};
52
52
53
struct file_info {
53
struct file_info {
54
  struct list_head list;
54
  struct td_list_head list;
55
  char name[4096];
55
  char name[4096];
56
  struct stat stat;
56
  struct stat stat;
57
};
57
};
(-)testdisk-6.8.org/src/filegen.h (-1 / +1 lines)
Lines 88-94 Link Here
88
88
89
struct alloc_data_struct
89
struct alloc_data_struct
90
{
90
{
91
  struct list_head list;
91
  struct td_list_head list;
92
  uint64_t start;
92
  uint64_t start;
93
  uint64_t end;
93
  uint64_t end;
94
  file_stat_t *file_stat;
94
  file_stat_t *file_stat;
(-)testdisk-6.8.org/src/intrface.c (-9 / +9 lines)
Lines 1080-1094 Link Here
1080
1080
1081
static list_part_t *interface_load(disk_t *disk_car,list_part_t *list_part, const int debug)
1081
static list_part_t *interface_load(disk_t *disk_car,list_part_t *list_part, const int debug)
1082
{
1082
{
1083
  struct list_head *backup_walker=NULL;
1083
  struct td_list_head *backup_walker=NULL;
1084
  backup_disk_t *backup_list=partition_load(disk_car,debug);
1084
  backup_disk_t *backup_list=partition_load(disk_car,debug);
1085
  {
1085
  {
1086
    log_info("interface_load\n");
1086
    log_info("interface_load\n");
1087
    list_for_each(backup_walker,&backup_list->list)
1087
    td_list_for_each(backup_walker,&backup_list->list)
1088
    {
1088
    {
1089
      list_part_t *element;
1089
      list_part_t *element;
1090
      backup_disk_t *backup;
1090
      backup_disk_t *backup;
1091
      backup=list_entry(backup_walker, backup_disk_t, list);
1091
      backup=td_list_entry(backup_walker, backup_disk_t, list);
1092
      log_info("%s %s",backup->description,ctime(&backup->my_time));
1092
      log_info("%s %s",backup->description,ctime(&backup->my_time));
1093
      for(element=backup->list_part;element!=NULL;element=element->next)
1093
      for(element=backup->list_part;element!=NULL;element=element->next)
1094
	log_partition(disk_car,element->part);
1094
	log_partition(disk_car,element->part);
Lines 1100-1106 Link Here
1100
    int backup_current_num=0;
1100
    int backup_current_num=0;
1101
    int rewrite=1;
1101
    int rewrite=1;
1102
    unsigned int menu=3;   /* default : quit */
1102
    unsigned int menu=3;   /* default : quit */
1103
    struct list_head *backup_current=backup_list->list.next;
1103
    struct td_list_head *backup_current=backup_list->list.next;
1104
    struct MenuItem menuLoadBackup[]=
1104
    struct MenuItem menuLoadBackup[]=
1105
    {
1105
    {
1106
      { 'P', "Previous",""},
1106
      { 'P', "Previous",""},
Lines 1134-1140 Link Here
1134
	for(i=0,backup_walker=backup_list->list.next;(backup_walker!=&backup_list->list) && (i<offset);backup_walker=backup_walker->next,i++);
1134
	for(i=0,backup_walker=backup_list->list.next;(backup_walker!=&backup_list->list) && (i<offset);backup_walker=backup_walker->next,i++);
1135
	for(i=offset;(backup_walker!=&backup_list->list) &&((i-offset)<INTER_STRUCTURE);i++,backup_walker=backup_walker->next)
1135
	for(i=offset;(backup_walker!=&backup_list->list) &&((i-offset)<INTER_STRUCTURE);i++,backup_walker=backup_walker->next)
1136
	{
1136
	{
1137
	  backup=list_entry(backup_walker, backup_disk_t, list);
1137
	  backup=td_list_entry(backup_walker, backup_disk_t, list);
1138
	  wmove(stdscr,8+i-offset,0);
1138
	  wmove(stdscr,8+i-offset,0);
1139
	  wclrtoeol(stdscr);	/* before addstr for BSD compatibility */
1139
	  wclrtoeol(stdscr);	/* before addstr for BSD compatibility */
1140
	  if(backup_walker==backup_current)
1140
	  if(backup_walker==backup_current)
Lines 1222-1228 Link Here
1222
    {
1222
    {
1223
      list_part_t *partition;
1223
      list_part_t *partition;
1224
      backup_disk_t *backup;
1224
      backup_disk_t *backup;
1225
      backup=list_entry(backup_current, backup_disk_t, list);
1225
      backup=td_list_entry(backup_current, backup_disk_t, list);
1226
      for(partition=backup->list_part;partition!=NULL;partition=partition->next)
1226
      for(partition=backup->list_part;partition!=NULL;partition=partition->next)
1227
      {
1227
      {
1228
	/* Check partition and load partition name */
1228
	/* Check partition and load partition name */
Lines 1232-1242 Link Here
1232
    }
1232
    }
1233
  }
1233
  }
1234
  { /* Cleanup */
1234
  { /* Cleanup */
1235
    struct list_head *backup_walker_next = NULL;
1235
    struct td_list_head *backup_walker_next = NULL;
1236
    list_for_each_safe(backup_walker,backup_walker_next,&backup_list->list)
1236
    td_list_for_each_safe(backup_walker,backup_walker_next,&backup_list->list)
1237
    {
1237
    {
1238
      backup_disk_t *backup;
1238
      backup_disk_t *backup;
1239
      backup=list_entry(backup_walker, backup_disk_t, list);
1239
      backup=td_list_entry(backup_walker, backup_disk_t, list);
1240
      delete_list_part(backup->list_part);
1240
      delete_list_part(backup->list_part);
1241
      free(backup);
1241
      free(backup);
1242
    }
1242
    }
(-)testdisk-6.8.org/src/intrf.c (-13 / +13 lines)
Lines 1548-1558 Link Here
1548
  do
1548
  do
1549
  {
1549
  {
1550
    DIR* dir;
1550
    DIR* dir;
1551
    struct list_head *dir_current;
1551
    struct td_list_head *dir_current;
1552
    int offset=0;
1552
    int offset=0;
1553
    int pos_num=0;
1553
    int pos_num=0;
1554
    static struct file_info dir_list = {
1554
    static struct file_info dir_list = {
1555
      .list = LIST_HEAD_INIT(dir_list.list),
1555
      .list = TD_LIST_HEAD_INIT(dir_list.list),
1556
      .name = {0}
1556
      .name = {0}
1557
    };
1557
    };
1558
    wmove(window,7,0);
1558
    wmove(window,7,0);
Lines 1576-1582 Link Here
1576
	new_drive->name[2]=PATH_SEP;
1576
	new_drive->name[2]=PATH_SEP;
1577
	new_drive->name[3]='\0';
1577
	new_drive->name[3]='\0';
1578
	new_drive->stat.st_mode=LINUX_S_IFDIR|LINUX_S_IRWXUGO;
1578
	new_drive->stat.st_mode=LINUX_S_IFDIR|LINUX_S_IRWXUGO;
1579
	list_add_tail(&new_drive->list,&dir_list.list);
1579
	td_list_add_tail(&new_drive->list,&dir_list.list);
1580
      }
1580
      }
1581
      dir=NULL;
1581
      dir=NULL;
1582
    }
1582
    }
Lines 1633-1639 Link Here
1633
	      }
1633
	      }
1634
#endif
1634
#endif
1635
	      strncpy(dir_info->name,dir_entrie->d_name,sizeof(dir_info->name));
1635
	      strncpy(dir_info->name,dir_entrie->d_name,sizeof(dir_info->name));
1636
	      list_add_tail(&dir_info->list,&dir_list.list);
1636
	      td_list_add_tail(&dir_info->list,&dir_list.list);
1637
	      dir_info=(struct file_info*)MALLOC(sizeof(*dir_info));
1637
	      dir_info=(struct file_info*)MALLOC(sizeof(*dir_info));
1638
	    }
1638
	    }
1639
	  }
1639
	  }
Lines 1665-1678 Link Here
1665
	wdoprintf(window,"To select another directory, use the arrow keys.");
1665
	wdoprintf(window,"To select another directory, use the arrow keys.");
1666
#endif
1666
#endif
1667
	{
1667
	{
1668
	  struct list_head *dir_walker = NULL;
1668
	  struct td_list_head *dir_walker = NULL;
1669
	  int i=0;
1669
	  int i=0;
1670
	  list_for_each(dir_walker,&dir_list.list)
1670
	  td_list_for_each(dir_walker,&dir_list.list)
1671
	  {
1671
	  {
1672
	    if(offset<=i)
1672
	    if(offset<=i)
1673
	    {
1673
	    {
1674
	      struct file_info *dir_info;
1674
	      struct file_info *dir_info;
1675
	      dir_info=list_entry(dir_walker, struct file_info, list);
1675
	      dir_info=td_list_entry(dir_walker, struct file_info, list);
1676
	      wmove(window,8+i-offset,0);
1676
	      wmove(window,8+i-offset,0);
1677
	      wclrtoeol(window);	/* before addstr for BSD compatibility */
1677
	      wclrtoeol(window);	/* before addstr for BSD compatibility */
1678
	      if(dir_walker==dir_current)
1678
	      if(dir_walker==dir_current)
Lines 1792-1798 Link Here
1792
	      if(dir_current!=&dir_list.list)
1792
	      if(dir_current!=&dir_list.list)
1793
	      {
1793
	      {
1794
		struct file_info *dir_info;
1794
		struct file_info *dir_info;
1795
		dir_info=list_entry(dir_current, struct file_info, list);
1795
		dir_info=td_list_entry(dir_current, struct file_info, list);
1796
		if(strcmp(dir_info->name,".")==0)
1796
		if(strcmp(dir_info->name,".")==0)
1797
		{
1797
		{
1798
		}
1798
		}
Lines 1819-1831 Link Here
1819
	} while(quit==0);
1819
	} while(quit==0);
1820
      } while(quit==1);
1820
      } while(quit==1);
1821
      {
1821
      {
1822
	struct list_head *dir_walker = NULL;
1822
	struct td_list_head *dir_walker = NULL;
1823
	struct list_head *dir_walker_next = NULL;
1823
	struct td_list_head *dir_walker_next = NULL;
1824
	list_for_each_safe(dir_walker,dir_walker_next,&dir_list.list)
1824
	td_list_for_each_safe(dir_walker,dir_walker_next,&dir_list.list)
1825
	{
1825
	{
1826
	  struct file_info *dir_info;
1826
	  struct file_info *dir_info;
1827
	  dir_info=list_entry(dir_walker, struct file_info, list);
1827
	  dir_info=td_list_entry(dir_walker, struct file_info, list);
1828
	  list_del(dir_walker);
1828
	  td_list_del(dir_walker);
1829
	  free(dir_info);
1829
	  free(dir_info);
1830
	}
1830
	}
1831
      }
1831
      }
(-)testdisk-6.8.org/src/list.c (-3 / +3 lines)
Lines 87-100 Link Here
87
      if(file_size>=size)
87
      if(file_size>=size)
88
      {
88
      {
89
	element->end-=(file_size-size);
89
	element->end-=(file_size-size);
90
	list_delete(element->next);
90
	td_list_delete(element->next);
91
//	element->next=NULL;	already done by list_delete
91
//	element->next=NULL;	already done by td_list_delete
92
      }
92
      }
93
    }
93
    }
94
  }
94
  }
95
}
95
}
96
96
97
void list_delete(alloc_list_t *list)
97
void td_list_delete(alloc_list_t *list)
98
{
98
{
99
  alloc_list_t *next;
99
  alloc_list_t *next;
100
  if(list!=NULL && list->prev!=NULL)
100
  if(list!=NULL && list->prev!=NULL)
(-)testdisk-6.8.org/src/list.h (-91 / +91 lines)
Lines 34-40 Link Here
34
34
35
void list_append_block(alloc_list_t *list, const uint64_t offset, const uint64_t blocksize, const int data);
35
void list_append_block(alloc_list_t *list, const uint64_t offset, const uint64_t blocksize, const int data);
36
void list_truncate(alloc_list_t *list, uint64_t size);
36
void list_truncate(alloc_list_t *list, uint64_t size);
37
void list_delete(alloc_list_t *list);
37
void td_list_delete(alloc_list_t *list);
38
38
39
39
40
/*
40
/*
Lines 56-71 Link Here
56
 * using the generic single-entry routines.
56
 * using the generic single-entry routines.
57
 */
57
 */
58
58
59
struct list_head {
59
struct td_list_head {
60
	struct list_head *next, *prev;
60
	struct td_list_head *next, *prev;
61
};
61
};
62
62
63
#define LIST_HEAD_INIT(name) { &(name), &(name) }
63
#define TD_LIST_HEAD_INIT(name) { &(name), &(name) }
64
64
65
#define LIST_HEAD(name) \
65
#define TD_LIST_HEAD(name) \
66
	struct list_head name = LIST_HEAD_INIT(name)
66
	struct td_list_head name = TD_LIST_HEAD_INIT(name)
67
67
68
#define INIT_LIST_HEAD(ptr) do { \
68
#define INIT_TD_LIST_HEAD(ptr) do { \
69
	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
69
	(ptr)->next = (ptr); (ptr)->prev = (ptr); \
70
} while (0)
70
} while (0)
71
71
Lines 75-83 Link Here
75
 * This is only for internal list manipulation where we know
75
 * This is only for internal list manipulation where we know
76
 * the prev/next entries already!
76
 * the prev/next entries already!
77
 */
77
 */
78
static inline void __list_add(struct list_head *new,
78
static inline void __td_list_add(struct td_list_head *new,
79
			      struct list_head *prev,
79
			      struct td_list_head *prev,
80
			      struct list_head *next)
80
			      struct td_list_head *next)
81
{
81
{
82
	next->prev = new;
82
	next->prev = new;
83
	new->next = next;
83
	new->next = next;
Lines 86-114 Link Here
86
}
86
}
87
87
88
/**
88
/**
89
 * list_add - add a new entry
89
 * td_list_add - add a new entry
90
 * @new: new entry to be added
90
 * @new: new entry to be added
91
 * @head: list head to add it after
91
 * @head: list head to add it after
92
 *
92
 *
93
 * Insert a new entry after the specified head.
93
 * Insert a new entry after the specified head.
94
 * This is good for implementing stacks.
94
 * This is good for implementing stacks.
95
 */
95
 */
96
static inline void list_add(struct list_head *new, struct list_head *head)
96
static inline void td_list_add(struct td_list_head *new, struct td_list_head *head)
97
{
97
{
98
	__list_add(new, head, head->next);
98
	__td_list_add(new, head, head->next);
99
}
99
}
100
100
101
/**
101
/**
102
 * list_add_tail - add a new entry
102
 * td_list_add_tail - add a new entry
103
 * @new: new entry to be added
103
 * @new: new entry to be added
104
 * @head: list head to add it before
104
 * @head: list head to add it before
105
 *
105
 *
106
 * Insert a new entry before the specified head.
106
 * Insert a new entry before the specified head.
107
 * This is useful for implementing queues.
107
 * This is useful for implementing queues.
108
 */
108
 */
109
static inline void list_add_tail(struct list_head *new, struct list_head *head)
109
static inline void td_list_add_tail(struct td_list_head *new, struct td_list_head *head)
110
{
110
{
111
	__list_add(new, head->prev, head);
111
	__td_list_add(new, head->prev, head);
112
}
112
}
113
113
114
/*
114
/*
Lines 118-208 Link Here
118
 * This is only for internal list manipulation where we know
118
 * This is only for internal list manipulation where we know
119
 * the prev/next entries already!
119
 * the prev/next entries already!
120
 */
120
 */
121
static inline void __list_del(struct list_head * prev, struct list_head * next)
121
static inline void __td_list_del(struct td_list_head * prev, struct td_list_head * next)
122
{
122
{
123
	next->prev = prev;
123
	next->prev = prev;
124
	prev->next = next;
124
	prev->next = next;
125
}
125
}
126
126
127
/**
127
/**
128
 * list_del - deletes entry from list.
128
 * td_list_del - deletes entry from list.
129
 * @entry: the element to delete from the list.
129
 * @entry: the element to delete from the list.
130
 * Note: list_empty on entry does not return true after this, the entry is
130
 * Note: td_list_empty on entry does not return true after this, the entry is
131
 * in an undefined state.
131
 * in an undefined state.
132
 */
132
 */
133
static inline void list_del(struct list_head *entry)
133
static inline void td_list_del(struct td_list_head *entry)
134
{
134
{
135
	__list_del(entry->prev, entry->next);
135
	__td_list_del(entry->prev, entry->next);
136
	entry->next = LIST_POISON1;
136
	entry->next = LIST_POISON1;
137
	entry->prev = LIST_POISON2;
137
	entry->prev = LIST_POISON2;
138
}
138
}
139
139
140
/**
140
/**
141
 * list_del_init - deletes entry from list and reinitialize it.
141
 * td_list_del_init - deletes entry from list and reinitialize it.
142
 * @entry: the element to delete from the list.
142
 * @entry: the element to delete from the list.
143
 */
143
 */
144
static inline void list_del_init(struct list_head *entry)
144
static inline void td_list_del_init(struct td_list_head *entry)
145
{
145
{
146
	__list_del(entry->prev, entry->next);
146
	__td_list_del(entry->prev, entry->next);
147
	INIT_LIST_HEAD(entry);
147
	INIT_TD_LIST_HEAD(entry);
148
}
148
}
149
149
150
/**
150
/**
151
 * list_move - delete from one list and add as another's head
151
 * td_list_move - delete from one list and add as another's head
152
 * @list: the entry to move
152
 * @list: the entry to move
153
 * @head: the head that will precede our entry
153
 * @head: the head that will precede our entry
154
 */
154
 */
155
static inline void list_move(struct list_head *list, struct list_head *head)
155
static inline void td_list_move(struct td_list_head *list, struct td_list_head *head)
156
{
156
{
157
        __list_del(list->prev, list->next);
157
        __td_list_del(list->prev, list->next);
158
        list_add(list, head);
158
        td_list_add(list, head);
159
}
159
}
160
160
161
/**
161
/**
162
 * list_move_tail - delete from one list and add as another's tail
162
 * td_list_move_tail - delete from one list and add as another's tail
163
 * @list: the entry to move
163
 * @list: the entry to move
164
 * @head: the head that will follow our entry
164
 * @head: the head that will follow our entry
165
 */
165
 */
166
static inline void list_move_tail(struct list_head *list,
166
static inline void td_list_move_tail(struct td_list_head *list,
167
				  struct list_head *head)
167
				  struct td_list_head *head)
168
{
168
{
169
        __list_del(list->prev, list->next);
169
        __td_list_del(list->prev, list->next);
170
        list_add_tail(list, head);
170
        td_list_add_tail(list, head);
171
}
171
}
172
172
173
/**
173
/**
174
 * list_empty - tests whether a list is empty
174
 * td_list_empty - tests whether a list is empty
175
 * @head: the list to test.
175
 * @head: the list to test.
176
 */
176
 */
177
static inline int list_empty(const struct list_head *head)
177
static inline int td_list_empty(const struct td_list_head *head)
178
{
178
{
179
	return head->next == head;
179
	return head->next == head;
180
}
180
}
181
181
182
/**
182
/**
183
 * list_empty_careful - tests whether a list is
183
 * td_list_empty_careful - tests whether a list is
184
 * empty _and_ checks that no other CPU might be
184
 * empty _and_ checks that no other CPU might be
185
 * in the process of still modifying either member
185
 * in the process of still modifying either member
186
 *
186
 *
187
 * NOTE: using list_empty_careful() without synchronization
187
 * NOTE: using td_list_empty_careful() without synchronization
188
 * can only be safe if the only activity that can happen
188
 * can only be safe if the only activity that can happen
189
 * to the list entry is list_del_init(). Eg. it cannot be used
189
 * to the list entry is td_list_del_init(). Eg. it cannot be used
190
 * if another CPU could re-list_add() it.
190
 * if another CPU could re-td_list_add() it.
191
 *
191
 *
192
 * @head: the list to test.
192
 * @head: the list to test.
193
 */
193
 */
194
static inline int list_empty_careful(const struct list_head *head)
194
static inline int td_list_empty_careful(const struct td_list_head *head)
195
{
195
{
196
	struct list_head *next = head->next;
196
	struct td_list_head *next = head->next;
197
	return (next == head) && (next == head->prev);
197
	return (next == head) && (next == head->prev);
198
}
198
}
199
199
200
static inline void __list_splice(struct list_head *list,
200
static inline void __td_list_splice(struct td_list_head *list,
201
				 struct list_head *head)
201
				 struct td_list_head *head)
202
{
202
{
203
	struct list_head *first = list->next;
203
	struct td_list_head *first = list->next;
204
	struct list_head *last = list->prev;
204
	struct td_list_head *last = list->prev;
205
	struct list_head *at = head->next;
205
	struct td_list_head *at = head->next;
206
206
207
	first->prev = head;
207
	first->prev = head;
208
	head->next = first;
208
	head->next = first;
Lines 212-336 Link Here
212
}
212
}
213
213
214
/**
214
/**
215
 * list_splice - join two lists
215
 * td_list_splice - join two lists
216
 * @list: the new list to add.
216
 * @list: the new list to add.
217
 * @head: the place to add it in the first list.
217
 * @head: the place to add it in the first list.
218
 */
218
 */
219
static inline void list_splice(struct list_head *list, struct list_head *head)
219
static inline void td_list_splice(struct td_list_head *list, struct td_list_head *head)
220
{
220
{
221
	if (!list_empty(list))
221
	if (!td_list_empty(list))
222
		__list_splice(list, head);
222
		__td_list_splice(list, head);
223
}
223
}
224
224
225
/**
225
/**
226
 * list_splice_init - join two lists and reinitialise the emptied list.
226
 * td_list_splice_init - join two lists and reinitialise the emptied list.
227
 * @list: the new list to add.
227
 * @list: the new list to add.
228
 * @head: the place to add it in the first list.
228
 * @head: the place to add it in the first list.
229
 *
229
 *
230
 * The list at @list is reinitialised
230
 * The list at @list is reinitialised
231
 */
231
 */
232
static inline void list_splice_init(struct list_head *list,
232
static inline void td_list_splice_init(struct td_list_head *list,
233
				    struct list_head *head)
233
				    struct td_list_head *head)
234
{
234
{
235
	if (!list_empty(list)) {
235
	if (!td_list_empty(list)) {
236
		__list_splice(list, head);
236
		__td_list_splice(list, head);
237
		INIT_LIST_HEAD(list);
237
		INIT_TD_LIST_HEAD(list);
238
	}
238
	}
239
}
239
}
240
240
241
/**
241
/**
242
 * list_entry - get the struct for this entry
242
 * td_list_entry - get the struct for this entry
243
 * @ptr:	the &struct list_head pointer.
243
 * @ptr:	the &struct td_list_head pointer.
244
 * @type:	the type of the struct this is embedded in.
244
 * @type:	the type of the struct this is embedded in.
245
 * @member:	the name of the list_struct within the struct.
245
 * @member:	the name of the list_struct within the struct.
246
 */
246
 */
247
#define list_entry(ptr, type, member) \
247
#define td_list_entry(ptr, type, member) \
248
	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
248
	((type *)((char *)(ptr)-(unsigned long)(&((type *)0)->member)))
249
249
250
/**
250
/**
251
 * __list_for_each	-	iterate over a list
251
 * __td_list_for_each	-	iterate over a list
252
 * @pos:	the &struct list_head to use as a loop counter.
252
 * @pos:	the &struct td_list_head to use as a loop counter.
253
 * @head:	the head for your list.
253
 * @head:	the head for your list.
254
 *
254
 *
255
 */
255
 */
256
#define list_for_each(pos, head) \
256
#define td_list_for_each(pos, head) \
257
	for (pos = (head)->next; pos != (head); pos = pos->next)
257
	for (pos = (head)->next; pos != (head); pos = pos->next)
258
258
259
/**
259
/**
260
 * list_for_each_prev	-	iterate over a list backwards
260
 * td_list_for_each_prev	-	iterate over a list backwards
261
 * @pos:	the &struct list_head to use as a loop counter.
261
 * @pos:	the &struct td_list_head to use as a loop counter.
262
 * @head:	the head for your list.
262
 * @head:	the head for your list.
263
 */
263
 */
264
#define list_for_each_prev(pos, head) \
264
#define td_list_for_each_prev(pos, head) \
265
	for (pos = (head)->prev; pos != (head); \
265
	for (pos = (head)->prev; pos != (head); \
266
        	pos = pos->prev)
266
        	pos = pos->prev)
267
267
268
/**
268
/**
269
 * list_for_each_safe	-	iterate over a list safe against removal of list entry
269
 * td_list_for_each_safe	-	iterate over a list safe against removal of list entry
270
 * @pos:	the &struct list_head to use as a loop counter.
270
 * @pos:	the &struct td_list_head to use as a loop counter.
271
 * @n:		another &struct list_head to use as temporary storage
271
 * @n:		another &struct td_list_head to use as temporary storage
272
 * @head:	the head for your list.
272
 * @head:	the head for your list.
273
 */
273
 */
274
#define list_for_each_safe(pos, n, head) \
274
#define td_list_for_each_safe(pos, n, head) \
275
	for (pos = (head)->next, n = pos->next; pos != (head); \
275
	for (pos = (head)->next, n = pos->next; pos != (head); \
276
		pos = n, n = pos->next)
276
		pos = n, n = pos->next)
277
277
278
/**
278
/**
279
 * list_for_each_entry	-	iterate over list of given type
279
 * td_list_for_each_entry	-	iterate over list of given type
280
 * @pos:	the type * to use as a loop counter.
280
 * @pos:	the type * to use as a loop counter.
281
 * @head:	the head for your list.
281
 * @head:	the head for your list.
282
 * @member:	the name of the list_struct within the struct.
282
 * @member:	the name of the list_struct within the struct.
283
 */
283
 */
284
#define list_for_each_entry(pos, head, member)				\
284
#define td_list_for_each_entry(pos, head, member)				\
285
	for (pos = list_entry((head)->next, typeof(*pos), member);	\
285
	for (pos = td_list_entry((head)->next, typeof(*pos), member);	\
286
	     &pos->member != (head); 	\
286
	     &pos->member != (head); 	\
287
	     pos = list_entry(pos->member.next, typeof(*pos), member))
287
	     pos = td_list_entry(pos->member.next, typeof(*pos), member))
288
288
289
/**
289
/**
290
 * list_for_each_entry_reverse - iterate backwards over list of given type.
290
 * td_list_for_each_entry_reverse - iterate backwards over list of given type.
291
 * @pos:	the type * to use as a loop counter.
291
 * @pos:	the type * to use as a loop counter.
292
 * @head:	the head for your list.
292
 * @head:	the head for your list.
293
 * @member:	the name of the list_struct within the struct.
293
 * @member:	the name of the list_struct within the struct.
294
 */
294
 */
295
#define list_for_each_entry_reverse(pos, head, member)			\
295
#define td_list_for_each_entry_reverse(pos, head, member)			\
296
	for (pos = list_entry((head)->prev, typeof(*pos), member);	\
296
	for (pos = td_list_entry((head)->prev, typeof(*pos), member);	\
297
	     &pos->member != (head); 	\
297
	     &pos->member != (head); 	\
298
	     pos = list_entry(pos->member.prev, typeof(*pos), member))
298
	     pos = td_list_entry(pos->member.prev, typeof(*pos), member))
299
299
300
/**
300
/**
301
 * list_prepare_entry - prepare a pos entry for use as a start point in
301
 * td_list_prepare_entry - prepare a pos entry for use as a start point in
302
 *			list_for_each_entry_continue
302
 *			td_list_for_each_entry_continue
303
 * @pos:	the type * to use as a start point
303
 * @pos:	the type * to use as a start point
304
 * @head:	the head of the list
304
 * @head:	the head of the list
305
 * @member:	the name of the list_struct within the struct.
305
 * @member:	the name of the list_struct within the struct.
306
 */
306
 */
307
#define list_prepare_entry(pos, head, member) \
307
#define td_list_prepare_entry(pos, head, member) \
308
	((pos) ? : list_entry(head, typeof(*pos), member))
308
	((pos) ? : td_list_entry(head, typeof(*pos), member))
309
309
310
/**
310
/**
311
 * list_for_each_entry_continue -	iterate over list of given type
311
 * td_list_for_each_entry_continue -	iterate over list of given type
312
 *			continuing after existing point
312
 *			continuing after existing point
313
 * @pos:	the type * to use as a loop counter.
313
 * @pos:	the type * to use as a loop counter.
314
 * @head:	the head for your list.
314
 * @head:	the head for your list.
315
 * @member:	the name of the list_struct within the struct.
315
 * @member:	the name of the list_struct within the struct.
316
 */
316
 */
317
#define list_for_each_entry_continue(pos, head, member) 		\
317
#define td_list_for_each_entry_continue(pos, head, member) 		\
318
	for (pos = list_entry(pos->member.next, typeof(*pos), member);	\
318
	for (pos = td_list_entry(pos->member.next, typeof(*pos), member);	\
319
	     &pos->member != (head);	\
319
	     &pos->member != (head);	\
320
	     pos = list_entry(pos->member.next, typeof(*pos), member))
320
	     pos = td_list_entry(pos->member.next, typeof(*pos), member))
321
321
322
/**
322
/**
323
 * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
323
 * td_list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
324
 * @pos:	the type * to use as a loop counter.
324
 * @pos:	the type * to use as a loop counter.
325
 * @n:		another type * to use as temporary storage
325
 * @n:		another type * to use as temporary storage
326
 * @head:	the head for your list.
326
 * @head:	the head for your list.
327
 * @member:	the name of the list_struct within the struct.
327
 * @member:	the name of the list_struct within the struct.
328
 */
328
 */
329
#define list_for_each_entry_safe(pos, n, head, member)			\
329
#define td_list_for_each_entry_safe(pos, n, head, member)			\
330
	for (pos = list_entry((head)->next, typeof(*pos), member),	\
330
	for (pos = td_list_entry((head)->next, typeof(*pos), member),	\
331
		n = list_entry(pos->member.next, typeof(*pos), member);	\
331
		n = td_list_entry(pos->member.next, typeof(*pos), member);	\
332
	     &pos->member != (head); 					\
332
	     &pos->member != (head); 					\
333
	     pos = n, n = list_entry(n->member.next, typeof(*n), member))
333
	     pos = n, n = td_list_entry(n->member.next, typeof(*n), member))
334
334
335
335
336
#endif
336
#endif
(-)testdisk-6.8.org/src/ntfs.c (-7 / +7 lines)
Lines 233-239 Link Here
233
    {
233
    {
234
      unsigned int attr_value_length=NTFS_GETU16(attr_record+0x10);
234
      unsigned int attr_value_length=NTFS_GETU16(attr_record+0x10);
235
      unsigned int attr_value_offset=NTFS_GETU16(attr_record+0x14);
235
      unsigned int attr_value_offset=NTFS_GETU16(attr_record+0x14);
236
      const char *attr_list_entry=attr_record+attr_value_offset;
236
      const char *attr_td_list_entry=attr_record+attr_value_offset;
237
      if(attr_value_offset%8!=0)
237
      if(attr_value_offset%8!=0)
238
      {
238
      {
239
#ifdef NTFS_DEBUG
239
#ifdef NTFS_DEBUG
Lines 241-255 Link Here
241
#endif
241
#endif
242
	return 2;
242
	return 2;
243
      }
243
      }
244
      if(attr_list_entry+26>=end)
244
      if(attr_td_list_entry+26>=end)
245
      {
245
      {
246
#ifdef NTFS_DEBUG
246
#ifdef NTFS_DEBUG
247
	log_debug("ntfs_get_attr attr_list_entry+26=%p, end=%p\n",attr_list_entry+26,end);
247
	log_debug("ntfs_get_attr attr_td_list_entry+26=%p, end=%p\n",attr_td_list_entry+26,end);
248
#endif
248
#endif
249
	return 2;
249
	return 2;
250
      }
250
      }
251
      /* We found the attribute type. Is the name correct, too? */
251
      /* We found the attribute type. Is the name correct, too? */
252
      if((attr_value_offset+attr_value_length>attr_len) || (attr_list_entry+attr_len >= end))
252
      if((attr_value_offset+attr_value_length>attr_len) || (attr_td_list_entry+attr_len >= end))
253
      {
253
      {
254
#ifdef NTFS_DEBUG
254
#ifdef NTFS_DEBUG
255
	// log_debug("ntfs_get_attr \n");
255
	// log_debug("ntfs_get_attr \n");
Lines 262-268 Link Here
262
	{
262
	{
263
	  case 0x30:	/* AT_FILE_NAME */
263
	  case 0x30:	/* AT_FILE_NAME */
264
	    {
264
	    {
265
	      const char *file_name_attr=attr_list_entry;
265
	      const char *file_name_attr=attr_td_list_entry;
266
	      unsigned int file_name_length;
266
	      unsigned int file_name_length;
267
	      const char *name_it;
267
	      const char *name_it;
268
	      if(file_name_attr+0x42>=end)
268
	      if(file_name_attr+0x42>=end)
Lines 303-315 Link Here
303
	      volume_name_length/=2;	/* Unicode */
303
	      volume_name_length/=2;	/* Unicode */
304
	      if(volume_name_length>sizeof(partition->name)-1)
304
	      if(volume_name_length>sizeof(partition->name)-1)
305
		volume_name_length=sizeof(partition->name)-1;
305
		volume_name_length=sizeof(partition->name)-1;
306
	      for(name_it=attr_list_entry;(volume_name_length>0) && (*name_it!='\0') && (name_it[1]=='\0'); name_it+=2,volume_name_length--)
306
	      for(name_it=attr_td_list_entry;(volume_name_length>0) && (*name_it!='\0') && (name_it[1]=='\0'); name_it+=2,volume_name_length--)
307
		*dest++=*name_it;
307
		*dest++=*name_it;
308
	      *dest++='\0'; /* 27 january 2003: Correct a bug found by Andreas du Plessis-Denz */
308
	      *dest++='\0'; /* 27 january 2003: Correct a bug found by Andreas du Plessis-Denz */
309
	    }
309
	    }
310
	    return 1;
310
	    return 1;
311
	  case 0x90:	/* AT_INDEX_ROOT */
311
	  case 0x90:	/* AT_INDEX_ROOT */
312
	    return NTFS_GETU32(attr_list_entry+8);	/* index_block_size */
312
	    return NTFS_GETU32(attr_td_list_entry+8);	/* index_block_size */
313
	}
313
	}
314
      }
314
      }
315
    }
315
    }
(-)testdisk-6.8.org/src/ntfs_dir.c (-5 / +5 lines)
Lines 93-99 Link Here
93
extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
93
extern u64 ntfs_inode_lookup_by_name(ntfs_inode *dir_ni,
94
                const ntfschar *uname, const int uname_len);
94
                const ntfschar *uname, const int uname_len);
95
static time_t ntfs2utc (s64 ntfstime);
95
static time_t ntfs2utc (s64 ntfstime);
96
static int ntfs_list_entry(  struct ntfs_dir_struct *ls, const ntfschar *name, 
96
static int ntfs_td_list_entry(  struct ntfs_dir_struct *ls, const ntfschar *name, 
97
		const int name_len, const int name_type, const s64 pos,
97
		const int name_len, const int name_type, const s64 pos,
98
		const MFT_REF mref, const unsigned dt_type);
98
		const MFT_REF mref, const unsigned dt_type);
99
static file_data_t *ntfs_dir(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const unsigned long int cluster);
99
static file_data_t *ntfs_dir(disk_t *disk_car, const partition_t *partition, dir_data_t *dir_data, const unsigned long int cluster);
Lines 138-147 Link Here
138
}
138
}
139
139
140
/**
140
/**
141
 * ntfs_list_entry
141
 * ntfs_td_list_entry
142
 * FIXME: Should we print errors as we go along? (AIA)
142
 * FIXME: Should we print errors as we go along? (AIA)
143
 */
143
 */
144
static int ntfs_list_entry(  struct ntfs_dir_struct *ls, const ntfschar *name, 
144
static int ntfs_td_list_entry(  struct ntfs_dir_struct *ls, const ntfschar *name, 
145
		const int name_len, const int name_type, const s64 pos,
145
		const int name_len, const int name_type, const s64 pos,
146
		const MFT_REF mref, const unsigned dt_type)
146
		const MFT_REF mref, const unsigned dt_type)
147
{
147
{
Lines 150-156 Link Here
150
  filename = calloc (1, MAX_PATH);
150
  filename = calloc (1, MAX_PATH);
151
  if (!filename)
151
  if (!filename)
152
  {
152
  {
153
    log_critical("ntfs_list_entry calloc failed\n");
153
    log_critical("ntfs_td_list_entry calloc failed\n");
154
    return -1;
154
    return -1;
155
  }
155
  }
156
156
Lines 292-298 Link Here
292
   */
292
   */
293
  pos = 0;
293
  pos = 0;
294
  if (inode->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
294
  if (inode->mrec->flags & MFT_RECORD_IS_DIRECTORY) {
295
    if(ntfs_readdir(inode, &pos, ls, (ntfs_filldir_t)ntfs_list_entry)<0)
295
    if(ntfs_readdir(inode, &pos, ls, (ntfs_filldir_t)ntfs_td_list_entry)<0)
296
    {
296
    {
297
      log_error("ntfs_readdir failed\n");
297
      log_error("ntfs_readdir failed\n");
298
    }
298
    }
(-)testdisk-6.8.org/src/photorec.c (-54 / +54 lines)
Lines 223-236 Link Here
223
223
224
static void list_free_add(const file_recovery_t *file_recovery, alloc_data_t *list_search_space)
224
static void list_free_add(const file_recovery_t *file_recovery, alloc_data_t *list_search_space)
225
{
225
{
226
  struct list_head *search_walker = NULL;
226
  struct td_list_head *search_walker = NULL;
227
#ifdef DEBUG_FREE
227
#ifdef DEBUG_FREE
228
  log_trace("list_free_add %lu\n",(long unsigned)(file_recovery->location.start/512));
228
  log_trace("list_free_add %lu\n",(long unsigned)(file_recovery->location.start/512));
229
#endif
229
#endif
230
  list_for_each(search_walker, &list_search_space->list)
230
  td_list_for_each(search_walker, &list_search_space->list)
231
  {
231
  {
232
    alloc_data_t *current_search_space;
232
    alloc_data_t *current_search_space;
233
    current_search_space=list_entry(search_walker, alloc_data_t, list);
233
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
234
    if(current_search_space->start < file_recovery->location.start && file_recovery->location.start < current_search_space->end)
234
    if(current_search_space->start < file_recovery->location.start && file_recovery->location.start < current_search_space->end)
235
    {
235
    {
236
      alloc_data_t *new_free_space;
236
      alloc_data_t *new_free_space;
Lines 239-245 Link Here
239
      new_free_space->end=current_search_space->end;
239
      new_free_space->end=current_search_space->end;
240
      new_free_space->file_stat=NULL;
240
      new_free_space->file_stat=NULL;
241
      current_search_space->end=file_recovery->location.start-1;
241
      current_search_space->end=file_recovery->location.start-1;
242
      list_add(&new_free_space->list, search_walker);
242
      td_list_add(&new_free_space->list, search_walker);
243
    }
243
    }
244
    if(current_search_space->start==file_recovery->location.start)
244
    if(current_search_space->start==file_recovery->location.start)
245
    {
245
    {
Lines 252-273 Link Here
252
static alloc_data_t *update_search_space(const file_recovery_t *file_recovery, alloc_data_t *list_search_space, alloc_data_t **new_current_search_space, uint64_t *offset, const unsigned int blocksize)
252
static alloc_data_t *update_search_space(const file_recovery_t *file_recovery, alloc_data_t *list_search_space, alloc_data_t **new_current_search_space, uint64_t *offset, const unsigned int blocksize)
253
{
253
{
254
  const alloc_list_t *element;
254
  const alloc_list_t *element;
255
  struct list_head *search_walker = NULL;
255
  struct td_list_head *search_walker = NULL;
256
#ifdef DEBUG_UPDATE_SEARCH_SPACE
256
#ifdef DEBUG_UPDATE_SEARCH_SPACE
257
  log_trace("update_search_space\n");
257
  log_trace("update_search_space\n");
258
  list_for_each(search_walker, &list_search_space->list)
258
  td_list_for_each(search_walker, &list_search_space->list)
259
  {
259
  {
260
    alloc_data_t *cur_free_space;
260
    alloc_data_t *cur_free_space;
261
    cur_free_space=list_entry(search_walker, alloc_data_t, list);
261
    cur_free_space=td_list_entry(search_walker, alloc_data_t, list);
262
    log_trace(" %llu-%llu",(long long unsigned)(cur_free_space->start/512),
262
    log_trace(" %llu-%llu",(long long unsigned)(cur_free_space->start/512),
263
	(long long unsigned)(cur_free_space->end/512));
263
	(long long unsigned)(cur_free_space->end/512));
264
  }
264
  }
265
  log_trace("\n");
265
  log_trace("\n");
266
#endif
266
#endif
267
  list_for_each(search_walker, &list_search_space->list)
267
  td_list_for_each(search_walker, &list_search_space->list)
268
  {
268
  {
269
    alloc_data_t *current_search_space;
269
    alloc_data_t *current_search_space;
270
    current_search_space=list_entry(search_walker, alloc_data_t, list);
270
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
271
    if(current_search_space->start <= file_recovery->location.start &&
271
    if(current_search_space->start <= file_recovery->location.start &&
272
	file_recovery->location.start <= current_search_space->end)
272
	file_recovery->location.start <= current_search_space->end)
273
    {
273
    {
Lines 291-297 Link Here
291
291
292
static alloc_data_t *update_search_space_aux(alloc_data_t *list_search_space, uint64_t start, uint64_t end, alloc_data_t **new_current_search_space, uint64_t *offset)
292
static alloc_data_t *update_search_space_aux(alloc_data_t *list_search_space, uint64_t start, uint64_t end, alloc_data_t **new_current_search_space, uint64_t *offset)
293
{
293
{
294
  struct list_head *search_walker = NULL;
294
  struct td_list_head *search_walker = NULL;
295
#ifdef DEBUG_UPDATE_SEARCH_SPACE
295
#ifdef DEBUG_UPDATE_SEARCH_SPACE
296
    log_trace("update_search_space_aux offset=%llu remove [%llu-%llu]\n",
296
    log_trace("update_search_space_aux offset=%llu remove [%llu-%llu]\n",
297
	(long long unsigned)((*offset)/512),
297
	(long long unsigned)((*offset)/512),
Lines 300-309 Link Here
300
#endif
300
#endif
301
  if(start >= end)
301
  if(start >= end)
302
    return list_search_space;
302
    return list_search_space;
303
  list_for_each(search_walker, &list_search_space->list)
303
  td_list_for_each(search_walker, &list_search_space->list)
304
  {
304
  {
305
    alloc_data_t *current_search_space;
305
    alloc_data_t *current_search_space;
306
    current_search_space=list_entry(search_walker, alloc_data_t, list);
306
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
307
#ifdef DEBUG_UPDATE_SEARCH_SPACE
307
#ifdef DEBUG_UPDATE_SEARCH_SPACE
308
    log_trace("update_search_space_aux offset=%llu remove [%llu-%llu] in [%llu-%llu]\n",
308
    log_trace("update_search_space_aux offset=%llu remove [%llu-%llu] in [%llu-%llu]\n",
309
	(long long unsigned)((*offset)/512),
309
	(long long unsigned)((*offset)/512),
Lines 328-341 Link Here
328
      /* current_search_space->start==start current_search_space->end<=end */
328
      /* current_search_space->start==start current_search_space->end<=end */
329
      start=current_search_space->end+1;
329
      start=current_search_space->end+1;
330
      if(list_search_space==current_search_space)
330
      if(list_search_space==current_search_space)
331
	list_search_space=list_entry(current_search_space->list.next, alloc_data_t, list);
331
	list_search_space=td_list_entry(current_search_space->list.next, alloc_data_t, list);
332
      if(offset!=NULL && new_current_search_space!=NULL &&
332
      if(offset!=NULL && new_current_search_space!=NULL &&
333
	  current_search_space->start<=*offset && *offset<=current_search_space->end)
333
	  current_search_space->start<=*offset && *offset<=current_search_space->end)
334
      {
334
      {
335
	*new_current_search_space=list_entry(current_search_space->list.next, alloc_data_t, list);
335
	*new_current_search_space=td_list_entry(current_search_space->list.next, alloc_data_t, list);
336
	*offset=(*new_current_search_space)->start;
336
	*offset=(*new_current_search_space)->start;
337
      }
337
      }
338
      list_del(search_walker);
338
      td_list_del(search_walker);
339
      free(current_search_space);
339
      free(current_search_space);
340
      return update_search_space_aux(list_search_space, start,end, new_current_search_space, offset);
340
      return update_search_space_aux(list_search_space, start,end, new_current_search_space, offset);
341
    }
341
    }
Lines 349-355 Link Here
349
	if(offset!=NULL && new_current_search_space!=NULL &&
349
	if(offset!=NULL && new_current_search_space!=NULL &&
350
	  start<=*offset && *offset<=current_search_space->end)
350
	  start<=*offset && *offset<=current_search_space->end)
351
	{
351
	{
352
	  *new_current_search_space=list_entry(current_search_space->list.next, alloc_data_t, list);
352
	  *new_current_search_space=td_list_entry(current_search_space->list.next, alloc_data_t, list);
353
	  *offset=(*new_current_search_space)->start;
353
	  *offset=(*new_current_search_space)->start;
354
	}
354
	}
355
	current_search_space->end=start-1;
355
	current_search_space->end=start-1;
Lines 358-371 Link Here
358
      /* start<=current_search_space->start current_search_space->end==end */
358
      /* start<=current_search_space->start current_search_space->end==end */
359
      end=current_search_space->start-1;
359
      end=current_search_space->start-1;
360
      if(list_search_space==current_search_space)
360
      if(list_search_space==current_search_space)
361
	list_search_space=list_entry(current_search_space->list.next, alloc_data_t, list);
361
	list_search_space=td_list_entry(current_search_space->list.next, alloc_data_t, list);
362
      if(offset!=NULL && new_current_search_space!=NULL &&
362
      if(offset!=NULL && new_current_search_space!=NULL &&
363
	  current_search_space->start<=*offset && *offset<=current_search_space->end)
363
	  current_search_space->start<=*offset && *offset<=current_search_space->end)
364
      {
364
      {
365
	*new_current_search_space=list_entry(current_search_space->list.next, alloc_data_t, list);
365
	*new_current_search_space=td_list_entry(current_search_space->list.next, alloc_data_t, list);
366
	*offset=(*new_current_search_space)->start;
366
	*offset=(*new_current_search_space)->start;
367
      }
367
      }
368
      list_del(search_walker);
368
      td_list_del(search_walker);
369
      free(current_search_space);
369
      free(current_search_space);
370
      return update_search_space_aux(list_search_space, start,end, new_current_search_space, offset);
370
      return update_search_space_aux(list_search_space, start,end, new_current_search_space, offset);
371
    }
371
    }
Lines 388-394 Link Here
388
      new_free_space->end=current_search_space->end;
388
      new_free_space->end=current_search_space->end;
389
      new_free_space->file_stat=NULL;
389
      new_free_space->file_stat=NULL;
390
      current_search_space->end=start-1;
390
      current_search_space->end=start-1;
391
      list_add(&new_free_space->list,search_walker);
391
      td_list_add(&new_free_space->list,search_walker);
392
      if(offset!=NULL && new_current_search_space!=NULL &&
392
      if(offset!=NULL && new_current_search_space!=NULL &&
393
	  new_free_space->start<=*offset && *offset<=new_free_space->end)
393
	  new_free_space->start<=*offset && *offset<=new_free_space->end)
394
      {
394
      {
Lines 418-430 Link Here
418
418
419
void free_list_search_space(alloc_data_t *list_search_space)
419
void free_list_search_space(alloc_data_t *list_search_space)
420
{
420
{
421
  struct list_head *search_walker = NULL;
421
  struct td_list_head *search_walker = NULL;
422
  struct list_head *search_walker_next = NULL;
422
  struct td_list_head *search_walker_next = NULL;
423
  list_for_each_safe(search_walker,search_walker_next,&list_search_space->list)
423
  td_list_for_each_safe(search_walker,search_walker_next,&list_search_space->list)
424
  {
424
  {
425
    alloc_data_t *current_search_space;
425
    alloc_data_t *current_search_space;
426
    current_search_space=list_entry(search_walker, alloc_data_t, list);
426
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
427
    list_del(search_walker);
427
    td_list_del(search_walker);
428
    free(current_search_space);
428
    free(current_search_space);
429
  }
429
  }
430
}
430
}
Lines 514-520 Link Here
514
static void get_prev_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
514
static void get_prev_header(alloc_data_t *list_search_space, alloc_data_t **current_search_space, uint64_t *offset)
515
{
515
{
516
  if((*current_search_space) != list_search_space)
516
  if((*current_search_space) != list_search_space)
517
    *current_search_space=list_entry((*current_search_space)->list.prev, alloc_data_t, list);
517
    *current_search_space=td_list_entry((*current_search_space)->list.prev, alloc_data_t, list);
518
  *offset=(*current_search_space)->start;
518
  *offset=(*current_search_space)->start;
519
}
519
}
520
#endif
520
#endif
Lines 525-531 Link Here
525
  alloc_data_t *file_space=*current_search_space;
525
  alloc_data_t *file_space=*current_search_space;
526
  for(nbr=0;nbr<5;nbr++)
526
  for(nbr=0;nbr<5;nbr++)
527
  {
527
  {
528
    file_space=list_entry(file_space->list.prev, alloc_data_t, list);
528
    file_space=td_list_entry(file_space->list.prev, alloc_data_t, list);
529
    if(file_space==list_search_space)
529
    if(file_space==list_search_space)
530
      return -1;
530
      return -1;
531
    if(file_space->file_stat!=NULL)
531
    if(file_space->file_stat!=NULL)
Lines 540-547 Link Here
540
540
541
void forget(alloc_data_t *list_search_space, alloc_data_t *current_search_space)
541
void forget(alloc_data_t *list_search_space, alloc_data_t *current_search_space)
542
{
542
{
543
  struct list_head *search_walker = NULL;
543
  struct td_list_head *search_walker = NULL;
544
  struct list_head *prev= NULL;
544
  struct td_list_head *prev= NULL;
545
  int nbr=0;
545
  int nbr=0;
546
  if(current_search_space==list_search_space)
546
  if(current_search_space==list_search_space)
547
    return ;
547
    return ;
Lines 553-560 Link Here
553
    if(nbr>10000)
553
    if(nbr>10000)
554
    {
554
    {
555
      alloc_data_t *tmp;
555
      alloc_data_t *tmp;
556
      tmp=list_entry(search_walker, alloc_data_t, list);
556
      tmp=td_list_entry(search_walker, alloc_data_t, list);
557
      list_del(&tmp->list);
557
      td_list_del(&tmp->list);
558
      free(tmp);
558
      free(tmp);
559
    }
559
    }
560
    else
560
    else
Lines 564-577 Link Here
564
564
565
void list_cluster_free(list_cluster_t *list_cluster)
565
void list_cluster_free(list_cluster_t *list_cluster)
566
{
566
{
567
  struct list_head *dir_walker = NULL;
567
  struct td_list_head *dir_walker = NULL;
568
  struct list_head *dir_walker_next = NULL;
568
  struct td_list_head *dir_walker_next = NULL;
569
  list_for_each_safe(dir_walker,dir_walker_next,&list_cluster->list)
569
  td_list_for_each_safe(dir_walker,dir_walker_next,&list_cluster->list)
570
  {
570
  {
571
    list_cluster_t *info;
571
    list_cluster_t *info;
572
    info=list_entry(dir_walker, list_cluster_t, list);
572
    info=td_list_entry(dir_walker, list_cluster_t, list);
573
    delete_list_file(info->dir_list);
573
    delete_list_file(info->dir_list);
574
    list_del(dir_walker);
574
    td_list_del(dir_walker);
575
    free(info);
575
    free(info);
576
  }
576
  }
577
}
577
}
Lines 589-604 Link Here
589
589
590
void update_stats(file_stat_t *file_stats, alloc_data_t *list_search_space)
590
void update_stats(file_stat_t *file_stats, alloc_data_t *list_search_space)
591
{
591
{
592
  struct list_head *search_walker = NULL;
592
  struct td_list_head *search_walker = NULL;
593
  int i;
593
  int i;
594
  /* Reset */
594
  /* Reset */
595
  for(i=0;file_stats[i].file_hint!=NULL;i++)
595
  for(i=0;file_stats[i].file_hint!=NULL;i++)
596
    file_stats[i].not_recovered=0;
596
    file_stats[i].not_recovered=0;
597
  /* Update */
597
  /* Update */
598
  list_for_each(search_walker, &list_search_space->list)
598
  td_list_for_each(search_walker, &list_search_space->list)
599
  {
599
  {
600
    alloc_data_t *current_search_space;
600
    alloc_data_t *current_search_space;
601
    current_search_space=list_entry(search_walker, alloc_data_t, list);
601
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
602
    if(current_search_space->file_stat!=NULL)
602
    if(current_search_space->file_stat!=NULL)
603
    {
603
    {
604
      current_search_space->file_stat->not_recovered++;
604
      current_search_space->file_stat->not_recovered++;
Lines 705-717 Link Here
705
  unsigned int nbr_max=0;
705
  unsigned int nbr_max=0;
706
  for(cluster_size=default_blocksize;cluster_size<=128*512;cluster_size*=2)
706
  for(cluster_size=default_blocksize;cluster_size<=128*512;cluster_size*=2)
707
  {
707
  {
708
    struct list_head *dir_walker = NULL;
708
    struct td_list_head *dir_walker = NULL;
709
    cluster_offset_t cluster_offset[1000];
709
    cluster_offset_t cluster_offset[1000];
710
    unsigned int nbr_sol=0;
710
    unsigned int nbr_sol=0;
711
    list_for_each(dir_walker,&list_cluster->list)
711
    td_list_for_each(dir_walker,&list_cluster->list)
712
    {
712
    {
713
      list_cluster_t *info;
713
      list_cluster_t *info;
714
      info=list_entry(dir_walker, list_cluster_t, list);
714
      info=td_list_entry(dir_walker, list_cluster_t, list);
715
      if(info->cluster>=2 && (info->cluster-2)*cluster_size<info->offset)
715
      if(info->cluster>=2 && (info->cluster-2)*cluster_size<info->offset)
716
      {
716
      {
717
	unsigned int sol_cur;
717
	unsigned int sol_cur;
Lines 753-767 Link Here
753
  int blocksize_ok=0;
753
  int blocksize_ok=0;
754
  unsigned int blocksize;
754
  unsigned int blocksize;
755
  *offset=0;
755
  *offset=0;
756
  if(list_empty(&list_file->list))
756
  if(td_list_empty(&list_file->list))
757
    return default_blocksize;
757
    return default_blocksize;
758
  for(blocksize=128*512;blocksize>=default_blocksize && blocksize_ok==0;blocksize=blocksize>>1)
758
  for(blocksize=128*512;blocksize>=default_blocksize && blocksize_ok==0;blocksize=blocksize>>1)
759
  {
759
  {
760
    struct list_head *search_walker = NULL;
760
    struct td_list_head *search_walker = NULL;
761
    blocksize_ok=1;
761
    blocksize_ok=1;
762
    {
762
    {
763
      alloc_data_t *tmp;
763
      alloc_data_t *tmp;
764
      tmp=list_entry(list_file->list.next, alloc_data_t, list);
764
      tmp=td_list_entry(list_file->list.next, alloc_data_t, list);
765
      *offset=tmp->start%blocksize;
765
      *offset=tmp->start%blocksize;
766
    }
766
    }
767
    for(search_walker=list_file->list.next;
767
    for(search_walker=list_file->list.next;
Lines 769-775 Link Here
769
      search_walker=search_walker->next)
769
      search_walker=search_walker->next)
770
    {
770
    {
771
      alloc_data_t *current_file;
771
      alloc_data_t *current_file;
772
      current_file=list_entry(search_walker, alloc_data_t, list);
772
      current_file=td_list_entry(search_walker, alloc_data_t, list);
773
      if(current_file->start%blocksize!=*offset)
773
      if(current_file->start%blocksize!=*offset)
774
	blocksize_ok=0;
774
	blocksize_ok=0;
775
    }
775
    }
Lines 780-797 Link Here
780
780
781
alloc_data_t * update_blocksize(unsigned int blocksize, alloc_data_t *list_search_space, const uint64_t offset)
781
alloc_data_t * update_blocksize(unsigned int blocksize, alloc_data_t *list_search_space, const uint64_t offset)
782
{
782
{
783
  struct list_head *search_walker = NULL;
783
  struct td_list_head *search_walker = NULL;
784
  struct list_head *search_walker_next = NULL;
784
  struct td_list_head *search_walker_next = NULL;
785
  list_for_each_safe(search_walker,search_walker_next,&list_search_space->list)
785
  td_list_for_each_safe(search_walker,search_walker_next,&list_search_space->list)
786
  {
786
  {
787
    alloc_data_t *current_search_space;
787
    alloc_data_t *current_search_space;
788
    current_search_space=list_entry(search_walker, alloc_data_t, list);
788
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
789
    current_search_space->start=(current_search_space->start-offset%blocksize+blocksize-1)/blocksize*blocksize+offset%blocksize;
789
    current_search_space->start=(current_search_space->start-offset%blocksize+blocksize-1)/blocksize*blocksize+offset%blocksize;
790
    if(current_search_space->start>current_search_space->end)
790
    if(current_search_space->start>current_search_space->end)
791
    {
791
    {
792
      list_del(search_walker);
792
      td_list_del(search_walker);
793
      if(list_search_space==current_search_space)
793
      if(list_search_space==current_search_space)
794
	list_search_space=list_entry(search_walker_next, alloc_data_t, list);
794
	list_search_space=td_list_entry(search_walker_next, alloc_data_t, list);
795
      free(current_search_space);
795
      free(current_search_space);
796
    }
796
    }
797
  }
797
  }
Lines 1240-1253 Link Here
1240
      list_free_add(file_recovery, list_search_space);
1240
      list_free_add(file_recovery, list_search_space);
1241
      if((*current_search_space)!=list_search_space &&
1241
      if((*current_search_space)!=list_search_space &&
1242
	  !((*current_search_space)->start <= *offset && *offset <= (*current_search_space)->end))
1242
	  !((*current_search_space)->start <= *offset && *offset <= (*current_search_space)->end))
1243
	*current_search_space=list_entry((*current_search_space)->list.next, alloc_data_t, list);
1243
	*current_search_space=td_list_entry((*current_search_space)->list.next, alloc_data_t, list);
1244
    }
1244
    }
1245
    else if(status!=STATUS_EXT2_ON_SAVE_EVERYTHING && status!=STATUS_EXT2_OFF_SAVE_EVERYTHING && status!=STATUS_FIND_OFFSET)
1245
    else if(status!=STATUS_EXT2_ON_SAVE_EVERYTHING && status!=STATUS_EXT2_OFF_SAVE_EVERYTHING && status!=STATUS_FIND_OFFSET)
1246
    {
1246
    {
1247
      list_search_space=update_search_space(file_recovery,list_search_space,current_search_space,offset,blocksize);
1247
      list_search_space=update_search_space(file_recovery,list_search_space,current_search_space,offset,blocksize);
1248
      file_recovered=1;
1248
      file_recovered=1;
1249
    }
1249
    }
1250
    list_delete(file_recovery->location.next);
1250
    td_list_delete(file_recovery->location.next);
1251
    file_recovery->location.next=NULL;
1251
    file_recovery->location.next=NULL;
1252
  }
1252
  }
1253
  if(file_recovery->file_size==0 && file_recovery->offset_error!=0)
1253
  if(file_recovery->file_size==0 && file_recovery->offset_error!=0)
(-)testdisk-6.8.org/src/photorec.h (-1 / +1 lines)
Lines 9-15 Link Here
9
typedef struct list_cluster_struct list_cluster_t;
9
typedef struct list_cluster_struct list_cluster_t;
10
struct list_cluster_struct
10
struct list_cluster_struct
11
{
11
{
12
  struct list_head list;
12
  struct td_list_head list;
13
  uint64_t offset;
13
  uint64_t offset;
14
  uint32_t cluster;
14
  uint32_t cluster;
15
  file_data_t *dir_list;
15
  file_data_t *dir_list;
(-)testdisk-6.8.org/src/phrecn.c (-30 / +30 lines)
Lines 365-372 Link Here
365
365
366
static int photorec_bf(disk_t *disk_car, partition_t *partition, const int debug, const int paranoid, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass, const unsigned int expert, const unsigned int lowmem)
366
static int photorec_bf(disk_t *disk_car, partition_t *partition, const int debug, const int paranoid, const char *recup_dir, const int interface, file_stat_t *file_stats, unsigned int *file_nbr, unsigned int *blocksize, alloc_data_t *list_search_space, const time_t real_start_time, unsigned int *dir_num, const photorec_status_t status, const unsigned int pass, const unsigned int expert, const unsigned int lowmem)
367
{
367
{
368
  struct list_head *search_walker = NULL;
368
  struct td_list_head *search_walker = NULL;
369
  struct list_head *n= NULL;
369
  struct td_list_head *n= NULL;
370
  unsigned char *buffer_start;
370
  unsigned char *buffer_start;
371
  unsigned int read_size;
371
  unsigned int read_size;
372
  unsigned int buffer_size;
372
  unsigned int buffer_size;
Lines 385-391 Link Here
385
    uint64_t offset;
385
    uint64_t offset;
386
    int need_to_check_file;
386
    int need_to_check_file;
387
    file_recovery_t file_recovery;
387
    file_recovery_t file_recovery;
388
    current_search_space=list_entry(search_walker, alloc_data_t, list);
388
    current_search_space=td_list_entry(search_walker, alloc_data_t, list);
389
    offset=current_search_space->start;
389
    offset=current_search_space->start;
390
    buffer_olddata=buffer_start;
390
    buffer_olddata=buffer_start;
391
    buffer=buffer_olddata+(*blocksize);
391
    buffer=buffer_olddata+(*blocksize);
Lines 394-405 Link Here
394
    disk_car->read(disk_car,READ_SIZE, buffer, offset);
394
    disk_car->read(disk_car,READ_SIZE, buffer, offset);
395
#ifdef DEBUG_BF
395
#ifdef DEBUG_BF
396
    {
396
    {
397
      struct list_head *tmp= NULL;
397
      struct td_list_head *tmp= NULL;
398
      log_debug("Explore ");
398
      log_debug("Explore ");
399
      list_for_each(tmp, &list_search_space->list)
399
      td_list_for_each(tmp, &list_search_space->list)
400
      {
400
      {
401
	alloc_data_t *cur_free_space;
401
	alloc_data_t *cur_free_space;
402
	cur_free_space=list_entry(tmp, alloc_data_t, list);
402
	cur_free_space=td_list_entry(tmp, alloc_data_t, list);
403
	log_debug(" %lu-%lu",(long unsigned)(cur_free_space->start/disk_car->sector_size),
403
	log_debug(" %lu-%lu",(long unsigned)(cur_free_space->start/disk_car->sector_size),
404
	    (long unsigned)(cur_free_space->end/disk_car->sector_size));
404
	    (long unsigned)(cur_free_space->end/disk_car->sector_size));
405
	if(cur_free_space==current_search_space)
405
	if(cur_free_space==current_search_space)
Lines 538-544 Link Here
538
    {
538
    {
539
      if(file_finish(&file_recovery,recup_dir,paranoid,file_nbr, *blocksize, list_search_space, &current_search_space, &offset, dir_num,status,disk_car->sector_size,disk_car)<0)
539
      if(file_finish(&file_recovery,recup_dir,paranoid,file_nbr, *blocksize, list_search_space, &current_search_space, &offset, dir_num,status,disk_car->sector_size,disk_car)<0)
540
      { /* BF */
540
      { /* BF */
541
	current_search_space=list_entry(search_walker, alloc_data_t, list);
541
	current_search_space=td_list_entry(search_walker, alloc_data_t, list);
542
	ind_stop=photorec_bf_aux(disk_car, partition, paranoid, recup_dir, interface, file_stats, file_nbr, &file_recovery, *blocksize, list_search_space, current_search_space, real_start_time, dir_num, status, pass2);
542
	ind_stop=photorec_bf_aux(disk_car, partition, paranoid, recup_dir, interface, file_stats, file_nbr, &file_recovery, *blocksize, list_search_space, current_search_space, real_start_time, dir_num, status, pass2);
543
	pass2++;
543
	pass2++;
544
      }
544
      }
Lines 619-629 Link Here
619
	  extrablock_offset=element->end/blocksize*blocksize;
619
	  extrablock_offset=element->end/blocksize*blocksize;
620
      }
620
      }
621
      /* Get the corresponding search_place */
621
      /* Get the corresponding search_place */
622
      extractblock_search_space=list_entry(list_search_space->list.next, alloc_data_t, list);
622
      extractblock_search_space=td_list_entry(list_search_space->list.next, alloc_data_t, list);
623
      while(extractblock_search_space != list_search_space &&
623
      while(extractblock_search_space != list_search_space &&
624
	  !(extractblock_search_space->start <= extrablock_offset &&
624
	  !(extractblock_search_space->start <= extrablock_offset &&
625
	    extrablock_offset <= extractblock_search_space->end))
625
	    extrablock_offset <= extractblock_search_space->end))
626
	extractblock_search_space=list_entry(extractblock_search_space->list.next, alloc_data_t, list);
626
	extractblock_search_space=td_list_entry(extractblock_search_space->list.next, alloc_data_t, list);
627
      /* Update extractblock_search_space & extrablock_offset */
627
      /* Update extractblock_search_space & extrablock_offset */
628
      get_next_sector(list_search_space, &extractblock_search_space, &extrablock_offset, blocksize);
628
      get_next_sector(list_search_space, &extractblock_search_space, &extrablock_offset, blocksize);
629
      /* */
629
      /* */
Lines 730-739 Link Here
730
  alloc_data_t *current_search_space;
730
  alloc_data_t *current_search_space;
731
  file_recovery_t file_recovery;
731
  file_recovery_t file_recovery;
732
  static alloc_data_t list_file={
732
  static alloc_data_t list_file={
733
    .list = LIST_HEAD_INIT(list_file.list)
733
    .list = TD_LIST_HEAD_INIT(list_file.list)
734
  };
734
  };
735
  static list_cluster_t list_cluster= {
735
  static list_cluster_t list_cluster= {
736
    .list = LIST_HEAD_INIT(list_cluster.list)
736
    .list = TD_LIST_HEAD_INIT(list_cluster.list)
737
  };
737
  };
738
#define READ_SIZE 256*512
738
#define READ_SIZE 256*512
739
  read_size=((*blocksize)>8192?(*blocksize):8192);
739
  read_size=((*blocksize)>8192?(*blocksize):8192);
Lines 747-764 Link Here
747
  memset(buffer_olddata,0,(*blocksize));
747
  memset(buffer_olddata,0,(*blocksize));
748
  if(debug>1)
748
  if(debug>1)
749
  {
749
  {
750
    struct list_head *search_walker = NULL;
750
    struct td_list_head *search_walker = NULL;
751
    log_debug("Explore ");
751
    log_debug("Explore ");
752
    list_for_each(search_walker, &list_search_space->list)
752
    td_list_for_each(search_walker, &list_search_space->list)
753
    {
753
    {
754
      alloc_data_t *cur_free_space;
754
      alloc_data_t *cur_free_space;
755
      cur_free_space=list_entry(search_walker, alloc_data_t, list);
755
      cur_free_space=td_list_entry(search_walker, alloc_data_t, list);
756
      log_debug(" %lu-%lu",(long unsigned)(cur_free_space->start/disk_car->sector_size),
756
      log_debug(" %lu-%lu",(long unsigned)(cur_free_space->start/disk_car->sector_size),
757
	  (long unsigned)(cur_free_space->end/disk_car->sector_size));
757
	  (long unsigned)(cur_free_space->end/disk_car->sector_size));
758
    }
758
    }
759
    log_debug("\n");
759
    log_debug("\n");
760
  }
760
  }
761
  current_search_space=list_entry(list_search_space->list.next, alloc_data_t, list);
761
  current_search_space=td_list_entry(list_search_space->list.next, alloc_data_t, list);
762
  if(current_search_space!=list_search_space)
762
  if(current_search_space!=list_search_space)
763
    offset=current_search_space->start;
763
    offset=current_search_space->start;
764
  disk_car->read(disk_car,READ_SIZE, buffer, offset);
764
  disk_car->read(disk_car,READ_SIZE, buffer, offset);
Lines 832-838 Link Here
832
	      new_file_alloc=(alloc_data_t*)MALLOC(sizeof(*new_file_alloc));
832
	      new_file_alloc=(alloc_data_t*)MALLOC(sizeof(*new_file_alloc));
833
	      new_file_alloc->start=file_recovery.location.start;
833
	      new_file_alloc->start=file_recovery.location.start;
834
	      new_file_alloc->end=0;
834
	      new_file_alloc->end=0;
835
	      list_add_tail(&new_file_alloc->list,&list_file.list);
835
	      td_list_add_tail(&new_file_alloc->list,&list_file.list);
836
	      (*file_nbr)++;
836
	      (*file_nbr)++;
837
	    }
837
	    }
838
	    if(file_recovery.file_stat->file_hint==&file_hint_dir)
838
	    if(file_recovery.file_stat->file_hint==&file_hint_dir)
Lines 1080-1086 Link Here
1080
  aff_buffer(BUFFER_RESET,"Q");
1080
  aff_buffer(BUFFER_RESET,"Q");
1081
  log_info("\nAnalyse\n");
1081
  log_info("\nAnalyse\n");
1082
  log_partition(disk_car,partition);
1082
  log_partition(disk_car,partition);
1083
  if(blocksize==0 || list_empty(&list_search_space->list))
1083
  if(blocksize==0 || td_list_empty(&list_search_space->list))
1084
  {
1084
  {
1085
    blocksize=disk_car->sector_size;
1085
    blocksize=disk_car->sector_size;
1086
    blocksize_is_known=0;
1086
    blocksize_is_known=0;
Lines 1088-1097 Link Here
1088
  else
1088
  else
1089
    blocksize_is_known=1;
1089
    blocksize_is_known=1;
1090
1090
1091
  if(list_empty(&list_search_space->list))
1091
  if(td_list_empty(&list_search_space->list))
1092
  {
1092
  {
1093
    alloc_data_t *tmp=init_search_space(partition,disk_car);
1093
    alloc_data_t *tmp=init_search_space(partition,disk_car);
1094
    list_add_tail(&tmp->list, &list_search_space->list);
1094
    td_list_add_tail(&tmp->list, &list_search_space->list);
1095
    if(mode_ext2==0 && carve_free_space_only>0)
1095
    if(mode_ext2==0 && carve_free_space_only>0)
1096
    {
1096
    {
1097
      blocksize=remove_used_space(disk_car, partition, list_search_space);
1097
      blocksize=remove_used_space(disk_car, partition, list_search_space);
Lines 1103-1113 Link Here
1103
  }
1103
  }
1104
  else
1104
  else
1105
  { /* Correct the values */
1105
  { /* Correct the values */
1106
    struct list_head *search_walker = NULL;
1106
    struct td_list_head *search_walker = NULL;
1107
    list_for_each(search_walker, &list_search_space->list)
1107
    td_list_for_each(search_walker, &list_search_space->list)
1108
    {
1108
    {
1109
      alloc_data_t *current_search_space;
1109
      alloc_data_t *current_search_space;
1110
      current_search_space=list_entry(search_walker, alloc_data_t, list);
1110
      current_search_space=td_list_entry(search_walker, alloc_data_t, list);
1111
      current_search_space->start=current_search_space->start*disk_car->sector_size;
1111
      current_search_space->start=current_search_space->start*disk_car->sector_size;
1112
      current_search_space->end=current_search_space->end*disk_car->sector_size+disk_car->sector_size-1;
1112
      current_search_space->end=current_search_space->end*disk_car->sector_size+disk_car->sector_size-1;
1113
    }
1113
    }
Lines 1266-1280 Link Here
1266
    }
1266
    }
1267
  }
1267
  }
1268
  {
1268
  {
1269
    struct list_head *search_walker = NULL;
1269
    struct td_list_head *search_walker = NULL;
1270
    struct list_head *search_walker_next = NULL;
1270
    struct td_list_head *search_walker_next = NULL;
1271
    unsigned long int nbr_headers=0;
1271
    unsigned long int nbr_headers=0;
1272
    uint64_t sectors_with_unknown_data=0;
1272
    uint64_t sectors_with_unknown_data=0;
1273
    /* Free memory */
1273
    /* Free memory */
1274
    list_for_each_safe(search_walker,search_walker_next,&list_search_space->list)
1274
    td_list_for_each_safe(search_walker,search_walker_next,&list_search_space->list)
1275
    {
1275
    {
1276
      alloc_data_t *current_search_space;
1276
      alloc_data_t *current_search_space;
1277
      current_search_space=list_entry(search_walker, alloc_data_t, list);
1277
      current_search_space=td_list_entry(search_walker, alloc_data_t, list);
1278
      if(current_search_space->file_stat!=NULL)
1278
      if(current_search_space->file_stat!=NULL)
1279
      {
1279
      {
1280
	nbr_headers++;
1280
	nbr_headers++;
Lines 1290-1296 Link Here
1290
	      current_search_space->file_stat->file_hint->extension:""):
1290
	      current_search_space->file_stat->file_hint->extension:""):
1291
	     "(null)"));
1291
	     "(null)"));
1292
      }
1292
      }
1293
      list_del(search_walker);
1293
      td_list_del(search_walker);
1294
      free(current_search_space);
1294
      free(current_search_space);
1295
    }
1295
    }
1296
    log_info("%llu sectors contains unknown data, %lu invalid files found %s.\n",
1296
    log_info("%llu sectors contains unknown data, %lu invalid files found %s.\n",
Lines 1533-1544 Link Here
1533
  };
1533
  };
1534
  char *current_cmd=cmd_run;
1534
  char *current_cmd=cmd_run;
1535
  alloc_data_t list_search_space={
1535
  alloc_data_t list_search_space={
1536
    .list = LIST_HEAD_INIT(list_search_space.list)
1536
    .list = TD_LIST_HEAD_INIT(list_search_space.list)
1537
  };
1537
  };
1538
  if(cmd_device==NULL)
1538
  if(cmd_device==NULL)
1539
  {
1539
  {
1540
    session_load(&cmd_device, &current_cmd,&list_search_space);
1540
    session_load(&cmd_device, &current_cmd,&list_search_space);
1541
    if(cmd_device!=NULL && current_cmd!=NULL && !list_empty(&list_search_space.list) && ask_confirmation("Continue previous session ? (Y/N)")!=0)
1541
    if(cmd_device!=NULL && current_cmd!=NULL && !td_list_empty(&list_search_space.list) && ask_confirmation("Continue previous session ? (Y/N)")!=0)
1542
    {
1542
    {
1543
      /* yes */
1543
      /* yes */
1544
    }
1544
    }
Lines 2041-2047 Link Here
2041
      (unsigned long long)((*current_search_space)->end)/512);
2041
      (unsigned long long)((*current_search_space)->end)/512);
2042
#endif
2042
#endif
2043
  if((*current_search_space) != list_search_space)
2043
  if((*current_search_space) != list_search_space)
2044
    *current_search_space=list_entry((*current_search_space)->list.next, alloc_data_t, list);
2044
    *current_search_space=td_list_entry((*current_search_space)->list.next, alloc_data_t, list);
2045
  *offset=(*current_search_space)->start;
2045
  *offset=(*current_search_space)->start;
2046
}
2046
}
2047
2047
(-)testdisk-6.8.org/src/savehdr.c (-2 / +2 lines)
Lines 137-143 Link Here
137
	log_debug("new disk: %s\n",pos);
137
	log_debug("new disk: %s\n",pos);
138
      }
138
      }
139
      if(new_backup!=NULL)
139
      if(new_backup!=NULL)
140
	list_add_tail(&new_backup->list,&list_backup->list);
140
	td_list_add_tail(&new_backup->list,&list_backup->list);
141
      new_backup=(backup_disk_t*)MALLOC(sizeof(*new_backup));
141
      new_backup=(backup_disk_t*)MALLOC(sizeof(*new_backup));
142
      new_backup->description[0]='\0';
142
      new_backup->description[0]='\0';
143
      new_backup->list_part=NULL;
143
      new_backup->list_part=NULL;
Lines 196-202 Link Here
196
    }
196
    }
197
  }
197
  }
198
  if(new_backup!=NULL)
198
  if(new_backup!=NULL)
199
    list_add_tail(&new_backup->list,&list_backup->list);
199
    td_list_add_tail(&new_backup->list,&list_backup->list);
200
  fclose(f_backup);
200
  fclose(f_backup);
201
  free(buffer);
201
  free(buffer);
202
  return list_backup;
202
  return list_backup;
(-)testdisk-6.8.org/src/savehdr.h (-1 / +1 lines)
Lines 23-29 Link Here
23
typedef struct backup_disk backup_disk_t;
23
typedef struct backup_disk backup_disk_t;
24
struct backup_disk
24
struct backup_disk
25
{
25
{
26
  struct list_head list;
26
  struct td_list_head list;
27
  time_t my_time;
27
  time_t my_time;
28
  char description[128];
28
  char description[128];
29
  list_part_t *list_part;
29
  list_part_t *list_part;
(-)testdisk-6.8.org/src/sessionp.c (-4 / +4 lines)
Lines 142-148 Link Here
142
	  new_free_space->start=start;
142
	  new_free_space->start=start;
143
	  new_free_space->end=end;
143
	  new_free_space->end=end;
144
	  new_free_space->file_stat=NULL;
144
	  new_free_space->file_stat=NULL;
145
	  list_add_tail(&new_free_space->list, &list_free_space->list);
145
	  td_list_add_tail(&new_free_space->list, &list_free_space->list);
146
#ifdef DEBUG
146
#ifdef DEBUG
147
	  log_trace(">%lu-%lu<\n",start,end);
147
	  log_trace(">%lu-%lu<\n",start,end);
148
#endif
148
#endif
Lines 161-167 Link Here
161
161
162
int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partition_t *partition, const file_enable_t *files_enable, const unsigned int blocksize, const int debug)
162
int session_save(alloc_data_t *list_free_space, disk_t *disk_car, const partition_t *partition, const file_enable_t *files_enable, const unsigned int blocksize, const int debug)
163
{
163
{
164
  struct list_head *free_walker = NULL;
164
  struct td_list_head *free_walker = NULL;
165
  FILE *f_session;
165
  FILE *f_session;
166
  unsigned int i;
166
  unsigned int i;
167
  if(debug>1)
167
  if(debug>1)
Lines 183-192 Link Here
183
    }
183
    }
184
  }
184
  }
185
  fprintf(f_session,"search,inter\n");
185
  fprintf(f_session,"search,inter\n");
186
  list_for_each(free_walker, &list_free_space->list)
186
  td_list_for_each(free_walker, &list_free_space->list)
187
  {
187
  {
188
    alloc_data_t *current_free_space;
188
    alloc_data_t *current_free_space;
189
    current_free_space=list_entry(free_walker, alloc_data_t, list);
189
    current_free_space=td_list_entry(free_walker, alloc_data_t, list);
190
    fprintf(f_session,"%lu-%lu\n",(long unsigned)(current_free_space->start/disk_car->sector_size),
190
    fprintf(f_session,"%lu-%lu\n",(long unsigned)(current_free_space->start/disk_car->sector_size),
191
	(long unsigned)(current_free_space->end/disk_car->sector_size));
191
	(long unsigned)(current_free_space->end/disk_car->sector_size));
192
  }
192
  }

Return to bug 194346