add stat->st_mode h2t conversion

This commit is contained in:
tehzz 2020-05-15 16:44:27 -04:00
parent eda897279a
commit 113271122f
2 changed files with 79 additions and 3 deletions

View File

@ -7219,11 +7219,46 @@ static inline int target_to_host_mlockall_arg(int arg)
}
#endif
static const bitmask_transtbl st_mode_tlb[] = {
{ TARGET_S_IFMT, TARGET_S_IFIFO, S_IFMT, S_IFIFO },
{ TARGET_S_IFMT, TARGET_S_IFCHR, S_IFMT, S_IFCHR },
{ TARGET_S_IFMT, TARGET_S_IFDIR, S_IFMT, S_IFDIR },
{ TARGET_S_IFMT, TARGET_S_IFBLK, S_IFMT, S_IFBLK },
{ TARGET_S_IFMT, TARGET_S_IFREG, S_IFMT, S_IFREG },
{ TARGET_S_IFMT, TARGET_S_IFLNK, S_IFMT, S_IFLNK },
{ TARGET_S_IFMT, TARGET_S_IFSOCK, S_IFMT, S_IFSOCK },
#ifdef S_IFNAM
{ TARGET_S_IFMT, TARGET_S_IFNAM, S_IFMT, S_IFNAM },
#endif
{ TARGET_S_ISUID, TARGET_S_ISUID, S_ISUID, S_ISUID },
{ TARGET_S_ISGID, TARGET_S_ISGID, S_ISGID, S_ISGID },
{ TARGET_S_ISVTX, TARGET_S_ISVTX, S_ISVTX, S_ISVTX },
{ TARGET_S_IREAD, TARGET_S_IREAD, S_IREAD, S_IREAD },
{ TARGET_S_IWRITE, TARGET_S_IWRITE, S_IWRITE, S_IWRITE },
{ TARGET_S_IEXEC, TARGET_S_IEXEC, S_IEXEC, S_IEXEC },
{ TARGET_S_ENFMT, TARGET_S_ENFMT, S_ISGID, S_ISGID },
{ TARGET_S_IRWXU, TARGET_S_IRWXU, S_IRWXU, S_IRWXU },
{ TARGET_S_IRWXU, TARGET_S_IRUSR, S_IRWXU, S_IRUSR },
{ TARGET_S_IRWXU, TARGET_S_IWUSR, S_IRWXU, S_IWUSR },
{ TARGET_S_IRWXU, TARGET_S_IXUSR, S_IRWXU, S_IXUSR },
{ TARGET_S_IRWXG, TARGET_S_IRWXG, S_IRWXG, S_IRWXG },
{ TARGET_S_IRWXG, TARGET_S_IRGRP, S_IRWXG, S_IRGRP },
{ TARGET_S_IRWXG, TARGET_S_IWGRP, S_IRWXG, S_IWGRP },
{ TARGET_S_IRWXG, TARGET_S_IXGRP, S_IRWXG, S_IXGRP },
{ TARGET_S_IRWXO, TARGET_S_IRWXO, S_IRWXO, S_IRWXO },
{ TARGET_S_IRWXO, TARGET_S_IROTH, S_IRWXO, S_IROTH },
{ TARGET_S_IRWXO, TARGET_S_IWOTH, S_IRWXO, S_IWOTH },
{ TARGET_S_IRWXO, TARGET_S_IXOTH, S_IRWXO, S_IXOTH },
{ 0, 0, 0, 0 },
};
static inline abi_long host_to_target_stat(void *cpu_env,
abi_ulong target_addr,
struct stat *host_st)
{
struct target_stat *target_st;
int cnvt_st_mode = host_to_target_bitmask(host_st->st_mode, st_mode_tlb);
if (!lock_user_struct(VERIFY_WRITE, target_st, target_addr, 0))
return -TARGET_EFAULT;
@ -7235,7 +7270,7 @@ static inline abi_long host_to_target_stat(void *cpu_env,
#endif
__put_user(host_st->st_dev, &target_st->st_dev);
__put_user(host_st->st_ino, &target_st->st_ino);
__put_user(host_st->st_mode, &target_st->st_mode);
__put_user(cnvt_st_mode, &target_st->st_mode);
__put_user(host_st->st_uid, &target_st->st_uid);
__put_user(host_st->st_gid, &target_st->st_gid);
__put_user(host_st->st_nlink, &target_st->st_nlink);

View File

@ -1929,7 +1929,7 @@ struct target_stat {
uint32_t st_rdev;
abi_long st_pad1[2]; /* Reserved for st_rdev expansion */
abi_long st_size;
abi_long st_pad2;
abi_long st_pad2;
/*
* Actually this should be timestruc_t st_atime, st_mtime and st_ctime
@ -1944,7 +1944,7 @@ struct target_stat {
int32_t target_st_ctime;
abi_long target_st_ctime_nsec;
abi_long st_blksize;
abi_long st_blksize;
abi_long st_blocks;
char st_fstype[16];
abi_long st_projid;
@ -3451,4 +3451,45 @@ struct target_prthread {
#define TARGET_PC_SYNC_IO 10
#endif
/* stat st_mode flags */
#ifdef TARGET_ABI_IRIX
/* masks */
#define TARGET_S_IFMT 0xF000 /* type of file */
#define TARGET_S_IAMB 0x1FF /* access mode bits */
#define TARGET_S_IFIFO 0x1000 /* fifo */
#define TARGET_S_IFCHR 0x2000 /* character special */
#define TARGET_S_IFDIR 0x4000 /* directory */
#define TARGET_S_IFNAM 0x5000 /* XENIX special named file */
#define TARGET_S_INSEM 0x1 /* XENIX semaphore subtype of IFNAM */
#define TARGET_S_INSHD 0x2 /* XENIX shared data subtype of IFNAM */
#define TARGET_S_IFBLK 0x6000 /* block special */
#define TARGET_S_IFREG 0x8000 /* regular */
#define TARGET_S_IFLNK 0xA000 /* symbolic link */
#define TARGET_S_IFSOCK 0xC000 /* socket */
#define TARGET_S_ISUID 0x800 /* set user id on execution */
#define TARGET_S_ISGID 0x400 /* set group id on execution */
#define TARGET_S_ISVTX 0x200 /* save swapped text even after use */
#define TARGET_S_IREAD 00400 /* read permission, owner */
#define TARGET_S_IWRITE 00200 /* write permission, owner */
#define TARGET_S_IEXEC 00100 /* execute/search permission, owner */
#define TARGET_S_ENFMT S_ISGID /* record locking enforcement flag */
#define TARGET_S_IRWXU 00700 /* read, write, execute: owner */
#define TARGET_S_IRUSR 00400 /* read permission: owner */
#define TARGET_S_IWUSR 00200 /* write permission: owner */
#define TARGET_S_IXUSR 00100 /* execute permission: owner */
#define TARGET_S_IRWXG 00070 /* read, write, execute: group */
#define TARGET_S_IRGRP 00040 /* read permission: group */
#define TARGET_S_IWGRP 00020 /* write permission: group */
#define TARGET_S_IXGRP 00010 /* execute permission: group */
#define TARGET_S_IRWXO 00007 /* read, write, execute: other */
#define TARGET_S_IROTH 00004 /* read permission: other */
#define TARGET_S_IWOTH 00002 /* write permission: other */
#define TARGET_S_IXOTH 00001 /* execute permission: other */
#endif /* TARGET_ABI_IRIX */
#endif