diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2012-10-02 16:34:38 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2012-11-28 21:49:02 -0500 |
commit | c4144670fd9b34d6eae22c9f83751745898e8243 (patch) | |
tree | da0bbda5707fafdc1d79eb2c851835c777182e89 | |
parent | 02232f8d2b22708f0651dc515544f4a7ef1e0224 (diff) |
kill daemonize()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | drivers/staging/gdm72xx/gdm_usb.c | 4 | ||||
-rw-r--r-- | fs/file.c | 6 | ||||
-rw-r--r-- | fs/fs_struct.c | 24 | ||||
-rw-r--r-- | include/linux/fdtable.h | 1 | ||||
-rw-r--r-- | include/linux/fs_struct.h | 1 | ||||
-rw-r--r-- | include/linux/sched.h | 1 | ||||
-rw-r--r-- | kernel/exit.c | 92 |
7 files changed, 1 insertions, 128 deletions
diff --git a/drivers/staging/gdm72xx/gdm_usb.c b/drivers/staging/gdm72xx/gdm_usb.c index 0c9e8958009b..39db582ab1a6 100644 --- a/drivers/staging/gdm72xx/gdm_usb.c +++ b/drivers/staging/gdm72xx/gdm_usb.c | |||
@@ -701,8 +701,6 @@ static int k_mode_thread(void *arg) | |||
701 | unsigned long flags, flags2, expire; | 701 | unsigned long flags, flags2, expire; |
702 | int ret; | 702 | int ret; |
703 | 703 | ||
704 | daemonize("k_mode_wimax"); | ||
705 | |||
706 | while (!k_mode_stop) { | 704 | while (!k_mode_stop) { |
707 | 705 | ||
708 | spin_lock_irqsave(&k_lock, flags2); | 706 | spin_lock_irqsave(&k_lock, flags2); |
@@ -764,7 +762,7 @@ static struct usb_driver gdm_usb_driver = { | |||
764 | static int __init usb_gdm_wimax_init(void) | 762 | static int __init usb_gdm_wimax_init(void) |
765 | { | 763 | { |
766 | #ifdef CONFIG_WIMAX_GDM72XX_K_MODE | 764 | #ifdef CONFIG_WIMAX_GDM72XX_K_MODE |
767 | kthread_run(k_mode_thread, NULL, "WiMax_thread"); | 765 | kthread_run(k_mode_thread, NULL, "k_mode_wimax"); |
768 | #endif /* CONFIG_WIMAX_GDM72XX_K_MODE */ | 766 | #endif /* CONFIG_WIMAX_GDM72XX_K_MODE */ |
769 | return usb_register(&gdm_usb_driver); | 767 | return usb_register(&gdm_usb_driver); |
770 | } | 768 | } |
@@ -519,12 +519,6 @@ struct files_struct init_files = { | |||
519 | .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), | 519 | .file_lock = __SPIN_LOCK_UNLOCKED(init_task.file_lock), |
520 | }; | 520 | }; |
521 | 521 | ||
522 | void daemonize_descriptors(void) | ||
523 | { | ||
524 | atomic_inc(&init_files.count); | ||
525 | reset_files_struct(&init_files); | ||
526 | } | ||
527 | |||
528 | /* | 522 | /* |
529 | * allocate a file descriptor, mark it busy. | 523 | * allocate a file descriptor, mark it busy. |
530 | */ | 524 | */ |
diff --git a/fs/fs_struct.c b/fs/fs_struct.c index 5df4775fea03..fe6ca583bbc0 100644 --- a/fs/fs_struct.c +++ b/fs/fs_struct.c | |||
@@ -164,27 +164,3 @@ struct fs_struct init_fs = { | |||
164 | .seq = SEQCNT_ZERO, | 164 | .seq = SEQCNT_ZERO, |
165 | .umask = 0022, | 165 | .umask = 0022, |
166 | }; | 166 | }; |
167 | |||
168 | void daemonize_fs_struct(void) | ||
169 | { | ||
170 | struct fs_struct *fs = current->fs; | ||
171 | |||
172 | if (fs) { | ||
173 | int kill; | ||
174 | |||
175 | task_lock(current); | ||
176 | |||
177 | spin_lock(&init_fs.lock); | ||
178 | init_fs.users++; | ||
179 | spin_unlock(&init_fs.lock); | ||
180 | |||
181 | spin_lock(&fs->lock); | ||
182 | current->fs = &init_fs; | ||
183 | kill = !--fs->users; | ||
184 | spin_unlock(&fs->lock); | ||
185 | |||
186 | task_unlock(current); | ||
187 | if (kill) | ||
188 | free_fs_struct(fs); | ||
189 | } | ||
190 | } | ||
diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h index 45052aa814c8..fb7dacae0522 100644 --- a/include/linux/fdtable.h +++ b/include/linux/fdtable.h | |||
@@ -95,7 +95,6 @@ struct task_struct; | |||
95 | struct files_struct *get_files_struct(struct task_struct *); | 95 | struct files_struct *get_files_struct(struct task_struct *); |
96 | void put_files_struct(struct files_struct *fs); | 96 | void put_files_struct(struct files_struct *fs); |
97 | void reset_files_struct(struct files_struct *); | 97 | void reset_files_struct(struct files_struct *); |
98 | void daemonize_descriptors(void); | ||
99 | int unshare_files(struct files_struct **); | 98 | int unshare_files(struct files_struct **); |
100 | struct files_struct *dup_fd(struct files_struct *, int *); | 99 | struct files_struct *dup_fd(struct files_struct *, int *); |
101 | void do_close_on_exec(struct files_struct *); | 100 | void do_close_on_exec(struct files_struct *); |
diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h index 003dc0fd7347..d0ae3a84bcfb 100644 --- a/include/linux/fs_struct.h +++ b/include/linux/fs_struct.h | |||
@@ -21,7 +21,6 @@ extern void set_fs_root(struct fs_struct *, struct path *); | |||
21 | extern void set_fs_pwd(struct fs_struct *, struct path *); | 21 | extern void set_fs_pwd(struct fs_struct *, struct path *); |
22 | extern struct fs_struct *copy_fs_struct(struct fs_struct *); | 22 | extern struct fs_struct *copy_fs_struct(struct fs_struct *); |
23 | extern void free_fs_struct(struct fs_struct *); | 23 | extern void free_fs_struct(struct fs_struct *); |
24 | extern void daemonize_fs_struct(void); | ||
25 | extern int unshare_fs_struct(void); | 24 | extern int unshare_fs_struct(void); |
26 | 25 | ||
27 | static inline void get_fs_root(struct fs_struct *fs, struct path *root) | 26 | static inline void get_fs_root(struct fs_struct *fs, struct path *root) |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 0dd42a02df2e..a0166481eb20 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -2283,7 +2283,6 @@ extern void flush_itimer_signals(void); | |||
2283 | 2283 | ||
2284 | extern void do_group_exit(int); | 2284 | extern void do_group_exit(int); |
2285 | 2285 | ||
2286 | extern void daemonize(const char *, ...); | ||
2287 | extern int allow_signal(int); | 2286 | extern int allow_signal(int); |
2288 | extern int disallow_signal(int); | 2287 | extern int disallow_signal(int); |
2289 | 2288 | ||
diff --git a/kernel/exit.c b/kernel/exit.c index 346616c0092c..f9275e2c7c2c 100644 --- a/kernel/exit.c +++ b/kernel/exit.c | |||
@@ -322,43 +322,6 @@ kill_orphaned_pgrp(struct task_struct *tsk, struct task_struct *parent) | |||
322 | } | 322 | } |
323 | } | 323 | } |
324 | 324 | ||
325 | /** | ||
326 | * reparent_to_kthreadd - Reparent the calling kernel thread to kthreadd | ||
327 | * | ||
328 | * If a kernel thread is launched as a result of a system call, or if | ||
329 | * it ever exits, it should generally reparent itself to kthreadd so it | ||
330 | * isn't in the way of other processes and is correctly cleaned up on exit. | ||
331 | * | ||
332 | * The various task state such as scheduling policy and priority may have | ||
333 | * been inherited from a user process, so we reset them to sane values here. | ||
334 | * | ||
335 | * NOTE that reparent_to_kthreadd() gives the caller full capabilities. | ||
336 | */ | ||
337 | static void reparent_to_kthreadd(void) | ||
338 | { | ||
339 | write_lock_irq(&tasklist_lock); | ||
340 | |||
341 | ptrace_unlink(current); | ||
342 | /* Reparent to init */ | ||
343 | current->real_parent = current->parent = kthreadd_task; | ||
344 | list_move_tail(¤t->sibling, ¤t->real_parent->children); | ||
345 | |||
346 | /* Set the exit signal to SIGCHLD so we signal init on exit */ | ||
347 | current->exit_signal = SIGCHLD; | ||
348 | |||
349 | if (task_nice(current) < 0) | ||
350 | set_user_nice(current, 0); | ||
351 | /* cpus_allowed? */ | ||
352 | /* rt_priority? */ | ||
353 | /* signals? */ | ||
354 | memcpy(current->signal->rlim, init_task.signal->rlim, | ||
355 | sizeof(current->signal->rlim)); | ||
356 | |||
357 | atomic_inc(&init_cred.usage); | ||
358 | commit_creds(&init_cred); | ||
359 | write_unlock_irq(&tasklist_lock); | ||
360 | } | ||
361 | |||
362 | void __set_special_pids(struct pid *pid) | 325 | void __set_special_pids(struct pid *pid) |
363 | { | 326 | { |
364 | struct task_struct *curr = current->group_leader; | 327 | struct task_struct *curr = current->group_leader; |
@@ -370,13 +333,6 @@ void __set_special_pids(struct pid *pid) | |||
370 | change_pid(curr, PIDTYPE_PGID, pid); | 333 | change_pid(curr, PIDTYPE_PGID, pid); |
371 | } | 334 | } |
372 | 335 | ||
373 | static void set_special_pids(struct pid *pid) | ||
374 | { | ||
375 | write_lock_irq(&tasklist_lock); | ||
376 | __set_special_pids(pid); | ||
377 | write_unlock_irq(&tasklist_lock); | ||
378 | } | ||
379 | |||
380 | /* | 336 | /* |
381 | * Let kernel threads use this to say that they allow a certain signal. | 337 | * Let kernel threads use this to say that they allow a certain signal. |
382 | * Must not be used if kthread was cloned with CLONE_SIGHAND. | 338 | * Must not be used if kthread was cloned with CLONE_SIGHAND. |
@@ -416,54 +372,6 @@ int disallow_signal(int sig) | |||
416 | 372 | ||
417 | EXPORT_SYMBOL(disallow_signal); | 373 | EXPORT_SYMBOL(disallow_signal); |
418 | 374 | ||
419 | /* | ||
420 | * Put all the gunge required to become a kernel thread without | ||
421 | * attached user resources in one place where it belongs. | ||
422 | */ | ||
423 | |||
424 | void daemonize(const char *name, ...) | ||
425 | { | ||
426 | va_list args; | ||
427 | sigset_t blocked; | ||
428 | |||
429 | va_start(args, name); | ||
430 | vsnprintf(current->comm, sizeof(current->comm), name, args); | ||
431 | va_end(args); | ||
432 | |||
433 | /* | ||
434 | * If we were started as result of loading a module, close all of the | ||
435 | * user space pages. We don't need them, and if we didn't close them | ||
436 | * they would be locked into memory. | ||
437 | */ | ||
438 | exit_mm(current); | ||
439 | /* | ||
440 | * We don't want to get frozen, in case system-wide hibernation | ||
441 | * or suspend transition begins right now. | ||
442 | */ | ||
443 | current->flags |= (PF_NOFREEZE | PF_KTHREAD); | ||
444 | |||
445 | if (current->nsproxy != &init_nsproxy) { | ||
446 | get_nsproxy(&init_nsproxy); | ||
447 | switch_task_namespaces(current, &init_nsproxy); | ||
448 | } | ||
449 | set_special_pids(&init_struct_pid); | ||
450 | proc_clear_tty(current); | ||
451 | |||
452 | /* Block and flush all signals */ | ||
453 | sigfillset(&blocked); | ||
454 | sigprocmask(SIG_BLOCK, &blocked, NULL); | ||
455 | flush_signals(current); | ||
456 | |||
457 | /* Become as one with the init task */ | ||
458 | |||
459 | daemonize_fs_struct(); | ||
460 | daemonize_descriptors(); | ||
461 | |||
462 | reparent_to_kthreadd(); | ||
463 | } | ||
464 | |||
465 | EXPORT_SYMBOL(daemonize); | ||
466 | |||
467 | #ifdef CONFIG_MM_OWNER | 375 | #ifdef CONFIG_MM_OWNER |
468 | /* | 376 | /* |
469 | * A task is exiting. If it owned this mm, find a new owner for the mm. | 377 | * A task is exiting. If it owned this mm, find a new owner for the mm. |