Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\readdir.c Create Date:2022-07-28 20:06:36
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:filldir

Proto:static int filldir(struct dir_context *ctx, const char *name, int namlen, loff_t offset, u64 ino, unsigned int d_type)

Type:int

Parameter:

TypeParameterName
struct dir_context *ctx
const char *name
intnamlen
loff_toffset
u64ino
unsigned intd_type
221  __user * dirent
222  buf = container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(ctx, structgetdents_callback, ctx)
225  reclen = @a is a power of 2 value (offsetof(structlinux_dirent, d_name) + namlen + 2, sizeof(long))
229  error = POSIX says that a dirent name cannot contain NULL or a '/'.* It's not 100% clear what we should really do in this case.* The filesystem is clearly corrupted, but returning a hard* error means that you now don't see any of the other names
230  If Value for the false possibility is greater at compile time(error) Then Return error
232  error = -EINVAL
233  If reclen > count Then Return -EINVAL
235  d_ino = ino
236  If size of d_ino < size of ino && d_ino != ino Then
237  error = -EOVERFLOW
238  Return -EOVERFLOW
240  prev_reclen = prev_reclen
241  If prev_reclen && signal_pending(current process) Then Return -EINTR
243  dirent = current_dir
244  prev = dirent - prev_reclen
245  If Not The "unsafe" user accesses aren't really "unsafe", but the naming* is a big fat warning: you have to not only do the access_ok()* checking before using them, but you have to surround them with the* user_access_begin/end() pair. Then Go to efault
249  unsafe_put_user(offset, & d_off, efault_end)
250  unsafe_put_user(d_ino, & d_ino, efault_end)
251  unsafe_put_user(reclen, & d_reclen, efault_end)
252  unsafe_put_user(d_type, (char__user * )dirent + reclen - 1, efault_end)
253  Note the "unsafe_put_user() semantics: we goto a* label for errors.(d_name, name, namlen, efault_end)
254  user_access_end()
256  current_dir = dirent + reclen
257  prev_reclen = reclen
258  count -= reclen
259  Return 0
260  efault_end :
261  user_access_end()
262  efault :
263  error = -EFAULT
264  Return -EFAULT