|
Lines 52-57
Link Here
|
| 52 |
#include <sys/resourcevar.h> |
52 |
#include <sys/resourcevar.h> |
| 53 |
#include <sys/resource.h> |
53 |
#include <sys/resource.h> |
| 54 |
#include <sys/types.h> |
54 |
#include <sys/types.h> |
|
|
55 |
#include <sys/malloc.h> |
| 55 |
#include <miscfs/procfs/procfs.h> |
56 |
#include <miscfs/procfs/procfs.h> |
| 56 |
|
57 |
|
| 57 |
|
58 |
|
|
Lines 66-106
Link Here
|
| 66 |
int i; |
67 |
int i; |
| 67 |
int xlen; |
68 |
int xlen; |
| 68 |
int error; |
69 |
int error; |
| 69 |
char psbuf[512]; /* XXX - conservative */ |
70 |
char *psbuf; |
| 70 |
|
71 |
|
| 71 |
if (uio->uio_rw != UIO_READ) |
72 |
if (uio->uio_rw != UIO_READ) |
| 72 |
return (EOPNOTSUPP); |
73 |
return (EOPNOTSUPP); |
| 73 |
|
74 |
psbuf = (char *)malloc(512 * sizeof(char), M_TEMP, M_WAITOK); |
| 74 |
|
75 |
/* XXX conservative, but potentially overflowable */ |
| 75 |
ps = psbuf; |
76 |
ps = psbuf; |
| 76 |
|
|
|
| 77 |
for (i = 0; i < RLIM_NLIMITS; i++) { |
77 |
for (i = 0; i < RLIM_NLIMITS; i++) { |
| 78 |
|
78 |
/* Add the rlimit ident */ |
| 79 |
/* |
|
|
| 80 |
* Add the rlimit ident |
| 81 |
*/ |
| 82 |
|
| 83 |
ps += sprintf(ps, "%s ", rlimit_ident[i]); |
79 |
ps += sprintf(ps, "%s ", rlimit_ident[i]); |
| 84 |
|
80 |
/* Replace RLIM_INFINITY with -1 in the string */ |
| 85 |
/* |
81 |
/* current limit */ |
| 86 |
* Replace RLIM_INFINITY with -1 in the string |
|
|
| 87 |
*/ |
| 88 |
|
| 89 |
/* |
| 90 |
* current limit |
| 91 |
*/ |
| 92 |
|
| 93 |
if (p->p_rlimit[i].rlim_cur == RLIM_INFINITY) { |
82 |
if (p->p_rlimit[i].rlim_cur == RLIM_INFINITY) { |
| 94 |
ps += sprintf(ps, "-1 "); |
83 |
ps += sprintf(ps, "-1 "); |
| 95 |
} else { |
84 |
} else { |
| 96 |
ps += sprintf(ps, "%llu ", |
85 |
ps += sprintf(ps, "%llu ", |
| 97 |
(unsigned long long)p->p_rlimit[i].rlim_cur); |
86 |
(unsigned long long)p->p_rlimit[i].rlim_cur); |
| 98 |
} |
87 |
} |
| 99 |
|
88 |
/* maximum limit */ |
| 100 |
/* |
|
|
| 101 |
* maximum limit |
| 102 |
*/ |
| 103 |
|
| 104 |
if (p->p_rlimit[i].rlim_max == RLIM_INFINITY) { |
89 |
if (p->p_rlimit[i].rlim_max == RLIM_INFINITY) { |
| 105 |
ps += sprintf(ps, "-1\n"); |
90 |
ps += sprintf(ps, "-1\n"); |
| 106 |
} else { |
91 |
} else { |
|
Lines 108-119
Link Here
|
| 108 |
(unsigned long long)p->p_rlimit[i].rlim_max); |
93 |
(unsigned long long)p->p_rlimit[i].rlim_max); |
| 109 |
} |
94 |
} |
| 110 |
} |
95 |
} |
| 111 |
|
|
|
| 112 |
/* |
96 |
/* |
| 113 |
* This logic is rather tasty - but its from procfs_status.c, so |
97 |
* This logic is rather tasty - but its from procfs_status.c, so |
| 114 |
* I guess I'll use it here. |
98 |
* I guess I'll use it here. |
| 115 |
*/ |
99 |
*/ |
| 116 |
|
|
|
| 117 |
xlen = ps - psbuf; |
100 |
xlen = ps - psbuf; |
| 118 |
xlen -= uio->uio_offset; |
101 |
xlen -= uio->uio_offset; |
| 119 |
ps = psbuf + uio->uio_offset; |
102 |
ps = psbuf + uio->uio_offset; |
|
Lines 122-128
Link Here
|
| 122 |
error = 0; |
105 |
error = 0; |
| 123 |
else |
106 |
else |
| 124 |
error = uiomove(ps, xlen, uio); |
107 |
error = uiomove(ps, xlen, uio); |
| 125 |
|
108 |
free(psbuf, M_TEMP); |
| 126 |
return (error); |
109 |
return (error); |
| 127 |
} |
110 |
} |