Lines Matching full:dir
3 * linux/fs/adfs/dir.c
17 int adfs_dir_copyfrom(void *dst, struct adfs_dir *dir, unsigned int offset, in adfs_dir_copyfrom() argument
20 struct super_block *sb = dir->sb; in adfs_dir_copyfrom()
26 if (index + (remain < len) >= dir->nr_buffers) in adfs_dir_copyfrom()
30 memcpy(dst, dir->bhs[index]->b_data + offset, remain); in adfs_dir_copyfrom()
37 memcpy(dst, dir->bhs[index]->b_data + offset, len); in adfs_dir_copyfrom()
42 int adfs_dir_copyto(struct adfs_dir *dir, unsigned int offset, const void *src, in adfs_dir_copyto() argument
45 struct super_block *sb = dir->sb; in adfs_dir_copyto()
51 if (index + (remain < len) >= dir->nr_buffers) in adfs_dir_copyto()
55 memcpy(dir->bhs[index]->b_data + offset, src, remain); in adfs_dir_copyto()
62 memcpy(dir->bhs[index]->b_data + offset, src, len); in adfs_dir_copyto()
67 static void __adfs_dir_cleanup(struct adfs_dir *dir) in __adfs_dir_cleanup() argument
69 dir->nr_buffers = 0; in __adfs_dir_cleanup()
71 if (dir->bhs != dir->bh) in __adfs_dir_cleanup()
72 kfree(dir->bhs); in __adfs_dir_cleanup()
73 dir->bhs = NULL; in __adfs_dir_cleanup()
74 dir->sb = NULL; in __adfs_dir_cleanup()
77 void adfs_dir_relse(struct adfs_dir *dir) in adfs_dir_relse() argument
81 for (i = 0; i < dir->nr_buffers; i++) in adfs_dir_relse()
82 brelse(dir->bhs[i]); in adfs_dir_relse()
84 __adfs_dir_cleanup(dir); in adfs_dir_relse()
87 static void adfs_dir_forget(struct adfs_dir *dir) in adfs_dir_forget() argument
91 for (i = 0; i < dir->nr_buffers; i++) in adfs_dir_forget()
92 bforget(dir->bhs[i]); in adfs_dir_forget()
94 __adfs_dir_cleanup(dir); in adfs_dir_forget()
98 unsigned int size, struct adfs_dir *dir) in adfs_dir_read_buffers() argument
105 if (num > ARRAY_SIZE(dir->bh)) { in adfs_dir_read_buffers()
107 if (dir->bhs != dir->bh) in adfs_dir_read_buffers()
114 if (dir->nr_buffers) in adfs_dir_read_buffers()
115 memcpy(bhs, dir->bhs, dir->nr_buffers * sizeof(*bhs)); in adfs_dir_read_buffers()
117 dir->bhs = bhs; in adfs_dir_read_buffers()
120 for (i = dir->nr_buffers; i < num; i++) { in adfs_dir_read_buffers()
123 adfs_error(sb, "dir %06x has a hole at offset %u", in adfs_dir_read_buffers()
128 dir->bhs[i] = sb_bread(sb, block); in adfs_dir_read_buffers()
129 if (!dir->bhs[i]) { in adfs_dir_read_buffers()
131 "dir %06x failed read at offset %u, mapped block 0x%08x", in adfs_dir_read_buffers()
136 dir->nr_buffers++; in adfs_dir_read_buffers()
141 adfs_dir_relse(dir); in adfs_dir_read_buffers()
147 unsigned int size, struct adfs_dir *dir) in adfs_dir_read() argument
149 dir->sb = sb; in adfs_dir_read()
150 dir->bhs = dir->bh; in adfs_dir_read()
151 dir->nr_buffers = 0; in adfs_dir_read()
153 return ADFS_SB(sb)->s_dir->read(sb, indaddr, size, dir); in adfs_dir_read()
157 struct adfs_dir *dir) in adfs_dir_read_inode() argument
161 ret = adfs_dir_read(sb, ADFS_I(inode)->indaddr, inode->i_size, dir); in adfs_dir_read_inode()
165 if (ADFS_I(inode)->parent_id != dir->parent_id) { in adfs_dir_read_inode()
168 ADFS_I(inode)->parent_id, dir->parent_id); in adfs_dir_read_inode()
169 adfs_dir_relse(dir); in adfs_dir_read_inode()
176 static void adfs_dir_mark_dirty(struct adfs_dir *dir) in adfs_dir_mark_dirty() argument
181 for (i = 0; i < dir->nr_buffers; i++) in adfs_dir_mark_dirty()
182 mark_buffer_dirty(dir->bhs[i]); in adfs_dir_mark_dirty()
185 static int adfs_dir_sync(struct adfs_dir *dir) in adfs_dir_sync() argument
190 for (i = dir->nr_buffers - 1; i >= 0; i--) { in adfs_dir_sync()
191 struct buffer_head *bh = dir->bhs[i]; in adfs_dir_sync()
200 void adfs_object_fixup(struct adfs_dir *dir, struct object_info *obj) in adfs_object_fixup() argument
226 if (!(obj->attr & ADFS_NDA_DIRECTORY) && ADFS_SB(dir->sb)->s_ftsuffix) { in adfs_object_fixup()
243 struct adfs_dir dir; in adfs_iterate() local
247 ret = adfs_dir_read_inode(sb, inode, &dir); in adfs_iterate()
257 if (!dir_emit(ctx, "..", 2, dir.parent_id, DT_DIR)) in adfs_iterate()
262 ret = ops->iterate(&dir, ctx); in adfs_iterate()
266 adfs_dir_relse(&dir); in adfs_iterate()
278 struct adfs_dir dir; in adfs_dir_update() local
288 ret = adfs_dir_read(sb, obj->parent_id, 0, &dir); in adfs_dir_update()
292 ret = ops->update(&dir, obj); in adfs_dir_update()
296 ret = ops->commit(&dir); in adfs_dir_update()
301 adfs_dir_mark_dirty(&dir); in adfs_dir_update()
304 ret = adfs_dir_sync(&dir); in adfs_dir_update()
306 adfs_dir_relse(&dir); in adfs_dir_update()
316 adfs_dir_relse(&dir); in adfs_dir_update()
318 adfs_dir_forget(&dir); in adfs_dir_update()
353 struct adfs_dir dir; in adfs_dir_lookup_byname() local
358 ret = adfs_dir_read_inode(sb, inode, &dir); in adfs_dir_lookup_byname()
362 ret = ops->setpos(&dir, 0); in adfs_dir_lookup_byname()
369 while (ops->getnext(&dir, obj) == 0) { in adfs_dir_lookup_byname()
379 adfs_dir_relse(&dir); in adfs_dir_lookup_byname()
430 adfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) in adfs_lookup() argument
436 error = adfs_dir_lookup_byname(dir, &dentry->d_name, &obj); in adfs_lookup()
442 inode = adfs_iget(dir->i_sb, &obj); in adfs_lookup()