Lines Matching +full:back +full:- +full:to +full:- +full:back

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2017-2018 HUAWEI, Inc.
24 * on-disk error, let's only BUG_ON in the debugging mode. in erofs_dirnamecmp()
25 * otherwise, it will return 1 to just skip the invalid name in erofs_dirnamecmp()
28 DBG_BUGON(qd->name > qd->end); in erofs_dirnamecmp()
31 /* However it is absolutely safe if < qd->end */ in erofs_dirnamecmp()
32 while (qd->name + i < qd->end && qd->name[i] != '\0') { in erofs_dirnamecmp()
33 if (qn->name[i] != qd->name[i]) { in erofs_dirnamecmp()
35 return qn->name[i] > qd->name[i] ? 1 : -1; in erofs_dirnamecmp()
41 return qn->name[i] == '\0' ? 0 : 1; in erofs_dirnamecmp()
44 #define nameoff_from_disk(off, sz) (le16_to_cpu(off) & ((sz) - 1))
51 int head, back; in find_target_dirent() local
57 back = ndirents - 1; in find_target_dirent()
60 while (head <= back) { in find_target_dirent()
61 const int mid = head + (back - head) / 2; in find_target_dirent()
67 .end = mid >= ndirents - 1 ? in find_target_dirent()
82 back = mid - 1; in find_target_dirent()
87 return ERR_PTR(-ENOENT); in find_target_dirent()
95 int head, back; in find_target_block_classic() local
96 struct address_space *const mapping = dir->i_mapping; in find_target_block_classic()
97 struct page *candidate = ERR_PTR(-ENOENT); in find_target_block_classic()
101 back = erofs_inode_datablocks(dir) - 1; in find_target_block_classic()
103 while (head <= back) { in find_target_block_classic()
104 const int mid = head + (back - head) / 2; in find_target_block_classic()
109 const int nameoff = nameoff_from_disk(de->nameoff, in find_target_block_classic()
119 erofs_err(dir->i_sb, in find_target_block_classic()
121 mid, EROFS_I(dir)->nid); in find_target_block_classic()
123 page = ERR_PTR(-EFSCORRUPTED); in find_target_block_classic()
155 back = mid - 1; in find_target_block_classic()
178 if (!dir->i_size) in erofs_namei()
179 return -ENOENT; in erofs_namei()
181 qn.name = name->name; in erofs_namei()
182 qn.end = name->name + name->len; in erofs_namei()
198 *nid = le64_to_cpu(de->nid); in erofs_namei()
199 *d_type = de->file_type; in erofs_namei()
219 /* dentry must be unhashed in lookup, no need to worry about */ in erofs_lookup()
225 if (dentry->d_name.len > EROFS_NAME_LEN) in erofs_lookup()
226 return ERR_PTR(-ENAMETOOLONG); in erofs_lookup()
229 err = erofs_namei(dir, &dentry->d_name, &nid, &d_type); in erofs_lookup()
231 if (err == -ENOENT) { in erofs_lookup()
238 dentry->d_name.name, nid, d_type); in erofs_lookup()
239 inode = erofs_iget(dir->i_sb, nid, d_type == FT_DIR); in erofs_lookup()