[CRIU] [RFC] criu: Drop prlimit compat layer
Pavel Emelyanov
xemul at virtuozzo.com
Mon Apr 4 06:23:06 PDT 2016
> -int prlimit(pid_t pid, int resource, const struct rlimit *new_rlimit, struct rlimit *old_rlimit)
> -{
> - struct rlimit64 new_rlimit64_mem;
> - struct rlimit64 old_rlimit64_mem;
> - struct rlimit64 *new_rlimit64 = NULL;
> - struct rlimit64 *old_rlimit64 = NULL;
> - int ret;
> -
> - if (old_rlimit)
> - old_rlimit64 = &old_rlimit64_mem;
> -
> - if (new_rlimit) {
> - if (new_rlimit->rlim_cur == RLIM_INFINITY)
> - new_rlimit64_mem.rlim_cur = RLIM64_INFINITY;
> - else
> - new_rlimit64_mem.rlim_cur = new_rlimit->rlim_cur;
> - if (new_rlimit->rlim_max == RLIM_INFINITY)
> - new_rlimit64_mem.rlim_max = RLIM64_INFINITY;
> - else
> - new_rlimit64_mem.rlim_max = new_rlimit->rlim_max;
> - new_rlimit64 = &new_rlimit64_mem;
> - }
You've killed the conversions we did for INIFINITY values. Changing struct rlimit
to struct rlimit64 works only for 64 bit platforms.
> -
> - ret = sys_prlimit64(pid, resource, new_rlimit64, old_rlimit64);
> -
> - if (ret == 0 && old_rlimit) {
> - old_rlimit->rlim_cur = old_rlimit64_mem.rlim_cur;
> - if (old_rlimit->rlim_cur != old_rlimit64_mem.rlim_cur) {
> - if (new_rlimit) {
> - errno = EOVERFLOW;
> - return -1;
> - }
> - old_rlimit->rlim_cur = RLIM_INFINITY;
> - }
> - old_rlimit->rlim_max = old_rlimit64_mem.rlim_max;
> - if (old_rlimit->rlim_max != old_rlimit64_mem.rlim_max) {
> - if (new_rlimit) {
> - errno = EOVERFLOW;
> - return -1;
> - }
> - old_rlimit->rlim_max = RLIM_INFINITY;
> - }
> - } else if (ret) {
> - errno = -ret;
> - ret = -1;
> - }
> -
> - return ret;
> -}
> -
More information about the CRIU
mailing list