Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

VFS: note error returns in documentation for various lookup functions

Darrick recently noted that try_lookup_noperm() is documented as
"Look up a dentry by name in the dcache, returning NULL if it does not
currently exist." but it can in fact return an error.

So update the documentation for that and related functions.

Link: https://lore.kernel.org/all/20260218234917.GA6490@frogsfrogsfrogs/
Cc: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: NeilBrown <neil@brown.name>
Link: https://patch.msgid.link/20260224222542.3458677-2-neilb@ownmail.net
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

NeilBrown and committed by
Christian Brauner
c025a533 6de23f81

+28 -1
+28 -1
fs/namei.c
··· 3124 3124 * @base: base directory to lookup from 3125 3125 * 3126 3126 * Look up a dentry by name in the dcache, returning NULL if it does not 3127 - * currently exist. The function does not try to create a dentry and if one 3127 + * currently exist or an error if there is a problem with the name. 3128 + * The function does not try to create a dentry and if one 3128 3129 * is found it doesn't try to revalidate it. 3129 3130 * 3130 3131 * Note that this routine is purely a helper for filesystem usage and should ··· 3133 3132 * 3134 3133 * No locks need be held - only a counted reference to @base is needed. 3135 3134 * 3135 + * Returns: 3136 + * - ref-counted dentry on success, or 3137 + * - %NULL if name could not be found, or 3138 + * - ERR_PTR(-EACCES) if name is dot or dotdot or contains a slash or nul, or 3139 + * - ERR_PTR() if fs provide ->d_hash, and this returned an error. 3136 3140 */ 3137 3141 struct dentry *try_lookup_noperm(struct qstr *name, struct dentry *base) 3138 3142 { ··· 3214 3208 * 3215 3209 * Unlike lookup_one, it should be called without the parent 3216 3210 * i_rwsem held, and will take the i_rwsem itself if necessary. 3211 + * 3212 + * Returns: - A dentry, possibly negative, or 3213 + * - same errors as try_lookup_noperm() or 3214 + * - ERR_PTR(-ENOENT) if parent has been removed, or 3215 + * - ERR_PTR(-EACCES) if parent directory is not searchable. 3217 3216 */ 3218 3217 struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap, struct qstr *name, 3219 3218 struct dentry *base) ··· 3255 3244 * It should be called without the parent i_rwsem held, and will take 3256 3245 * the i_rwsem itself if necessary. If a fatal signal is pending or 3257 3246 * delivered, it will return %-EINTR if the lock is needed. 3247 + * 3248 + * Returns: A dentry, possibly negative, or 3249 + * - same errors as lookup_one_unlocked() or 3250 + * - ERR_PTR(-EINTR) if a fatal signal is pending. 3258 3251 */ 3259 3252 struct dentry *lookup_one_positive_killable(struct mnt_idmap *idmap, 3260 3253 struct qstr *name, ··· 3298 3283 * This can be used for in-kernel filesystem clients such as file servers. 3299 3284 * 3300 3285 * The helper should be called without i_rwsem held. 3286 + * 3287 + * Returns: A positive dentry, or 3288 + * - ERR_PTR(-ENOENT) if the name could not be found, or 3289 + * - same errors as lookup_one_unlocked(). 3301 3290 */ 3302 3291 struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap, 3303 3292 struct qstr *name, ··· 3330 3311 * 3331 3312 * Unlike try_lookup_noperm() it *does* revalidate the dentry if it already 3332 3313 * existed. 3314 + * 3315 + * Returns: A dentry, possibly negative, or 3316 + * - ERR_PTR(-ENOENT) if parent has been removed, or 3317 + * - same errors as try_lookup_noperm() 3333 3318 */ 3334 3319 struct dentry *lookup_noperm_unlocked(struct qstr *name, struct dentry *base) 3335 3320 { ··· 3358 3335 * _can_ become positive at any time, so callers of lookup_noperm_unlocked() 3359 3336 * need to be very careful; pinned positives have ->d_inode stable, so 3360 3337 * this one avoids such problems. 3338 + * 3339 + * Returns: A positive dentry, or 3340 + * - ERR_PTR(-ENOENT) if name cannot be found or parent has been removed, or 3341 + * - same errors as try_lookup_noperm() 3361 3342 */ 3362 3343 struct dentry *lookup_noperm_positive_unlocked(struct qstr *name, 3363 3344 struct dentry *base)