aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@redhat.com>2009-06-16 16:07:46 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-16 17:19:00 -0400
commit2f38d70fb4e97e7d00e12eaac45790cf6ebd7b22 (patch)
tree393a604669640635a33c1db179bd053d8b923252 /fs
parentb3fec0fe35a4ff048484f1408385a27695d4273b (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.c17
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
200static void f_modown(struct file *filp, struct pid *pid, enum pid_type type, 200static 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,
214int __f_setown(struct file *filp, struct pid *pid, enum pid_type type, 218int __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}
227EXPORT_SYMBOL(__f_setown); 230EXPORT_SYMBOL(__f_setown);
@@ -247,7 +250,7 @@ EXPORT_SYMBOL(f_setown);
247 250
248void f_delown(struct file *filp) 251void 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
253pid_t f_getown(struct file *filp) 256pid_t f_getown(struct file *filp)