aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/power/process.c
Commit message (Expand)AuthorAge
* oom: move oom_killer_enable()/oom_killer_disable to where they belongAlexey Dobriyan2009-09-22
* mm, PM/Freezer: Disable OOM killer when tasks are frozenRafael J. Wysocki2009-06-16
* container freezer: skip frozen cgroups during power management resumeMatt Helsley2008-10-20
* container freezer: make refrigerator always availableMatt Helsley2008-10-20
* pm: fix try_to_freeze_tasks()'s use of do_div()David Howells2008-07-24
* Freezer: Introduce PF_FREEZER_NOSIGRafael J. Wysocki2008-07-16
* freezer vs stopped or tracedRoland McGrath2008-03-04
* power: Use task_is_*Matthew Wilcox2007-12-06
* freezer: measure freezing timeRafael J. Wysocki2007-10-18
* freezer: be more verboseRafael J. Wysocki2007-10-18
* freezer: do not send signals to kernel threadsRafael J. Wysocki2007-10-18
* freezer: do not sync filesystems from freeze_processesRafael J. Wysocki2007-10-18
* Freezer: remove redundant check in try_to_freeze_tasksRafael J. Wysocki2007-07-19
* Freezer: return int from freeze_processesRafael J. Wysocki2007-07-19
* Freezer: use __set_current_state in refrigeratorRafael J. Wysocki2007-07-19
* Freezer: avoid freezing kernel threads prematurelyRafael J. Wysocki2007-07-19
* freezer: run show_state() when freezing times outAndrew Morton2007-07-19
* recalc_sigpending_tsk fixesRoland McGrath2007-05-23
* freezer: move frozen_process() to kernel/power/process.cGautham R Shenoy2007-05-23
* freezer: take kernel_execve into considerationRafael J. Wysocki2007-05-23
* freezer: fix vfork problemRafael J. Wysocki2007-05-23
* freezer: close potential race between refrigerator and thaw_tasksRafael J. Wysocki2007-05-23
* header cleaning: don't include smp_lock.h when not usedRandy Dunlap2007-05-08
* freezer: task->exit_state should be treated as boleanOleg Nesterov2007-05-08
* fix refrigerator() vs thaw_process() raceOleg Nesterov2007-05-07
* [PATCH] PM: Fix SMP races in the freezerRafael J. Wysocki2006-12-13
* [PATCH] PM: Fix freezing of stopped tasksRafael J. Wysocki2006-12-13
* [PATCH] swsusp: Untangle freeze_processesRafael J. Wysocki2006-12-07
* [PATCH] swsusp: Untangle thaw_processesRafael J. Wysocki2006-12-07
* [PATCH] suspend to disk fails if gdb is suspended with a traced childRafael J. Wysocki2006-12-07
* [PATCH] swsusp: thaw userspace and kernel space separatelyNigel Cunningham2006-12-07
* [PATCH] swsusp: clean up whitespace in freezer outputNigel Cunningham2006-12-07
* [PATCH] swsusp: quieten Freezer if !CONFIG_PM_DEBUGNigel Cunningham2006-12-07
* [PATCH] Add include/linux/freezer.h and move definitions from sched.hNigel Cunningham2006-12-07
* [PATCH] Make suspend possible with a traced process at a breakpointRafael J. Wysocki2006-08-06
* [PATCH] Fix suspend with traced tasksPavel Machek2006-03-31
* [PATCH] swsusp: freeze user space processes firstRafael J. Wysocki2006-03-23
* [PATCH] swsusp: documentation updatesPavel Machek2006-03-23
* [PATCH] pm: fix process freezingPavel Machek2005-09-05
* [PATCH] remove busywait in refrigeratorPavel Machek2005-09-05
* [PATCH] pm: clean up process.cPavel Machek2005-07-07
* [PATCH] Cleanup patch for process freezingChristoph Lameter2005-06-25
* Linux-2.6.12-rc2v2.6.12-rc2Linus Torvalds2005-04-16
committer Al Viro <viro@zeniv.linux.org.uk> 2009-03-31 23:00:26 -0400 Take fs_struct handling to new file (fs/fs_struct.c)' href='/cgit/cgit.cgi/litmus-rt-edfsc.git/commit/fs/fs_struct.c?h=linux-4.9-litmus&id=3e93cd671813e204c258f1e6c797959920cf7772'>3e93cd671813
498052bba55e





3e93cd671813
2a4419b5b2a7
498052bba55e
2a4419b5b2a7
498052bba55e
2a4419b5b2a7
498052bba55e

2a4419b5b2a7
498052bba55e




3e93cd671813
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172




                         
                            








                                                                        
                             


                            
                               











                                                                      
                             


                          
                               















                                                                 
                                             











                                                               
                                               







                                    
                                         
 


                                       



                                     
                                       

                 
                         
                               
                                     
                               
                                    
                                       
                                 

                                           







                                                                       

                                
                                          
                                       
                                                              





                           




                                                      
                               

                           
                             

                             
                               




                                   



                                     





                                  

                                       
                            
                                                             




                               





                                           
 
                                         
                                
                                           
 
                                     

                                       
                                       




                                           
 
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/fs.h>
#include <linux/path.h>
#include <linux/slab.h>
#include <linux/fs_struct.h>

/*
 * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
 * It can block.
 */
void set_fs_root(struct fs_struct *fs, struct path *path)
{
	struct path old_root;

	spin_lock(&fs->lock);
	old_root = fs->root;
	fs->root = *path;
	path_get(path);
	spin_unlock(&fs->lock);
	if (old_root.dentry)
		path_put(&old_root);
}

/*
 * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
 * It can block.
 */
void set_fs_pwd(struct fs_struct *fs, struct path *path)
{
	struct path old_pwd;

	spin_lock(&fs->lock);
	old_pwd = fs->pwd;
	fs->pwd = *path;
	path_get(path);
	spin_unlock(&fs->lock);

	if (old_pwd.dentry)
		path_put(&old_pwd);
}

void chroot_fs_refs(struct path *old_root, struct path *new_root)
{
	struct task_struct *g, *p;
	struct fs_struct *fs;
	int count = 0;

	read_lock(&tasklist_lock);
	do_each_thread(g, p) {
		task_lock(p);
		fs = p->fs;
		if (fs) {
			spin_lock(&fs->lock);
			if (fs->root.dentry == old_root->dentry
			    && fs->root.mnt == old_root->mnt) {
				path_get(new_root);
				fs->root = *new_root;
				count++;
			}
			if (fs->pwd.dentry == old_root->dentry
			    && fs->pwd.mnt == old_root->mnt) {
				path_get(new_root);
				fs->pwd = *new_root;
				count++;
			}
			spin_unlock(&fs->lock);
		}
		task_unlock(p);
	} while_each_thread(g, p);
	read_unlock(&tasklist_lock);
	while (count--)
		path_put(old_root);
}

void free_fs_struct(struct fs_struct *fs)
{
	path_put(&fs->root);
	path_put(&fs->pwd);
	kmem_cache_free(fs_cachep, fs);
}

void exit_fs(struct task_struct *tsk)
{
	struct fs_struct *fs = tsk->fs;

	if (fs) {
		int kill;
		task_lock(tsk);
		spin_lock(&fs->lock);
		tsk->fs = NULL;
		kill = !--fs->users;
		spin_unlock(&fs->lock);
		task_unlock(tsk);
		if (kill)
			free_fs_struct(fs);
	}
}

struct fs_struct *copy_fs_struct(struct fs_struct *old)
{
	struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
	/* We don't need to lock fs - think why ;-) */
	if (fs) {
		fs->users = 1;
		fs->in_exec = 0;
		spin_lock_init(&fs->lock);
		fs->umask = old->umask;
		get_fs_root_and_pwd(old, &fs->root, &fs->pwd);
	}
	return fs;
}

int unshare_fs_struct(void)
{
	struct fs_struct *fs = current->fs;
	struct fs_struct *new_fs = copy_fs_struct(fs);
	int kill;

	if (!new_fs)
		return -ENOMEM;

	task_lock(current);
	spin_lock(&fs->lock);
	kill = !--fs->users;
	current->fs = new_fs;
	spin_unlock(&fs->lock);
	task_unlock(current);

	if (kill)
		free_fs_struct(fs);

	return 0;
}
EXPORT_SYMBOL_GPL(unshare_fs_struct);

int current_umask(void)
{
	return current->fs->umask;
}
EXPORT_SYMBOL(current_umask);

/* to be mentioned only in INIT_TASK */
struct fs_struct init_fs = {
	.users		= 1,
	.lock		= __SPIN_LOCK_UNLOCKED(init_fs.lock),
	.umask		= 0022,
};

void daemonize_fs_struct(void)
{
	struct fs_struct *fs = current->fs;

	if (fs) {
		int kill;

		task_lock(current);

		spin_lock(&init_fs.lock);
		init_fs.users++;
		spin_unlock(&init_fs.lock);

		spin_lock(&fs->lock);
		current->fs = &init_fs;
		kill = !--fs->users;
		spin_unlock(&fs->lock);

		task_unlock(current);
		if (kill)
			free_fs_struct(fs);
	}
}