Commit 864bdb3b6cbd9911222543fef1cfe36f88183f44
1 parent
2be7fd55d4
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
new helper: daemonize_descriptors()
descriptor-related parts of daemonize, done right. As the result we simplify the locking rules for ->files - we hold task_lock in *all* cases when we modify ->files. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Showing 3 changed files with 8 additions and 3 deletions Side-by-side Diff
fs/file.c
... | ... | @@ -519,6 +519,12 @@ |
519 | 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 | + | |
522 | 528 | /* |
523 | 529 | * allocate a file descriptor, mark it busy. |
524 | 530 | */ |
include/linux/fdtable.h
... | ... | @@ -95,6 +95,7 @@ |
95 | 95 | struct files_struct *get_files_struct(struct task_struct *); |
96 | 96 | void put_files_struct(struct files_struct *fs); |
97 | 97 | void reset_files_struct(struct files_struct *); |
98 | +void daemonize_descriptors(void); | |
98 | 99 | int unshare_files(struct files_struct **); |
99 | 100 | struct files_struct *dup_fd(struct files_struct *, int *); |
100 | 101 | void do_close_on_exec(struct files_struct *); |
kernel/exit.c
... | ... | @@ -457,9 +457,7 @@ |
457 | 457 | /* Become as one with the init task */ |
458 | 458 | |
459 | 459 | daemonize_fs_struct(); |
460 | - exit_files(current); | |
461 | - current->files = init_task.files; | |
462 | - atomic_inc(¤t->files->count); | |
460 | + daemonize_descriptors(); | |
463 | 461 | |
464 | 462 | reparent_to_kthreadd(); |
465 | 463 | } |