linux(4): Move statx_copyout() close to linux_statx()

Just for future changes of the conditional Linuxulator build. We need
a small refactoring of the MI code to help porting Linuxulator to other
platforms.
This commit is contained in:
Dmitry Chagin 2023-04-28 11:54:59 +03:00
parent 6072eea0c3
commit e9204c5c2c

View File

@ -165,39 +165,6 @@ newstat_copyout(struct stat *buf, void *ubuf)
return (copyout(&tbuf, ubuf, sizeof(tbuf)));
}
static int
statx_copyout(struct stat *buf, void *ubuf)
{
struct l_statx tbuf;
bzero(&tbuf, sizeof(tbuf));
tbuf.stx_mask = STATX_ALL;
tbuf.stx_blksize = buf->st_blksize;
tbuf.stx_attributes = 0;
tbuf.stx_nlink = buf->st_nlink;
tbuf.stx_uid = buf->st_uid;
tbuf.stx_gid = buf->st_gid;
tbuf.stx_mode = buf->st_mode;
tbuf.stx_ino = buf->st_ino;
tbuf.stx_size = buf->st_size;
tbuf.stx_blocks = buf->st_blocks;
tbuf.stx_atime.tv_sec = buf->st_atim.tv_sec;
tbuf.stx_atime.tv_nsec = buf->st_atim.tv_nsec;
tbuf.stx_btime.tv_sec = buf->st_birthtim.tv_sec;
tbuf.stx_btime.tv_nsec = buf->st_birthtim.tv_nsec;
tbuf.stx_ctime.tv_sec = buf->st_ctim.tv_sec;
tbuf.stx_ctime.tv_nsec = buf->st_ctim.tv_nsec;
tbuf.stx_mtime.tv_sec = buf->st_mtim.tv_sec;
tbuf.stx_mtime.tv_nsec = buf->st_mtim.tv_nsec;
tbuf.stx_rdev_major = buf->st_rdev >> 8;
tbuf.stx_rdev_minor = buf->st_rdev & 0xff;
tbuf.stx_dev_major = buf->st_dev >> 8;
tbuf.stx_dev_minor = buf->st_dev & 0xff;
return (copyout(&tbuf, ubuf, sizeof(tbuf)));
}
#ifdef LINUX_LEGACY_SYSCALLS
int
@ -753,6 +720,40 @@ linux_syncfs(struct thread *td, struct linux_syncfs_args *args)
return (error);
}
static int
statx_copyout(struct stat *buf, void *ubuf)
{
struct l_statx tbuf;
bzero(&tbuf, sizeof(tbuf));
tbuf.stx_mask = STATX_ALL;
tbuf.stx_blksize = buf->st_blksize;
tbuf.stx_attributes = 0;
tbuf.stx_nlink = buf->st_nlink;
tbuf.stx_uid = buf->st_uid;
tbuf.stx_gid = buf->st_gid;
tbuf.stx_mode = buf->st_mode;
tbuf.stx_ino = buf->st_ino;
tbuf.stx_size = buf->st_size;
tbuf.stx_blocks = buf->st_blocks;
tbuf.stx_atime.tv_sec = buf->st_atim.tv_sec;
tbuf.stx_atime.tv_nsec = buf->st_atim.tv_nsec;
tbuf.stx_btime.tv_sec = buf->st_birthtim.tv_sec;
tbuf.stx_btime.tv_nsec = buf->st_birthtim.tv_nsec;
tbuf.stx_ctime.tv_sec = buf->st_ctim.tv_sec;
tbuf.stx_ctime.tv_nsec = buf->st_ctim.tv_nsec;
tbuf.stx_mtime.tv_sec = buf->st_mtim.tv_sec;
tbuf.stx_mtime.tv_nsec = buf->st_mtim.tv_nsec;
tbuf.stx_rdev_major = buf->st_rdev >> 8;
tbuf.stx_rdev_minor = buf->st_rdev & 0xff;
tbuf.stx_dev_major = buf->st_dev >> 8;
tbuf.stx_dev_minor = buf->st_dev & 0xff;
return (copyout(&tbuf, ubuf, sizeof(tbuf)));
}
int
linux_statx(struct thread *td, struct linux_statx_args *args)
{