~ubuntu-branches/debian/jessie/systemd/jessie

« back to all changes in this revision

Viewing changes to src/cgroup-show.c

  • Committer: Package Import Robot
  • Author(s): Tollef Fog Heen, Tollef Fog Heen, Michael Biebl
  • Date: 2012-04-03 19:59:17 UTC
  • mfrom: (1.1.10) (6.1.3 experimental)
  • Revision ID: package-import@ubuntu.com-20120403195917-l532urrbg4pkreas
Tags: 44-1
[ Tollef Fog Heen ]
* New upstream version.
  - Backport 3492207: journal: PAGE_SIZE is not known on ppc and other
    archs
  - Backport 5a2a2a1: journal: react with immediate rotation to a couple
    of more errors
  - Backport 693ce21: util: never follow symlinks in rm_rf_children()
    Fixes CVE-2012-1174, closes: #664364
* Drop output message from init-functions hook, it's pointless.
* Only rmdir /lib/init/rw if it exists.
* Explicitly order debian-fixup before sysinit.target to prevent a
  possible race condition with the creation of sockets.  Thanks to
  Michael Biebl for debugging this.
* Always restart the initctl socket on upgrades, to mask sysvinit
  removing it.

[ Michael Biebl ]
* Remove workaround for non-interactive sessions from pam config again.
* Create compat /dev/initctl symlink in case we are upgrading from a system
  running a newer version of sysvinit (using /run/initctl) and sysvinit is
  replaced with systemd-sysv during the upgrade. Closes: #663219
* Install new man pages.
* Build-Depend on valac (>= 0.12) instead of valac-0.12. Closes: #663323

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        return n;
51
51
}
52
52
 
53
 
static int show_cgroup_one_by_path(const char *path, const char *prefix, unsigned n_columns, bool more) {
 
53
static int show_cgroup_one_by_path(const char *path, const char *prefix, unsigned n_columns, bool more, bool kernel_threads) {
54
54
        char *fn;
55
55
        FILE *f;
56
56
        size_t n = 0, n_allocated = 0;
82
82
 
83
83
        while ((r = cg_read_pid(f, &pid)) > 0) {
84
84
 
 
85
                if (!kernel_threads && is_kernel_thread(pid) > 0)
 
86
                        continue;
 
87
 
85
88
                if (n >= n_allocated) {
86
89
                        pid_t *npids;
87
90
 
133
136
                for (i = 0; i < n; i++) {
134
137
                        char *t = NULL;
135
138
 
136
 
                        get_process_cmdline(pids[i], n_columns, &t);
 
139
                        get_process_cmdline(pids[i], n_columns, true, &t);
137
140
 
138
141
                        printf("%s%s %*lu %s\n",
139
142
                               prefix,
157
160
        return r;
158
161
}
159
162
 
160
 
int show_cgroup_by_path(const char *path, const char *prefix, unsigned n_columns) {
 
163
int show_cgroup_by_path(const char *path, const char *prefix, unsigned n_columns, bool kernel_threads) {
161
164
        DIR *d;
162
165
        char *last = NULL;
163
166
        char *p1 = NULL, *p2 = NULL, *fn = NULL, *gn = NULL;
181
184
        while ((r = cg_read_subgroup(d, &gn)) > 0) {
182
185
 
183
186
                if (!shown_pids) {
184
 
                        show_cgroup_one_by_path(path, prefix, n_columns, true);
 
187
                        show_cgroup_one_by_path(path, prefix, n_columns, true, kernel_threads);
185
188
                        shown_pids = true;
186
189
                }
187
190
 
194
197
                                        goto finish;
195
198
                                }
196
199
 
197
 
                        show_cgroup_by_path(last, p1, n_columns-2);
 
200
                        show_cgroup_by_path(last, p1, n_columns-2, kernel_threads);
198
201
 
199
202
                        free(last);
200
203
                        last = NULL;
213
216
                goto finish;
214
217
 
215
218
        if (!shown_pids)
216
 
                show_cgroup_one_by_path(path, prefix, n_columns, !!last);
 
219
                show_cgroup_one_by_path(path, prefix, n_columns, !!last, kernel_threads);
217
220
 
218
221
        if (last) {
219
222
                printf("%s\342\224\224 %s\n", prefix, file_name_from_path(last));
224
227
                                goto finish;
225
228
                        }
226
229
 
227
 
                show_cgroup_by_path(last, p2, n_columns-2);
 
230
                show_cgroup_by_path(last, p2, n_columns-2, kernel_threads);
228
231
        }
229
232
 
230
233
        r = 0;
240
243
        return r;
241
244
}
242
245
 
243
 
int show_cgroup(const char *controller, const char *path, const char *prefix, unsigned n_columns) {
 
246
int show_cgroup(const char *controller, const char *path, const char *prefix, unsigned n_columns, bool kernel_threads) {
244
247
        char *p;
245
248
        int r;
246
249
 
247
250
        assert(controller);
248
251
        assert(path);
249
252
 
250
 
        if ((r = cg_get_path(controller, path, NULL, &p)) < 0)
 
253
        r = cg_get_path(controller, path, NULL, &p);
 
254
        if (r < 0)
251
255
                return r;
252
256
 
253
 
        r = show_cgroup_by_path(p, prefix, n_columns);
 
257
        r = show_cgroup_by_path(p, prefix, n_columns, kernel_threads);
254
258
        free(p);
255
259
 
256
260
        return r;