Lines Matching +full:directory +full:- +full:based
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (C) 1997-1999 Russell King
7 * E and F format directory handling
48 int _off = idx - (_buf << blocksize_bits);\
49 *(u8 *)(bh[_buf]->b_data + _off); \
54 int _off = idx - (_buf << blocksize_bits);\
55 *(__le32 *)(bh[_buf]->b_data + _off); \
60 int _off = _idx - (_buf << blocksize_bits);\
61 (void *)(_bh[_buf]->b_data + _off); \
72 struct buffer_head * const *bh = dir->bh; in adfs_dir_checkbyte()
73 const int blocksize_bits = dir->sb->s_blocksize_bits; in adfs_dir_checkbyte()
76 int last = 5 - 26; in adfs_dir_checkbyte()
81 * word of the last directory entry. This in adfs_dir_checkbyte()
99 end.ptr8 = ptr.ptr8 + last - i; in adfs_dir_checkbyte()
107 * The directory tail is in the final bh in adfs_dir_checkbyte()
126 struct adfs_dirheader *head = dir->dirhead; in adfs_f_validate()
127 struct adfs_newdirtail *tail = dir->newtail; in adfs_f_validate()
129 if (head->startmasseq != tail->endmasseq || in adfs_f_validate()
130 tail->dirlastmask || tail->reserved[0] || tail->reserved[1] || in adfs_f_validate()
131 (memcmp(&head->startname, "Nick", 4) && in adfs_f_validate()
132 memcmp(&head->startname, "Hugo", 4)) || in adfs_f_validate()
133 memcmp(&head->startname, &tail->endname, 4) || in adfs_f_validate()
134 adfs_dir_checkbyte(dir) != tail->dircheckbyte) in adfs_f_validate()
135 return -EIO; in adfs_f_validate()
140 /* Read and check that a directory is valid */
144 const unsigned int blocksize_bits = sb->s_blocksize_bits; in adfs_f_read()
148 return -EIO; in adfs_f_read()
154 dir->dirhead = bufoff(dir->bh, 0); in adfs_f_read()
155 dir->newtail = bufoff(dir->bh, 2007); in adfs_f_read()
160 dir->parent_id = adfs_readval(dir->newtail->dirparent, 3); in adfs_f_read()
168 return -EIO; in adfs_f_read()
172 * convert a disk-based directory entry to a Linux ADFS directory entry
181 if (de->dirobname[name_len] < ' ') in adfs_dir2obj()
184 obj->name[name_len] = de->dirobname[name_len]; in adfs_dir2obj()
187 obj->name_len = name_len; in adfs_dir2obj()
188 obj->indaddr = adfs_readval(de->dirinddiscadd, 3); in adfs_dir2obj()
189 obj->loadaddr = adfs_readval(de->dirload, 4); in adfs_dir2obj()
190 obj->execaddr = adfs_readval(de->direxec, 4); in adfs_dir2obj()
191 obj->size = adfs_readval(de->dirlen, 4); in adfs_dir2obj()
192 obj->attr = de->newdiratts; in adfs_dir2obj()
198 * convert a Linux ADFS directory entry to a disk-based directory entry
203 adfs_writeval(de->dirinddiscadd, 3, obj->indaddr); in adfs_obj2dir()
204 adfs_writeval(de->dirload, 4, obj->loadaddr); in adfs_obj2dir()
205 adfs_writeval(de->direxec, 4, obj->execaddr); in adfs_obj2dir()
206 adfs_writeval(de->dirlen, 4, obj->size); in adfs_obj2dir()
207 de->newdiratts = obj->attr; in adfs_obj2dir()
211 * get a directory entry. Note that the caller is responsible
225 return -ENOENT; in __adfs_dir_get()
236 return -ENOENT; in adfs_f_setpos()
238 dir->pos = 5 + fpos * 26; in adfs_f_setpos()
247 ret = __adfs_dir_get(dir, dir->pos, obj); in adfs_f_getnext()
249 dir->pos += 26; in adfs_f_getnext()
257 int pos = 5 + (ctx->pos - 2) * 26; in adfs_f_iterate()
259 while (ctx->pos < 2 + ADFS_NUM_DIR_ENTRIES) { in adfs_f_iterate()
266 ctx->pos++; in adfs_f_iterate()
276 offset = 5 - (int)sizeof(de); in adfs_f_update()
282 adfs_error(dir->sb, "error reading directory entry"); in adfs_f_update()
283 return -ENOENT; in adfs_f_update()
286 adfs_error(dir->sb, "unable to locate entry to update"); in adfs_f_update()
287 return -ENOENT; in adfs_f_update()
289 } while (adfs_readval(de.dirinddiscadd, 3) != obj->indaddr); in adfs_f_update()
291 /* Update the directory entry with the new object state */ in adfs_f_update()
294 /* Write the directory entry back to the directory */ in adfs_f_update()
302 /* Increment directory sequence number */ in adfs_f_commit()
303 dir->dirhead->startmasseq += 1; in adfs_f_commit()
304 dir->newtail->endmasseq += 1; in adfs_f_commit()
306 /* Update directory check byte */ in adfs_f_commit()
307 dir->newtail->dircheckbyte = adfs_dir_checkbyte(dir); in adfs_f_commit()
309 /* Make sure the directory still validates correctly */ in adfs_f_commit()
312 adfs_msg(dir->sb, KERN_ERR, "error: update broke directory"); in adfs_f_commit()