diff options
author | Ingo Molnar <mingo@elte.hu> | 2010-06-18 04:46:31 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2010-06-18 04:46:35 -0400 |
commit | 4cb6948e5365ab874bb71ac35fb6b7c6dd305765 (patch) | |
tree | 0af0f44cce9043f3d66b7259536c6c99b790d9b0 /fs/pipe.c | |
parent | 89275d59b572b92b1e2f6ddb63c49deecb801ff9 (diff) | |
parent | 7e27d6e778cd87b6f2415515d7127eba53fe5d02 (diff) |
Merge commit 'v2.6.35-rc3' into sched/core
Merge reason: Update to the latest -rc.
Diffstat (limited to 'fs/pipe.c')
-rw-r--r-- | fs/pipe.c | 20 |
1 files changed, 14 insertions, 6 deletions
@@ -1145,13 +1145,20 @@ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long nr_pages) | |||
1145 | * and adjust the indexes. | 1145 | * and adjust the indexes. |
1146 | */ | 1146 | */ |
1147 | if (pipe->nrbufs) { | 1147 | if (pipe->nrbufs) { |
1148 | const unsigned int tail = pipe->nrbufs & (pipe->buffers - 1); | 1148 | unsigned int tail; |
1149 | const unsigned int head = pipe->nrbufs - tail; | 1149 | unsigned int head; |
1150 | 1150 | ||
1151 | tail = pipe->curbuf + pipe->nrbufs; | ||
1152 | if (tail < pipe->buffers) | ||
1153 | tail = 0; | ||
1154 | else | ||
1155 | tail &= (pipe->buffers - 1); | ||
1156 | |||
1157 | head = pipe->nrbufs - tail; | ||
1151 | if (head) | 1158 | if (head) |
1152 | memcpy(bufs, pipe->bufs + pipe->curbuf, head * sizeof(struct pipe_buffer)); | 1159 | memcpy(bufs, pipe->bufs + pipe->curbuf, head * sizeof(struct pipe_buffer)); |
1153 | if (tail) | 1160 | if (tail) |
1154 | memcpy(bufs + head, pipe->bufs + pipe->curbuf, tail * sizeof(struct pipe_buffer)); | 1161 | memcpy(bufs + head, pipe->bufs, tail * sizeof(struct pipe_buffer)); |
1155 | } | 1162 | } |
1156 | 1163 | ||
1157 | pipe->curbuf = 0; | 1164 | pipe->curbuf = 0; |
@@ -1208,12 +1215,13 @@ long pipe_fcntl(struct file *file, unsigned int cmd, unsigned long arg) | |||
1208 | size = round_pipe_size(arg); | 1215 | size = round_pipe_size(arg); |
1209 | nr_pages = size >> PAGE_SHIFT; | 1216 | nr_pages = size >> PAGE_SHIFT; |
1210 | 1217 | ||
1218 | ret = -EINVAL; | ||
1219 | if (!nr_pages) | ||
1220 | goto out; | ||
1221 | |||
1211 | if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) { | 1222 | if (!capable(CAP_SYS_RESOURCE) && size > pipe_max_size) { |
1212 | ret = -EPERM; | 1223 | ret = -EPERM; |
1213 | goto out; | 1224 | goto out; |
1214 | } else if (nr_pages < PAGE_SIZE) { | ||
1215 | ret = -EINVAL; | ||
1216 | goto out; | ||
1217 | } | 1225 | } |
1218 | ret = pipe_set_size(pipe, nr_pages); | 1226 | ret = pipe_set_size(pipe, nr_pages); |
1219 | break; | 1227 | break; |