blob: eedbe55c8091e0707a36265bb03bb37122c607f6 [file] [log] [blame]
Theodore Ts'o19c78dc1997-04-29 16:17:09 +00001/*
2 * irel_ma.c
3 *
4 * Copyright (C) 1996, 1997 Theodore Ts'o.
5 *
6 * %Begin-Header%
7 * This file may be redistributed under the terms of the GNU Public
8 * License.
9 * %End-Header%
10 */
11
12#include <fcntl.h>
13#include <stdio.h>
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000014#include <string.h>
Theodore Ts'o4cbe8af1997-08-10 23:07:40 +000015#if HAVE_UNISTD_H
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000016#include <unistd.h>
Theodore Ts'o4cbe8af1997-08-10 23:07:40 +000017#endif
18#if HAVE_ERRNO_H
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000019#include <errno.h>
Theodore Ts'o4cbe8af1997-08-10 23:07:40 +000020#endif
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000021
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +000022#include "ext2_fs.h"
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000023#include "ext2fs.h"
24#include "irel.h"
25
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000026static errcode_t ima_put(ext2_irel irel, ext2_ino_t old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000027 struct ext2_inode_relocate_entry *ent);
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000028static errcode_t ima_get(ext2_irel irel, ext2_ino_t old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000029 struct ext2_inode_relocate_entry *ent);
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000030static errcode_t ima_get_by_orig(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000031 struct ext2_inode_relocate_entry *ent);
32static errcode_t ima_start_iter(ext2_irel irel);
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000033static errcode_t ima_next(ext2_irel irel, ext2_ino_t *old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000034 struct ext2_inode_relocate_entry *ent);
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000035static errcode_t ima_add_ref(ext2_irel irel, ext2_ino_t ino,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000036 struct ext2_inode_reference *ref);
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000037static errcode_t ima_start_iter_ref(ext2_irel irel, ext2_ino_t ino);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000038static errcode_t ima_next_ref(ext2_irel irel, struct ext2_inode_reference *ref);
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000039static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new);
40static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000041static errcode_t ima_free(ext2_irel irel);
42
43/*
44 * This data structure stores the array of inode references; there is
45 * a structure for each inode.
46 */
47struct inode_reference_entry {
48 __u16 num;
49 struct ext2_inode_reference *refs;
50};
51
52struct irel_ma {
53 __u32 magic;
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000054 ext2_ino_t max_inode;
55 ext2_ino_t ref_current;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000056 int ref_iter;
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000057 ext2_ino_t *orig_map;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000058 struct ext2_inode_relocate_entry *entries;
59 struct inode_reference_entry *ref_entries;
60};
61
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000062errcode_t ext2fs_irel_memarray_create(char *name, ext2_ino_t max_inode,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000063 ext2_irel *new_irel)
64{
65 ext2_irel irel = 0;
66 errcode_t retval;
67 struct irel_ma *ma = 0;
68 size_t size;
69
70 *new_irel = 0;
71
72 /*
73 * Allocate memory structures
74 */
Theodore Ts'o7b4e4531997-10-26 03:41:24 +000075 retval = ext2fs_get_mem(sizeof(struct ext2_inode_relocation_table),
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -040076 &irel);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +000077 if (retval)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000078 goto errout;
79 memset(irel, 0, sizeof(struct ext2_inode_relocation_table));
80
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -040081 retval = ext2fs_get_mem(strlen(name)+1, &irel->name);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +000082 if (retval)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000083 goto errout;
84 strcpy(irel->name, name);
85
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -040086 retval = ext2fs_get_mem(sizeof(struct irel_ma), &ma);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +000087 if (retval)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000088 goto errout;
89 memset(ma, 0, sizeof(struct irel_ma));
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +000090 irel->priv_data = ma;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000091
Theodore Ts'o31dbecd2001-01-11 04:54:39 +000092 size = (size_t) (sizeof(ext2_ino_t) * (max_inode+1));
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -040093 retval = ext2fs_get_mem(size, &ma->orig_map);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +000094 if (retval)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +000095 goto errout;
96 memset(ma->orig_map, 0, size);
97
Theodore Ts'o3cb6c501997-08-11 20:29:22 +000098 size = (size_t) (sizeof(struct ext2_inode_relocate_entry) *
99 (max_inode+1));
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400100 retval = ext2fs_get_mem(size, &ma->entries);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +0000101 if (retval)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000102 goto errout;
103 memset(ma->entries, 0, size);
104
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000105 size = (size_t) (sizeof(struct inode_reference_entry) *
106 (max_inode+1));
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400107 retval = ext2fs_get_mem(size, &ma->ref_entries);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +0000108 if (retval)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000109 goto errout;
110 memset(ma->ref_entries, 0, size);
111 ma->max_inode = max_inode;
112
113 /*
114 * Fill in the irel data structure
115 */
116 irel->put = ima_put;
117 irel->get = ima_get;
118 irel->get_by_orig = ima_get_by_orig;
119 irel->start_iter = ima_start_iter;
120 irel->next = ima_next;
121 irel->add_ref = ima_add_ref;
122 irel->start_iter_ref = ima_start_iter_ref;
123 irel->next_ref = ima_next_ref;
124 irel->move = ima_move;
125 irel->delete = ima_delete;
126 irel->free = ima_free;
127
128 *new_irel = irel;
129 return 0;
130
131errout:
132 ima_free(irel);
133 return retval;
134}
135
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000136static errcode_t ima_put(ext2_irel irel, ext2_ino_t old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000137 struct ext2_inode_relocate_entry *ent)
138{
Theodore Ts'o7b4e4531997-10-26 03:41:24 +0000139 struct inode_reference_entry *ref_ent;
140 struct irel_ma *ma;
141 errcode_t retval;
Theodore Ts'o76f875d1998-04-27 01:41:13 +0000142 size_t size, old_size;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000143
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000144 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000145 if (old > ma->max_inode)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000146 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000147
148 /*
149 * Force the orig field to the correct value; the application
150 * program shouldn't be messing with this field.
151 */
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000152 if (ma->entries[(unsigned) old].new == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000153 ent->orig = old;
154 else
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000155 ent->orig = ma->entries[(unsigned) old].orig;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000156
157 /*
158 * If max_refs has changed, reallocate the refs array
159 */
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000160 ref_ent = ma->ref_entries + (unsigned) old;
161 if (ref_ent->refs && ent->max_refs !=
162 ma->entries[(unsigned) old].max_refs) {
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000163 size = (sizeof(struct ext2_inode_reference) * ent->max_refs);
Theodore Ts'o76f875d1998-04-27 01:41:13 +0000164 old_size = (sizeof(struct ext2_inode_reference) *
165 ma->entries[(unsigned) old].max_refs);
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400166 retval = ext2fs_resize_mem(old_size, size, &ref_ent->refs);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +0000167 if (retval)
168 return retval;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000169 }
170
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000171 ma->entries[(unsigned) old] = *ent;
172 ma->orig_map[(unsigned) ent->orig] = old;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000173 return 0;
174}
175
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000176static errcode_t ima_get(ext2_irel irel, ext2_ino_t old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000177 struct ext2_inode_relocate_entry *ent)
178{
179 struct irel_ma *ma;
180
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000181 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000182 if (old > ma->max_inode)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000183 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000184 if (ma->entries[(unsigned) old].new == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000185 return ENOENT;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000186 *ent = ma->entries[(unsigned) old];
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000187 return 0;
188}
189
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000190static errcode_t ima_get_by_orig(ext2_irel irel, ext2_ino_t orig, ext2_ino_t *old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000191 struct ext2_inode_relocate_entry *ent)
192{
193 struct irel_ma *ma;
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000194 ext2_ino_t ino;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000195
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000196 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000197 if (orig > ma->max_inode)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000198 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000199 ino = ma->orig_map[(unsigned) orig];
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000200 if (ino == 0)
201 return ENOENT;
202 *old = ino;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000203 *ent = ma->entries[(unsigned) ino];
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000204 return 0;
205}
206
207static errcode_t ima_start_iter(ext2_irel irel)
208{
209 irel->current = 0;
210 return 0;
211}
212
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000213static errcode_t ima_next(ext2_irel irel, ext2_ino_t *old,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000214 struct ext2_inode_relocate_entry *ent)
215{
216 struct irel_ma *ma;
217
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000218 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000219 while (++irel->current < ma->max_inode) {
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000220 if (ma->entries[(unsigned) irel->current].new == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000221 continue;
222 *old = irel->current;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000223 *ent = ma->entries[(unsigned) irel->current];
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000224 return 0;
225 }
226 *old = 0;
227 return 0;
228}
229
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000230static errcode_t ima_add_ref(ext2_irel irel, ext2_ino_t ino,
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000231 struct ext2_inode_reference *ref)
232{
233 struct irel_ma *ma;
234 size_t size;
235 struct inode_reference_entry *ref_ent;
236 struct ext2_inode_relocate_entry *ent;
Theodore Ts'o7b4e4531997-10-26 03:41:24 +0000237 errcode_t retval;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000238
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000239 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000240 if (ino > ma->max_inode)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000241 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000242
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000243 ref_ent = ma->ref_entries + (unsigned) ino;
244 ent = ma->entries + (unsigned) ino;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000245
246 /*
247 * If the inode reference array doesn't exist, create it.
248 */
249 if (ref_ent->refs == 0) {
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000250 size = (size_t) ((sizeof(struct ext2_inode_reference) *
251 ent->max_refs));
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400252 retval = ext2fs_get_mem(size, &ref_ent->refs);
Theodore Ts'o7b4e4531997-10-26 03:41:24 +0000253 if (retval)
254 return retval;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000255 memset(ref_ent->refs, 0, size);
256 ref_ent->num = 0;
257 }
258
259 if (ref_ent->num >= ent->max_refs)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000260 return EXT2_ET_TOO_MANY_REFS;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000261
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000262 ref_ent->refs[(unsigned) ref_ent->num++] = *ref;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000263 return 0;
264}
265
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000266static errcode_t ima_start_iter_ref(ext2_irel irel, ext2_ino_t ino)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000267{
268 struct irel_ma *ma;
269
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000270 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000271 if (ino > ma->max_inode)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000272 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000273 if (ma->entries[(unsigned) ino].new == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000274 return ENOENT;
275 ma->ref_current = ino;
276 ma->ref_iter = 0;
277 return 0;
278}
279
280static errcode_t ima_next_ref(ext2_irel irel,
281 struct ext2_inode_reference *ref)
282{
283 struct irel_ma *ma;
284 struct inode_reference_entry *ref_ent;
285
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000286 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000287
288 ref_ent = ma->ref_entries + ma->ref_current;
289
290 if ((ref_ent->refs == NULL) ||
291 (ma->ref_iter >= ref_ent->num)) {
292 ref->block = 0;
293 ref->offset = 0;
294 return 0;
295 }
296 *ref = ref_ent->refs[ma->ref_iter++];
297 return 0;
298}
299
300
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000301static errcode_t ima_move(ext2_irel irel, ext2_ino_t old, ext2_ino_t new)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000302{
303 struct irel_ma *ma;
304
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000305 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000306 if ((old > ma->max_inode) || (new > ma->max_inode))
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000307 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000308 if (ma->entries[(unsigned) old].new == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000309 return ENOENT;
310
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000311 ma->entries[(unsigned) new] = ma->entries[(unsigned) old];
312 if (ma->ref_entries[(unsigned) new].refs)
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400313 ext2fs_free_mem(&ma->ref_entries[(unsigned) new].refs);
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000314 ma->ref_entries[(unsigned) new] = ma->ref_entries[(unsigned) old];
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000315
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000316 ma->entries[(unsigned) old].new = 0;
317 ma->ref_entries[(unsigned) old].num = 0;
318 ma->ref_entries[(unsigned) old].refs = 0;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000319
320 ma->orig_map[ma->entries[new].orig] = new;
321 return 0;
322}
323
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000324static errcode_t ima_delete(ext2_irel irel, ext2_ino_t old)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000325{
326 struct irel_ma *ma;
327
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000328 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000329 if (old > ma->max_inode)
Theodore Ts'o1f0b6c11997-10-31 06:07:47 +0000330 return EXT2_ET_INVALID_ARGUMENT;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000331 if (ma->entries[(unsigned) old].new == 0)
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000332 return ENOENT;
333
334 ma->entries[old].new = 0;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000335 if (ma->ref_entries[(unsigned) old].refs)
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400336 ext2fs_free_mem(&ma->ref_entries[(unsigned) old].refs);
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000337 ma->orig_map[ma->entries[(unsigned) old].orig] = 0;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000338
Theodore Ts'o1c27cac1997-08-14 17:20:42 +0000339 ma->ref_entries[(unsigned) old].num = 0;
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000340 ma->ref_entries[(unsigned) old].refs = 0;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000341 return 0;
342}
343
344static errcode_t ima_free(ext2_irel irel)
345{
346 struct irel_ma *ma;
Theodore Ts'o31dbecd2001-01-11 04:54:39 +0000347 ext2_ino_t ino;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000348
349 if (!irel)
350 return 0;
351
Theodore Ts'ob5abe6f1998-01-19 14:47:53 +0000352 ma = irel->priv_data;
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000353
354 if (ma) {
355 if (ma->orig_map)
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400356 ext2fs_free_mem(&ma->orig_map);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000357 if (ma->entries)
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400358 ext2fs_free_mem(&ma->entries);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000359 if (ma->ref_entries) {
360 for (ino = 0; ino <= ma->max_inode; ino++) {
Theodore Ts'o3cb6c501997-08-11 20:29:22 +0000361 if (ma->ref_entries[(unsigned) ino].refs)
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400362 ext2fs_free_mem(&ma->ref_entries[(unsigned) ino].refs);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000363 }
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400364 ext2fs_free_mem(&ma->ref_entries);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000365 }
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400366 ext2fs_free_mem(&ma);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000367 }
368 if (irel->name)
Theodore Ts'oc4e3d3f2003-08-01 09:41:07 -0400369 ext2fs_free_mem(&irel->name);
370 ext2fs_free_mem(&irel);
Theodore Ts'o19c78dc1997-04-29 16:17:09 +0000371 return 0;
372}