Lines Matching refs:stat
47 struct inode *inode, struct kstat *stat) in generic_fillattr() argument
52 stat->dev = inode->i_sb->s_dev; in generic_fillattr()
53 stat->ino = inode->i_ino; in generic_fillattr()
54 stat->mode = inode->i_mode; in generic_fillattr()
55 stat->nlink = inode->i_nlink; in generic_fillattr()
56 stat->uid = vfsuid_into_kuid(vfsuid); in generic_fillattr()
57 stat->gid = vfsgid_into_kgid(vfsgid); in generic_fillattr()
58 stat->rdev = inode->i_rdev; in generic_fillattr()
59 stat->size = i_size_read(inode); in generic_fillattr()
60 stat->atime = inode->i_atime; in generic_fillattr()
61 stat->mtime = inode->i_mtime; in generic_fillattr()
62 stat->ctime = inode_get_ctime(inode); in generic_fillattr()
63 stat->blksize = i_blocksize(inode); in generic_fillattr()
64 stat->blocks = inode->i_blocks; in generic_fillattr()
67 stat->result_mask |= STATX_CHANGE_COOKIE; in generic_fillattr()
68 stat->change_cookie = inode_query_iversion(inode); in generic_fillattr()
82 void generic_fill_statx_attr(struct inode *inode, struct kstat *stat) in generic_fill_statx_attr() argument
85 stat->attributes |= STATX_ATTR_IMMUTABLE; in generic_fill_statx_attr()
87 stat->attributes |= STATX_ATTR_APPEND; in generic_fill_statx_attr()
88 stat->attributes_mask |= KSTAT_ATTR_VFS_FLAGS; in generic_fill_statx_attr()
105 int vfs_getattr_nosec(const struct path *path, struct kstat *stat, in vfs_getattr_nosec() argument
111 memset(stat, 0, sizeof(*stat)); in vfs_getattr_nosec()
112 stat->result_mask |= STATX_BASIC_STATS; in vfs_getattr_nosec()
118 stat->result_mask &= ~STATX_ATIME; in vfs_getattr_nosec()
125 stat->attributes |= STATX_ATTR_AUTOMOUNT; in vfs_getattr_nosec()
128 stat->attributes |= STATX_ATTR_DAX; in vfs_getattr_nosec()
130 stat->attributes_mask |= (STATX_ATTR_AUTOMOUNT | in vfs_getattr_nosec()
135 return inode->i_op->getattr(idmap, path, stat, in vfs_getattr_nosec()
139 generic_fillattr(idmap, request_mask, inode, stat); in vfs_getattr_nosec()
165 int vfs_getattr(const struct path *path, struct kstat *stat, in vfs_getattr() argument
176 return vfs_getattr_nosec(path, stat, request_mask, query_flags); in vfs_getattr()
190 int vfs_fstat(int fd, struct kstat *stat) in vfs_fstat() argument
198 error = vfs_getattr(&f.file->f_path, stat, STATX_BASIC_STATS, 0); in vfs_fstat()
233 struct kstat *stat, u32 request_mask) in vfs_statx() argument
248 error = vfs_getattr(&path, stat, request_mask, flags); in vfs_statx()
250 stat->mnt_id = real_mount(path.mnt)->mnt_id; in vfs_statx()
251 stat->result_mask |= STATX_MNT_ID; in vfs_statx()
254 stat->attributes |= STATX_ATTR_MOUNT_ROOT; in vfs_statx()
255 stat->attributes_mask |= STATX_ATTR_MOUNT_ROOT; in vfs_statx()
262 bdev_statx_dioalign(inode, stat); in vfs_statx()
275 struct kstat *stat, int flags) in vfs_fstatat() argument
295 return vfs_fstat(dfd, stat); in vfs_fstatat()
299 ret = vfs_statx(dfd, name, statx_flags, stat, STATX_BASIC_STATS); in vfs_fstatat()
311 static int cp_old_stat(struct kstat *stat, struct __old_kernel_stat __user * statbuf) in cp_old_stat() argument
326 tmp.st_dev = old_encode_dev(stat->dev); in cp_old_stat()
327 tmp.st_ino = stat->ino; in cp_old_stat()
328 if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) in cp_old_stat()
330 tmp.st_mode = stat->mode; in cp_old_stat()
331 tmp.st_nlink = stat->nlink; in cp_old_stat()
332 if (tmp.st_nlink != stat->nlink) in cp_old_stat()
334 SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid)); in cp_old_stat()
335 SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid)); in cp_old_stat()
336 tmp.st_rdev = old_encode_dev(stat->rdev); in cp_old_stat()
338 if (stat->size > MAX_NON_LFS) in cp_old_stat()
341 tmp.st_size = stat->size; in cp_old_stat()
342 tmp.st_atime = stat->atime.tv_sec; in cp_old_stat()
343 tmp.st_mtime = stat->mtime.tv_sec; in cp_old_stat()
344 tmp.st_ctime = stat->ctime.tv_sec; in cp_old_stat()
348 SYSCALL_DEFINE2(stat, const char __user *, filename, in SYSCALL_DEFINE2() argument
351 struct kstat stat; in SYSCALL_DEFINE2() local
354 error = vfs_stat(filename, &stat); in SYSCALL_DEFINE2()
358 return cp_old_stat(&stat, statbuf); in SYSCALL_DEFINE2()
364 struct kstat stat; in SYSCALL_DEFINE2() local
367 error = vfs_lstat(filename, &stat); in SYSCALL_DEFINE2()
371 return cp_old_stat(&stat, statbuf); in SYSCALL_DEFINE2()
376 struct kstat stat; in SYSCALL_DEFINE2() local
377 int error = vfs_fstat(fd, &stat); in SYSCALL_DEFINE2()
380 error = cp_old_stat(&stat, statbuf); in SYSCALL_DEFINE2()
393 static int cp_new_stat(struct kstat *stat, struct stat __user *statbuf) in cp_new_stat() argument
395 struct stat tmp; in cp_new_stat()
397 if (sizeof(tmp.st_dev) < 4 && !old_valid_dev(stat->dev)) in cp_new_stat()
399 if (sizeof(tmp.st_rdev) < 4 && !old_valid_dev(stat->rdev)) in cp_new_stat()
402 if (stat->size > MAX_NON_LFS) in cp_new_stat()
407 tmp.st_dev = new_encode_dev(stat->dev); in cp_new_stat()
408 tmp.st_ino = stat->ino; in cp_new_stat()
409 if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) in cp_new_stat()
411 tmp.st_mode = stat->mode; in cp_new_stat()
412 tmp.st_nlink = stat->nlink; in cp_new_stat()
413 if (tmp.st_nlink != stat->nlink) in cp_new_stat()
415 SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid)); in cp_new_stat()
416 SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid)); in cp_new_stat()
417 tmp.st_rdev = new_encode_dev(stat->rdev); in cp_new_stat()
418 tmp.st_size = stat->size; in cp_new_stat()
419 tmp.st_atime = stat->atime.tv_sec; in cp_new_stat()
420 tmp.st_mtime = stat->mtime.tv_sec; in cp_new_stat()
421 tmp.st_ctime = stat->ctime.tv_sec; in cp_new_stat()
423 tmp.st_atime_nsec = stat->atime.tv_nsec; in cp_new_stat()
424 tmp.st_mtime_nsec = stat->mtime.tv_nsec; in cp_new_stat()
425 tmp.st_ctime_nsec = stat->ctime.tv_nsec; in cp_new_stat()
427 tmp.st_blocks = stat->blocks; in cp_new_stat()
428 tmp.st_blksize = stat->blksize; in cp_new_stat()
433 struct stat __user *, statbuf) in SYSCALL_DEFINE2()
435 struct kstat stat; in SYSCALL_DEFINE2() local
436 int error = vfs_stat(filename, &stat); in SYSCALL_DEFINE2()
440 return cp_new_stat(&stat, statbuf); in SYSCALL_DEFINE2()
444 struct stat __user *, statbuf) in SYSCALL_DEFINE2()
446 struct kstat stat; in SYSCALL_DEFINE2() local
449 error = vfs_lstat(filename, &stat); in SYSCALL_DEFINE2()
453 return cp_new_stat(&stat, statbuf); in SYSCALL_DEFINE2()
458 struct stat __user *, statbuf, int, flag) in SYSCALL_DEFINE4()
460 struct kstat stat; in SYSCALL_DEFINE4() local
463 error = vfs_fstatat(dfd, filename, &stat, flag); in SYSCALL_DEFINE4()
466 return cp_new_stat(&stat, statbuf); in SYSCALL_DEFINE4()
470 SYSCALL_DEFINE2(newfstat, unsigned int, fd, struct stat __user *, statbuf) in SYSCALL_DEFINE2()
472 struct kstat stat; in SYSCALL_DEFINE2() local
473 int error = vfs_fstat(fd, &stat); in SYSCALL_DEFINE2()
476 error = cp_new_stat(&stat, statbuf); in SYSCALL_DEFINE2()
538 static long cp_new_stat64(struct kstat *stat, struct stat64 __user *statbuf) in cp_new_stat64() argument
545 tmp.st_dev = new_encode_dev(stat->dev); in cp_new_stat64()
546 tmp.st_rdev = new_encode_dev(stat->rdev); in cp_new_stat64()
548 tmp.st_dev = huge_encode_dev(stat->dev); in cp_new_stat64()
549 tmp.st_rdev = huge_encode_dev(stat->rdev); in cp_new_stat64()
551 tmp.st_ino = stat->ino; in cp_new_stat64()
552 if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) in cp_new_stat64()
555 tmp.__st_ino = stat->ino; in cp_new_stat64()
557 tmp.st_mode = stat->mode; in cp_new_stat64()
558 tmp.st_nlink = stat->nlink; in cp_new_stat64()
559 tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid); in cp_new_stat64()
560 tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid); in cp_new_stat64()
561 tmp.st_atime = stat->atime.tv_sec; in cp_new_stat64()
562 tmp.st_atime_nsec = stat->atime.tv_nsec; in cp_new_stat64()
563 tmp.st_mtime = stat->mtime.tv_sec; in cp_new_stat64()
564 tmp.st_mtime_nsec = stat->mtime.tv_nsec; in cp_new_stat64()
565 tmp.st_ctime = stat->ctime.tv_sec; in cp_new_stat64()
566 tmp.st_ctime_nsec = stat->ctime.tv_nsec; in cp_new_stat64()
567 tmp.st_size = stat->size; in cp_new_stat64()
568 tmp.st_blocks = stat->blocks; in cp_new_stat64()
569 tmp.st_blksize = stat->blksize; in cp_new_stat64()
576 struct kstat stat; in SYSCALL_DEFINE2() local
577 int error = vfs_stat(filename, &stat); in SYSCALL_DEFINE2()
580 error = cp_new_stat64(&stat, statbuf); in SYSCALL_DEFINE2()
588 struct kstat stat; in SYSCALL_DEFINE2() local
589 int error = vfs_lstat(filename, &stat); in SYSCALL_DEFINE2()
592 error = cp_new_stat64(&stat, statbuf); in SYSCALL_DEFINE2()
599 struct kstat stat; in SYSCALL_DEFINE2() local
600 int error = vfs_fstat(fd, &stat); in SYSCALL_DEFINE2()
603 error = cp_new_stat64(&stat, statbuf); in SYSCALL_DEFINE2()
611 struct kstat stat; in SYSCALL_DEFINE4() local
614 error = vfs_fstatat(dfd, filename, &stat, flag); in SYSCALL_DEFINE4()
617 return cp_new_stat64(&stat, statbuf); in SYSCALL_DEFINE4()
622 cp_statx(const struct kstat *stat, struct statx __user *buffer) in cp_statx() argument
629 tmp.stx_mask = stat->result_mask & ~STATX_CHANGE_COOKIE; in cp_statx()
630 tmp.stx_blksize = stat->blksize; in cp_statx()
632 tmp.stx_attributes = stat->attributes & ~STATX_ATTR_CHANGE_MONOTONIC; in cp_statx()
633 tmp.stx_nlink = stat->nlink; in cp_statx()
634 tmp.stx_uid = from_kuid_munged(current_user_ns(), stat->uid); in cp_statx()
635 tmp.stx_gid = from_kgid_munged(current_user_ns(), stat->gid); in cp_statx()
636 tmp.stx_mode = stat->mode; in cp_statx()
637 tmp.stx_ino = stat->ino; in cp_statx()
638 tmp.stx_size = stat->size; in cp_statx()
639 tmp.stx_blocks = stat->blocks; in cp_statx()
640 tmp.stx_attributes_mask = stat->attributes_mask; in cp_statx()
641 tmp.stx_atime.tv_sec = stat->atime.tv_sec; in cp_statx()
642 tmp.stx_atime.tv_nsec = stat->atime.tv_nsec; in cp_statx()
643 tmp.stx_btime.tv_sec = stat->btime.tv_sec; in cp_statx()
644 tmp.stx_btime.tv_nsec = stat->btime.tv_nsec; in cp_statx()
645 tmp.stx_ctime.tv_sec = stat->ctime.tv_sec; in cp_statx()
646 tmp.stx_ctime.tv_nsec = stat->ctime.tv_nsec; in cp_statx()
647 tmp.stx_mtime.tv_sec = stat->mtime.tv_sec; in cp_statx()
648 tmp.stx_mtime.tv_nsec = stat->mtime.tv_nsec; in cp_statx()
649 tmp.stx_rdev_major = MAJOR(stat->rdev); in cp_statx()
650 tmp.stx_rdev_minor = MINOR(stat->rdev); in cp_statx()
651 tmp.stx_dev_major = MAJOR(stat->dev); in cp_statx()
652 tmp.stx_dev_minor = MINOR(stat->dev); in cp_statx()
653 tmp.stx_mnt_id = stat->mnt_id; in cp_statx()
654 tmp.stx_dio_mem_align = stat->dio_mem_align; in cp_statx()
655 tmp.stx_dio_offset_align = stat->dio_offset_align; in cp_statx()
663 struct kstat stat; in do_statx() local
676 error = vfs_statx(dfd, filename, flags, &stat, mask); in do_statx()
680 return cp_statx(&stat, buffer); in do_statx()
710 static int cp_compat_stat(struct kstat *stat, struct compat_stat __user *ubuf) in cp_compat_stat() argument
714 if (sizeof(tmp.st_dev) < 4 && !old_valid_dev(stat->dev)) in cp_compat_stat()
716 if (sizeof(tmp.st_rdev) < 4 && !old_valid_dev(stat->rdev)) in cp_compat_stat()
720 tmp.st_dev = new_encode_dev(stat->dev); in cp_compat_stat()
721 tmp.st_ino = stat->ino; in cp_compat_stat()
722 if (sizeof(tmp.st_ino) < sizeof(stat->ino) && tmp.st_ino != stat->ino) in cp_compat_stat()
724 tmp.st_mode = stat->mode; in cp_compat_stat()
725 tmp.st_nlink = stat->nlink; in cp_compat_stat()
726 if (tmp.st_nlink != stat->nlink) in cp_compat_stat()
728 SET_UID(tmp.st_uid, from_kuid_munged(current_user_ns(), stat->uid)); in cp_compat_stat()
729 SET_GID(tmp.st_gid, from_kgid_munged(current_user_ns(), stat->gid)); in cp_compat_stat()
730 tmp.st_rdev = new_encode_dev(stat->rdev); in cp_compat_stat()
731 if ((u64) stat->size > MAX_NON_LFS) in cp_compat_stat()
733 tmp.st_size = stat->size; in cp_compat_stat()
734 tmp.st_atime = stat->atime.tv_sec; in cp_compat_stat()
735 tmp.st_atime_nsec = stat->atime.tv_nsec; in cp_compat_stat()
736 tmp.st_mtime = stat->mtime.tv_sec; in cp_compat_stat()
737 tmp.st_mtime_nsec = stat->mtime.tv_nsec; in cp_compat_stat()
738 tmp.st_ctime = stat->ctime.tv_sec; in cp_compat_stat()
739 tmp.st_ctime_nsec = stat->ctime.tv_nsec; in cp_compat_stat()
740 tmp.st_blocks = stat->blocks; in cp_compat_stat()
741 tmp.st_blksize = stat->blksize; in cp_compat_stat()
748 struct kstat stat; in COMPAT_SYSCALL_DEFINE2() local
751 error = vfs_stat(filename, &stat); in COMPAT_SYSCALL_DEFINE2()
754 return cp_compat_stat(&stat, statbuf); in COMPAT_SYSCALL_DEFINE2()
760 struct kstat stat; in COMPAT_SYSCALL_DEFINE2() local
763 error = vfs_lstat(filename, &stat); in COMPAT_SYSCALL_DEFINE2()
766 return cp_compat_stat(&stat, statbuf); in COMPAT_SYSCALL_DEFINE2()
774 struct kstat stat; in COMPAT_SYSCALL_DEFINE4() local
777 error = vfs_fstatat(dfd, filename, &stat, flag); in COMPAT_SYSCALL_DEFINE4()
780 return cp_compat_stat(&stat, statbuf); in COMPAT_SYSCALL_DEFINE4()
787 struct kstat stat; in COMPAT_SYSCALL_DEFINE2() local
788 int error = vfs_fstat(fd, &stat); in COMPAT_SYSCALL_DEFINE2()
791 error = cp_compat_stat(&stat, statbuf); in COMPAT_SYSCALL_DEFINE2()