diff options
author | Oleg Nesterov <oleg@redhat.com> | 2009-06-16 16:07:46 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-16 17:19:00 -0400 |
commit | 2f38d70fb4e97e7d00e12eaac45790cf6ebd7b22 (patch) | |
tree | 393a604669640635a33c1db179bd053d8b923252 /fs | |
parent | b3fec0fe35a4ff048484f1408385a27695d4273b (diff) |
shift current_cred() from __f_setown() to f_modown()
Shift current_cred() from __f_setown() to f_modown(). This reduces
the number of arguments and saves 48 bytes from fs/fcntl.o.
[ Note: this doesn't clear euid/uid when pid is set to NULL. But if
f_owner.pid == NULL we never use f_owner.uid/euid. Otherwise we'd
have a bug anyway: we must not send signals if pid was reset to NULL. ]
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/fcntl.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/fcntl.c b/fs/fcntl.c index 1ad703150dee..f9c03ca3b2f4 100644 --- a/fs/fcntl.c +++ b/fs/fcntl.c | |||
@@ -198,15 +198,19 @@ static int setfl(int fd, struct file * filp, unsigned long arg) | |||
198 | } | 198 | } |
199 | 199 | ||
200 | static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, | 200 | static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, |
201 | uid_t uid, uid_t euid, int force) | 201 | int force) |
202 | { | 202 | { |
203 | write_lock_irq(&filp->f_owner.lock); | 203 | write_lock_irq(&filp->f_owner.lock); |
204 | if (force || !filp->f_owner.pid) { | 204 | if (force || !filp->f_owner.pid) { |
205 | put_pid(filp->f_owner.pid); | 205 | put_pid(filp->f_owner.pid); |
206 | filp->f_owner.pid = get_pid(pid); | 206 | filp->f_owner.pid = get_pid(pid); |
207 | filp->f_owner.pid_type = type; | 207 | filp->f_owner.pid_type = type; |
208 | filp->f_owner.uid = uid; | 208 | |
209 | filp->f_owner.euid = euid; | 209 | if (pid) { |
210 | const struct cred *cred = current_cred(); | ||
211 | filp->f_owner.uid = cred->uid; | ||
212 | filp->f_owner.euid = cred->euid; | ||
213 | } | ||
210 | } | 214 | } |
211 | write_unlock_irq(&filp->f_owner.lock); | 215 | write_unlock_irq(&filp->f_owner.lock); |
212 | } | 216 | } |
@@ -214,14 +218,13 @@ static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, | |||
214 | int __f_setown(struct file *filp, struct pid *pid, enum pid_type type, | 218 | int __f_setown(struct file *filp, struct pid *pid, enum pid_type type, |
215 | int force) | 219 | int force) |
216 | { | 220 | { |
217 | const struct cred *cred = current_cred(); | ||
218 | int err; | 221 | int err; |
219 | 222 | ||
220 | err = security_file_set_fowner(filp); | 223 | err = security_file_set_fowner(filp); |
221 | if (err) | 224 | if (err) |
222 | return err; | 225 | return err; |
223 | 226 | ||
224 | f_modown(filp, pid, type, cred->uid, cred->euid, force); | 227 | f_modown(filp, pid, type, force); |
225 | return 0; | 228 | return 0; |
226 | } | 229 | } |
227 | EXPORT_SYMBOL(__f_setown); | 230 | EXPORT_SYMBOL(__f_setown); |
@@ -247,7 +250,7 @@ EXPORT_SYMBOL(f_setown); | |||
247 | 250 | ||
248 | void f_delown(struct file *filp) | 251 | void f_delown(struct file *filp) |
249 | { | 252 | { |
250 | f_modown(filp, NULL, PIDTYPE_PID, 0, 0, 1); | 253 | f_modown(filp, NULL, PIDTYPE_PID, 1); |
251 | } | 254 | } |
252 | 255 | ||
253 | pid_t f_getown(struct file *filp) | 256 | pid_t f_getown(struct file *filp) |