Revision e22b7015

b/linux-user/syscall.c
960 960
    return result;
961 961
}
962 962

  
963
static inline int target_to_host_resource(int code)
964
{
965
    switch (code) {
966
    case TARGET_RLIMIT_AS:
967
        return RLIMIT_AS;
968
    case TARGET_RLIMIT_CORE:
969
        return RLIMIT_CORE;
970
    case TARGET_RLIMIT_CPU:
971
        return RLIMIT_CPU;
972
    case TARGET_RLIMIT_DATA:
973
        return RLIMIT_DATA;
974
    case TARGET_RLIMIT_FSIZE:
975
        return RLIMIT_FSIZE;
976
    case TARGET_RLIMIT_LOCKS:
977
        return RLIMIT_LOCKS;
978
    case TARGET_RLIMIT_MEMLOCK:
979
        return RLIMIT_MEMLOCK;
980
    case TARGET_RLIMIT_MSGQUEUE:
981
        return RLIMIT_MSGQUEUE;
982
    case TARGET_RLIMIT_NICE:
983
        return RLIMIT_NICE;
984
    case TARGET_RLIMIT_NOFILE:
985
        return RLIMIT_NOFILE;
986
    case TARGET_RLIMIT_NPROC:
987
        return RLIMIT_NPROC;
988
    case TARGET_RLIMIT_RSS:
989
        return RLIMIT_RSS;
990
    case TARGET_RLIMIT_RTPRIO:
991
        return RLIMIT_RTPRIO;
992
    case TARGET_RLIMIT_SIGPENDING:
993
        return RLIMIT_SIGPENDING;
994
    case TARGET_RLIMIT_STACK:
995
        return RLIMIT_STACK;
996
    default:
997
        return code;
998
    }
999
}
1000

  
963 1001
static inline abi_long copy_from_user_timeval(struct timeval *tv,
964 1002
                                              abi_ulong target_tv_addr)
965 1003
{
......
5570 5608
        break;
5571 5609
    case TARGET_NR_setrlimit:
5572 5610
        {
5573
            int resource = arg1;
5611
            int resource = target_to_host_resource(arg1);
5574 5612
            struct target_rlimit *target_rlim;
5575 5613
            struct rlimit rlim;
5576 5614
            if (!lock_user_struct(VERIFY_READ, target_rlim, arg2, 1))
......
5583 5621
        break;
5584 5622
    case TARGET_NR_getrlimit:
5585 5623
        {
5586
            int resource = arg1;
5624
            int resource = target_to_host_resource(arg1);
5587 5625
            struct target_rlimit *target_rlim;
5588 5626
            struct rlimit rlim;
5589 5627

  
......
6892 6930
    case TARGET_NR_ugetrlimit:
6893 6931
    {
6894 6932
	struct rlimit rlim;
6895
	ret = get_errno(getrlimit(arg1, &rlim));
6933
	int resource = target_to_host_resource(arg1);
6934
	ret = get_errno(getrlimit(resource, &rlim));
6896 6935
	if (!is_error(ret)) {
6897 6936
	    struct target_rlimit *target_rlim;
6898 6937
            if (!lock_user_struct(VERIFY_WRITE, target_rlim, arg2, 0))
b/linux-user/syscall_defs.h
693 693
#define TARGET_RLIM_INFINITY	((target_ulong)~0UL)
694 694
#endif
695 695

  
696
#if defined(TARGET_MIPS)
697
#define TARGET_RLIMIT_CPU		0
698
#define TARGET_RLIMIT_FSIZE		1
699
#define TARGET_RLIMIT_DATA		2
700
#define TARGET_RLIMIT_STACK		3
701
#define TARGET_RLIMIT_CORE		4
702
#define TARGET_RLIMIT_RSS		7
703
#define TARGET_RLIMIT_NPROC		8
704
#define TARGET_RLIMIT_NOFILE		5
705
#define TARGET_RLIMIT_MEMLOCK		9
706
#define TARGET_RLIMIT_AS		6
707
#define TARGET_RLIMIT_LOCKS		10
708
#define TARGET_RLIMIT_SIGPENDING	11
709
#define TARGET_RLIMIT_MSGQUEUE		12
710
#define TARGET_RLIMIT_NICE		13
711
#define TARGET_RLIMIT_RTPRIO		14
712
#else
713
#define TARGET_RLIMIT_CPU		0
714
#define TARGET_RLIMIT_FSIZE		1
715
#define TARGET_RLIMIT_DATA		2
716
#define TARGET_RLIMIT_STACK		3
717
#define TARGET_RLIMIT_CORE		4
718
#define TARGET_RLIMIT_RSS		5
719
#define TARGET_RLIMIT_NPROC		6
720
#define TARGET_RLIMIT_NOFILE		7
721
#define TARGET_RLIMIT_MEMLOCK		8
722
#define TARGET_RLIMIT_AS		9
723
#define TARGET_RLIMIT_LOCKS		10
724
#define TARGET_RLIMIT_SIGPENDING	11
725
#define TARGET_RLIMIT_MSGQUEUE		12
726
#define TARGET_RLIMIT_NICE		13
727
#define TARGET_RLIMIT_RTPRIO		14
728
#endif
729

  
696 730
struct target_pollfd {
697 731
    int fd;           /* file descriptor */
698 732
    short events;     /* requested events */

Also available in: Unified diff