This takes both input and output as pointer arguments to avoid copying large structs.
(t *kernel.Task, statx *linux.Statx, stat *linux.Stat)
| 26 | // This takes both input and output as pointer arguments to avoid copying large |
| 27 | // structs. |
| 28 | func convertStatxToUserStat(t *kernel.Task, statx *linux.Statx, stat *linux.Stat) { |
| 29 | // Linux just copies fields from struct kstat without regard to struct |
| 30 | // kstat::result_mask (fs/stat.c:cp_new_stat()), so we do too. |
| 31 | userns := t.UserNamespace() |
| 32 | *stat = linux.Stat{ |
| 33 | Dev: uint64(linux.MakeDeviceID(uint16(statx.DevMajor), statx.DevMinor)), |
| 34 | Ino: statx.Ino, |
| 35 | Nlink: uint32(statx.Nlink), |
| 36 | Mode: uint32(statx.Mode), |
| 37 | UID: uint32(auth.KUID(statx.UID).In(userns).OrOverflow()), |
| 38 | GID: uint32(auth.KGID(statx.GID).In(userns).OrOverflow()), |
| 39 | Rdev: uint64(linux.MakeDeviceID(uint16(statx.RdevMajor), statx.RdevMinor)), |
| 40 | Size: int64(statx.Size), |
| 41 | Blksize: int32(statx.Blksize), |
| 42 | Blocks: int64(statx.Blocks), |
| 43 | ATime: timespecFromStatxTimestamp(statx.Atime), |
| 44 | MTime: timespecFromStatxTimestamp(statx.Mtime), |
| 45 | CTime: timespecFromStatxTimestamp(statx.Ctime), |
| 46 | } |
| 47 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…