Revision e22b7015 linux-user/syscall.c

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))

Also available in: Unified diff