Lines Matching +full:back +full:- +full:end
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2017-2018 HUAWEI, Inc.
12 const unsigned char *end; member
15 /* based on the end of qn is accurate and it must have the trailing '\0' */
23 * on-disk error, let's only BUG_ON in the debugging mode. in erofs_dirnamecmp()
27 DBG_BUGON(qd->name > qd->end); in erofs_dirnamecmp()
30 /* However it is absolutely safe if < qd->end */ in erofs_dirnamecmp()
31 while (qd->name + i < qd->end && qd->name[i] != '\0') { in erofs_dirnamecmp()
32 if (qn->name[i] != qd->name[i]) { in erofs_dirnamecmp()
34 return qn->name[i] > qd->name[i] ? 1 : -1; in erofs_dirnamecmp()
40 return qn->name[i] == '\0' ? 0 : 1; in erofs_dirnamecmp()
43 #define nameoff_from_disk(off, sz) (le16_to_cpu(off) & ((sz) - 1))
50 int head, back; in find_target_dirent() local
56 back = ndirents - 1; in find_target_dirent()
59 while (head <= back) { in find_target_dirent()
60 const int mid = head + (back - head) / 2; in find_target_dirent()
66 .end = mid >= ndirents - 1 ? in find_target_dirent()
81 back = mid - 1; in find_target_dirent()
86 return ERR_PTR(-ENOENT); in find_target_dirent()
93 int head = 0, back = erofs_iblks(dir) - 1; in erofs_find_target_block() local
95 void *candidate = ERR_PTR(-ENOENT); in erofs_find_target_block()
97 while (head <= back) { in erofs_find_target_block()
98 const int mid = head + (back - head) / 2; in erofs_find_target_block()
102 buf.mapping = dir->i_mapping; in erofs_find_target_block()
103 de = erofs_bread(&buf, erofs_pos(dir->i_sb, mid), EROFS_KMAP); in erofs_find_target_block()
105 const int nameoff = nameoff_from_disk(de->nameoff, bsz); in erofs_find_target_block()
113 erofs_err(dir->i_sb, in erofs_find_target_block()
115 mid, EROFS_I(dir)->nid); in erofs_find_target_block()
117 de = ERR_PTR(-EFSCORRUPTED); in erofs_find_target_block()
125 dname.end = (u8 *)de + bsz; in erofs_find_target_block()
127 dname.end = (u8 *)de + in erofs_find_target_block()
135 back = mid - 1; in erofs_find_target_block()
169 if (!dir->i_size) in erofs_namei()
170 return -ENOENT; in erofs_namei()
172 qn.name = name->name; in erofs_namei()
173 qn.end = name->name + name->len; in erofs_namei()
174 buf.mapping = dir->i_mapping; in erofs_namei()
186 *nid = le64_to_cpu(de->nid); in erofs_namei()
187 *d_type = de->file_type; in erofs_namei()
203 if (dentry->d_name.len > EROFS_NAME_LEN) in erofs_lookup()
204 return ERR_PTR(-ENAMETOOLONG); in erofs_lookup()
206 err = erofs_namei(dir, &dentry->d_name, &nid, &d_type); in erofs_lookup()
208 if (err == -ENOENT) in erofs_lookup()
214 inode = erofs_iget(dir->i_sb, nid); in erofs_lookup()