diff options
author | Mike Frysinger <vapier@gentoo.org> | 2014-12-10 18:52:10 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 20:41:12 -0500 |
commit | e6084d4a086b626acb5cf97795a9243062c2f4cd (patch) | |
tree | 5ed1c13b36f05bfe89948876a847ab05017865b3 | |
parent | 6b899c4e9a049dfca759d990bd53b14f81c3626c (diff) |
binfmt_misc: clean up code style a bit
Clean up various coding style issues that checkpatch complains about.
No functional changes here.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | fs/binfmt_misc.c | 293 |
1 files changed, 145 insertions, 148 deletions
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index d87ddc7c4b14..01a2cd9ab2bf 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -1,19 +1,10 @@ | |||
1 | /* | 1 | /* |
2 | * binfmt_misc.c | 2 | * binfmt_misc.c |
3 | * | 3 | * |
4 | * Copyright (C) 1997 Richard Günther | 4 | * Copyright (C) 1997 Richard Günther |
5 | * | 5 | * |
6 | * binfmt_misc detects binaries via a magic or filename extension and invokes | 6 | * binfmt_misc detects binaries via a magic or filename extension and invokes |
7 | * a specified wrapper. This should obsolete binfmt_java, binfmt_em86 and | 7 | * a specified wrapper. See Documentation/binfmt_misc.txt for more details. |
8 | * binfmt_mz. | ||
9 | * | ||
10 | * 1997-04-25 first version | ||
11 | * [...] | ||
12 | * 1997-05-19 cleanup | ||
13 | * 1997-06-26 hpa: pass the real filename rather than argv[0] | ||
14 | * 1997-06-30 minor cleanup | ||
15 | * 1997-08-09 removed extension stripping, locking cleanup | ||
16 | * 2001-02-28 AV: rewritten into something that resembles C. Original didn't. | ||
17 | */ | 8 | */ |
18 | 9 | ||
19 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | 10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
@@ -48,9 +39,9 @@ static LIST_HEAD(entries); | |||
48 | static int enabled = 1; | 39 | static int enabled = 1; |
49 | 40 | ||
50 | enum {Enabled, Magic}; | 41 | enum {Enabled, Magic}; |
51 | #define MISC_FMT_PRESERVE_ARGV0 (1<<31) | 42 | #define MISC_FMT_PRESERVE_ARGV0 (1 << 31) |
52 | #define MISC_FMT_OPEN_BINARY (1<<30) | 43 | #define MISC_FMT_OPEN_BINARY (1 << 30) |
53 | #define MISC_FMT_CREDENTIALS (1<<29) | 44 | #define MISC_FMT_CREDENTIALS (1 << 29) |
54 | 45 | ||
55 | typedef struct { | 46 | typedef struct { |
56 | struct list_head list; | 47 | struct list_head list; |
@@ -134,7 +125,7 @@ static Node *check_file(struct linux_binprm *bprm) | |||
134 | static int load_misc_binary(struct linux_binprm *bprm) | 125 | static int load_misc_binary(struct linux_binprm *bprm) |
135 | { | 126 | { |
136 | Node *fmt; | 127 | Node *fmt; |
137 | struct file * interp_file = NULL; | 128 | struct file *interp_file = NULL; |
138 | char iname[BINPRM_BUF_SIZE]; | 129 | char iname[BINPRM_BUF_SIZE]; |
139 | const char *iname_addr = iname; | 130 | const char *iname_addr = iname; |
140 | int retval; | 131 | int retval; |
@@ -142,7 +133,7 @@ static int load_misc_binary(struct linux_binprm *bprm) | |||
142 | 133 | ||
143 | retval = -ENOEXEC; | 134 | retval = -ENOEXEC; |
144 | if (!enabled) | 135 | if (!enabled) |
145 | goto _ret; | 136 | goto ret; |
146 | 137 | ||
147 | /* to keep locking time low, we copy the interpreter string */ | 138 | /* to keep locking time low, we copy the interpreter string */ |
148 | read_lock(&entries_lock); | 139 | read_lock(&entries_lock); |
@@ -151,25 +142,26 @@ static int load_misc_binary(struct linux_binprm *bprm) | |||
151 | strlcpy(iname, fmt->interpreter, BINPRM_BUF_SIZE); | 142 | strlcpy(iname, fmt->interpreter, BINPRM_BUF_SIZE); |
152 | read_unlock(&entries_lock); | 143 | read_unlock(&entries_lock); |
153 | if (!fmt) | 144 | if (!fmt) |
154 | goto _ret; | 145 | goto ret; |
155 | 146 | ||
156 | if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) { | 147 | if (!(fmt->flags & MISC_FMT_PRESERVE_ARGV0)) { |
157 | retval = remove_arg_zero(bprm); | 148 | retval = remove_arg_zero(bprm); |
158 | if (retval) | 149 | if (retval) |
159 | goto _ret; | 150 | goto ret; |
160 | } | 151 | } |
161 | 152 | ||
162 | if (fmt->flags & MISC_FMT_OPEN_BINARY) { | 153 | if (fmt->flags & MISC_FMT_OPEN_BINARY) { |
163 | 154 | ||
164 | /* if the binary should be opened on behalf of the | 155 | /* if the binary should be opened on behalf of the |
165 | * interpreter than keep it open and assign descriptor | 156 | * interpreter than keep it open and assign descriptor |
166 | * to it */ | 157 | * to it |
158 | */ | ||
167 | fd_binary = get_unused_fd_flags(0); | 159 | fd_binary = get_unused_fd_flags(0); |
168 | if (fd_binary < 0) { | 160 | if (fd_binary < 0) { |
169 | retval = fd_binary; | 161 | retval = fd_binary; |
170 | goto _ret; | 162 | goto ret; |
171 | } | 163 | } |
172 | fd_install(fd_binary, bprm->file); | 164 | fd_install(fd_binary, bprm->file); |
173 | 165 | ||
174 | /* if the binary is not readable than enforce mm->dumpable=0 | 166 | /* if the binary is not readable than enforce mm->dumpable=0 |
175 | regardless of the interpreter's permissions */ | 167 | regardless of the interpreter's permissions */ |
@@ -182,32 +174,32 @@ static int load_misc_binary(struct linux_binprm *bprm) | |||
182 | bprm->interp_flags |= BINPRM_FLAGS_EXECFD; | 174 | bprm->interp_flags |= BINPRM_FLAGS_EXECFD; |
183 | bprm->interp_data = fd_binary; | 175 | bprm->interp_data = fd_binary; |
184 | 176 | ||
185 | } else { | 177 | } else { |
186 | allow_write_access(bprm->file); | 178 | allow_write_access(bprm->file); |
187 | fput(bprm->file); | 179 | fput(bprm->file); |
188 | bprm->file = NULL; | 180 | bprm->file = NULL; |
189 | } | 181 | } |
190 | /* make argv[1] be the path to the binary */ | 182 | /* make argv[1] be the path to the binary */ |
191 | retval = copy_strings_kernel (1, &bprm->interp, bprm); | 183 | retval = copy_strings_kernel(1, &bprm->interp, bprm); |
192 | if (retval < 0) | 184 | if (retval < 0) |
193 | goto _error; | 185 | goto error; |
194 | bprm->argc++; | 186 | bprm->argc++; |
195 | 187 | ||
196 | /* add the interp as argv[0] */ | 188 | /* add the interp as argv[0] */ |
197 | retval = copy_strings_kernel (1, &iname_addr, bprm); | 189 | retval = copy_strings_kernel(1, &iname_addr, bprm); |
198 | if (retval < 0) | 190 | if (retval < 0) |
199 | goto _error; | 191 | goto error; |
200 | bprm->argc ++; | 192 | bprm->argc++; |
201 | 193 | ||
202 | /* Update interp in case binfmt_script needs it. */ | 194 | /* Update interp in case binfmt_script needs it. */ |
203 | retval = bprm_change_interp(iname, bprm); | 195 | retval = bprm_change_interp(iname, bprm); |
204 | if (retval < 0) | 196 | if (retval < 0) |
205 | goto _error; | 197 | goto error; |
206 | 198 | ||
207 | interp_file = open_exec (iname); | 199 | interp_file = open_exec(iname); |
208 | retval = PTR_ERR (interp_file); | 200 | retval = PTR_ERR(interp_file); |
209 | if (IS_ERR (interp_file)) | 201 | if (IS_ERR(interp_file)) |
210 | goto _error; | 202 | goto error; |
211 | 203 | ||
212 | bprm->file = interp_file; | 204 | bprm->file = interp_file; |
213 | if (fmt->flags & MISC_FMT_CREDENTIALS) { | 205 | if (fmt->flags & MISC_FMT_CREDENTIALS) { |
@@ -218,23 +210,23 @@ static int load_misc_binary(struct linux_binprm *bprm) | |||
218 | memset(bprm->buf, 0, BINPRM_BUF_SIZE); | 210 | memset(bprm->buf, 0, BINPRM_BUF_SIZE); |
219 | retval = kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE); | 211 | retval = kernel_read(bprm->file, 0, bprm->buf, BINPRM_BUF_SIZE); |
220 | } else | 212 | } else |
221 | retval = prepare_binprm (bprm); | 213 | retval = prepare_binprm(bprm); |
222 | 214 | ||
223 | if (retval < 0) | 215 | if (retval < 0) |
224 | goto _error; | 216 | goto error; |
225 | 217 | ||
226 | retval = search_binary_handler(bprm); | 218 | retval = search_binary_handler(bprm); |
227 | if (retval < 0) | 219 | if (retval < 0) |
228 | goto _error; | 220 | goto error; |
229 | 221 | ||
230 | _ret: | 222 | ret: |
231 | return retval; | 223 | return retval; |
232 | _error: | 224 | error: |
233 | if (fd_binary > 0) | 225 | if (fd_binary > 0) |
234 | sys_close(fd_binary); | 226 | sys_close(fd_binary); |
235 | bprm->interp_flags = 0; | 227 | bprm->interp_flags = 0; |
236 | bprm->interp_data = 0; | 228 | bprm->interp_data = 0; |
237 | goto _ret; | 229 | goto ret; |
238 | } | 230 | } |
239 | 231 | ||
240 | /* Command parsers */ | 232 | /* Command parsers */ |
@@ -261,39 +253,40 @@ static char *scanarg(char *s, char del) | |||
261 | return s; | 253 | return s; |
262 | } | 254 | } |
263 | 255 | ||
264 | static char * check_special_flags (char * sfs, Node * e) | 256 | static char *check_special_flags(char *sfs, Node *e) |
265 | { | 257 | { |
266 | char * p = sfs; | 258 | char *p = sfs; |
267 | int cont = 1; | 259 | int cont = 1; |
268 | 260 | ||
269 | /* special flags */ | 261 | /* special flags */ |
270 | while (cont) { | 262 | while (cont) { |
271 | switch (*p) { | 263 | switch (*p) { |
272 | case 'P': | 264 | case 'P': |
273 | pr_debug("register: flag: P (preserve argv0)\n"); | 265 | pr_debug("register: flag: P (preserve argv0)\n"); |
274 | p++; | 266 | p++; |
275 | e->flags |= MISC_FMT_PRESERVE_ARGV0; | 267 | e->flags |= MISC_FMT_PRESERVE_ARGV0; |
276 | break; | 268 | break; |
277 | case 'O': | 269 | case 'O': |
278 | pr_debug("register: flag: O (open binary)\n"); | 270 | pr_debug("register: flag: O (open binary)\n"); |
279 | p++; | 271 | p++; |
280 | e->flags |= MISC_FMT_OPEN_BINARY; | 272 | e->flags |= MISC_FMT_OPEN_BINARY; |
281 | break; | 273 | break; |
282 | case 'C': | 274 | case 'C': |
283 | pr_debug("register: flag: C (preserve creds)\n"); | 275 | pr_debug("register: flag: C (preserve creds)\n"); |
284 | p++; | 276 | p++; |
285 | /* this flags also implies the | 277 | /* this flags also implies the |
286 | open-binary flag */ | 278 | open-binary flag */ |
287 | e->flags |= (MISC_FMT_CREDENTIALS | | 279 | e->flags |= (MISC_FMT_CREDENTIALS | |
288 | MISC_FMT_OPEN_BINARY); | 280 | MISC_FMT_OPEN_BINARY); |
289 | break; | 281 | break; |
290 | default: | 282 | default: |
291 | cont = 0; | 283 | cont = 0; |
292 | } | 284 | } |
293 | } | 285 | } |
294 | 286 | ||
295 | return p; | 287 | return p; |
296 | } | 288 | } |
289 | |||
297 | /* | 290 | /* |
298 | * This registers a new binary format, it recognises the syntax | 291 | * This registers a new binary format, it recognises the syntax |
299 | * ':name:type:offset:magic:mask:interpreter:flags' | 292 | * ':name:type:offset:magic:mask:interpreter:flags' |
@@ -323,26 +316,26 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
323 | 316 | ||
324 | memset(e, 0, sizeof(Node)); | 317 | memset(e, 0, sizeof(Node)); |
325 | if (copy_from_user(buf, buffer, count)) | 318 | if (copy_from_user(buf, buffer, count)) |
326 | goto Efault; | 319 | goto efault; |
327 | 320 | ||
328 | del = *p++; /* delimeter */ | 321 | del = *p++; /* delimeter */ |
329 | 322 | ||
330 | pr_debug("register: delim: %#x {%c}\n", del, del); | 323 | pr_debug("register: delim: %#x {%c}\n", del, del); |
331 | 324 | ||
332 | /* Pad the buffer with the delim to simplify parsing below. */ | 325 | /* Pad the buffer with the delim to simplify parsing below. */ |
333 | memset(buf+count, del, 8); | 326 | memset(buf + count, del, 8); |
334 | 327 | ||
335 | /* Parse the 'name' field. */ | 328 | /* Parse the 'name' field. */ |
336 | e->name = p; | 329 | e->name = p; |
337 | p = strchr(p, del); | 330 | p = strchr(p, del); |
338 | if (!p) | 331 | if (!p) |
339 | goto Einval; | 332 | goto einval; |
340 | *p++ = '\0'; | 333 | *p++ = '\0'; |
341 | if (!e->name[0] || | 334 | if (!e->name[0] || |
342 | !strcmp(e->name, ".") || | 335 | !strcmp(e->name, ".") || |
343 | !strcmp(e->name, "..") || | 336 | !strcmp(e->name, "..") || |
344 | strchr(e->name, '/')) | 337 | strchr(e->name, '/')) |
345 | goto Einval; | 338 | goto einval; |
346 | 339 | ||
347 | pr_debug("register: name: {%s}\n", e->name); | 340 | pr_debug("register: name: {%s}\n", e->name); |
348 | 341 | ||
@@ -357,10 +350,10 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
357 | e->flags = (1 << Enabled) | (1 << Magic); | 350 | e->flags = (1 << Enabled) | (1 << Magic); |
358 | break; | 351 | break; |
359 | default: | 352 | default: |
360 | goto Einval; | 353 | goto einval; |
361 | } | 354 | } |
362 | if (*p++ != del) | 355 | if (*p++ != del) |
363 | goto Einval; | 356 | goto einval; |
364 | 357 | ||
365 | if (test_bit(Magic, &e->flags)) { | 358 | if (test_bit(Magic, &e->flags)) { |
366 | /* Handle the 'M' (magic) format. */ | 359 | /* Handle the 'M' (magic) format. */ |
@@ -369,21 +362,21 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
369 | /* Parse the 'offset' field. */ | 362 | /* Parse the 'offset' field. */ |
370 | s = strchr(p, del); | 363 | s = strchr(p, del); |
371 | if (!s) | 364 | if (!s) |
372 | goto Einval; | 365 | goto einval; |
373 | *s++ = '\0'; | 366 | *s++ = '\0'; |
374 | e->offset = simple_strtoul(p, &p, 10); | 367 | e->offset = simple_strtoul(p, &p, 10); |
375 | if (*p++) | 368 | if (*p++) |
376 | goto Einval; | 369 | goto einval; |
377 | pr_debug("register: offset: %#x\n", e->offset); | 370 | pr_debug("register: offset: %#x\n", e->offset); |
378 | 371 | ||
379 | /* Parse the 'magic' field. */ | 372 | /* Parse the 'magic' field. */ |
380 | e->magic = p; | 373 | e->magic = p; |
381 | p = scanarg(p, del); | 374 | p = scanarg(p, del); |
382 | if (!p) | 375 | if (!p) |
383 | goto Einval; | 376 | goto einval; |
384 | p[-1] = '\0'; | 377 | p[-1] = '\0'; |
385 | if (p == e->magic) | 378 | if (p == e->magic) |
386 | goto Einval; | 379 | goto einval; |
387 | if (USE_DEBUG) | 380 | if (USE_DEBUG) |
388 | print_hex_dump_bytes( | 381 | print_hex_dump_bytes( |
389 | KBUILD_MODNAME ": register: magic[raw]: ", | 382 | KBUILD_MODNAME ": register: magic[raw]: ", |
@@ -393,7 +386,7 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
393 | e->mask = p; | 386 | e->mask = p; |
394 | p = scanarg(p, del); | 387 | p = scanarg(p, del); |
395 | if (!p) | 388 | if (!p) |
396 | goto Einval; | 389 | goto einval; |
397 | p[-1] = '\0'; | 390 | p[-1] = '\0'; |
398 | if (p == e->mask) { | 391 | if (p == e->mask) { |
399 | e->mask = NULL; | 392 | e->mask = NULL; |
@@ -412,9 +405,9 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
412 | e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX); | 405 | e->size = string_unescape_inplace(e->magic, UNESCAPE_HEX); |
413 | if (e->mask && | 406 | if (e->mask && |
414 | string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size) | 407 | string_unescape_inplace(e->mask, UNESCAPE_HEX) != e->size) |
415 | goto Einval; | 408 | goto einval; |
416 | if (e->size + e->offset > BINPRM_BUF_SIZE) | 409 | if (e->size + e->offset > BINPRM_BUF_SIZE) |
417 | goto Einval; | 410 | goto einval; |
418 | pr_debug("register: magic/mask length: %i\n", e->size); | 411 | pr_debug("register: magic/mask length: %i\n", e->size); |
419 | if (USE_DEBUG) { | 412 | if (USE_DEBUG) { |
420 | print_hex_dump_bytes( | 413 | print_hex_dump_bytes( |
@@ -446,23 +439,23 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
446 | /* Skip the 'offset' field. */ | 439 | /* Skip the 'offset' field. */ |
447 | p = strchr(p, del); | 440 | p = strchr(p, del); |
448 | if (!p) | 441 | if (!p) |
449 | goto Einval; | 442 | goto einval; |
450 | *p++ = '\0'; | 443 | *p++ = '\0'; |
451 | 444 | ||
452 | /* Parse the 'magic' field. */ | 445 | /* Parse the 'magic' field. */ |
453 | e->magic = p; | 446 | e->magic = p; |
454 | p = strchr(p, del); | 447 | p = strchr(p, del); |
455 | if (!p) | 448 | if (!p) |
456 | goto Einval; | 449 | goto einval; |
457 | *p++ = '\0'; | 450 | *p++ = '\0'; |
458 | if (!e->magic[0] || strchr(e->magic, '/')) | 451 | if (!e->magic[0] || strchr(e->magic, '/')) |
459 | goto Einval; | 452 | goto einval; |
460 | pr_debug("register: extension: {%s}\n", e->magic); | 453 | pr_debug("register: extension: {%s}\n", e->magic); |
461 | 454 | ||
462 | /* Skip the 'mask' field. */ | 455 | /* Skip the 'mask' field. */ |
463 | p = strchr(p, del); | 456 | p = strchr(p, del); |
464 | if (!p) | 457 | if (!p) |
465 | goto Einval; | 458 | goto einval; |
466 | *p++ = '\0'; | 459 | *p++ = '\0'; |
467 | } | 460 | } |
468 | 461 | ||
@@ -470,27 +463,28 @@ static Node *create_entry(const char __user *buffer, size_t count) | |||
470 | e->interpreter = p; | 463 | e->interpreter = p; |
471 | p = strchr(p, del); | 464 | p = strchr(p, del); |
472 | if (!p) | 465 | if (!p) |
473 | goto Einval; | 466 | goto einval; |
474 | *p++ = '\0'; | 467 | *p++ = '\0'; |
475 | if (!e->interpreter[0]) | 468 | if (!e->interpreter[0]) |
476 | goto Einval; | 469 | goto einval; |
477 | pr_debug("register: interpreter: {%s}\n", e->interpreter); | 470 | pr_debug("register: interpreter: {%s}\n", e->interpreter); |
478 | 471 | ||
479 | /* Parse the 'flags' field. */ | 472 | /* Parse the 'flags' field. */ |
480 | p = check_special_flags (p, e); | 473 | p = check_special_flags(p, e); |
481 | if (*p == '\n') | 474 | if (*p == '\n') |
482 | p++; | 475 | p++; |
483 | if (p != buf + count) | 476 | if (p != buf + count) |
484 | goto Einval; | 477 | goto einval; |
478 | |||
485 | return e; | 479 | return e; |
486 | 480 | ||
487 | out: | 481 | out: |
488 | return ERR_PTR(err); | 482 | return ERR_PTR(err); |
489 | 483 | ||
490 | Efault: | 484 | efault: |
491 | kfree(e); | 485 | kfree(e); |
492 | return ERR_PTR(-EFAULT); | 486 | return ERR_PTR(-EFAULT); |
493 | Einval: | 487 | einval: |
494 | kfree(e); | 488 | kfree(e); |
495 | return ERR_PTR(-EINVAL); | 489 | return ERR_PTR(-EINVAL); |
496 | } | 490 | } |
@@ -509,7 +503,7 @@ static int parse_command(const char __user *buffer, size_t count) | |||
509 | return -EFAULT; | 503 | return -EFAULT; |
510 | if (!count) | 504 | if (!count) |
511 | return 0; | 505 | return 0; |
512 | if (s[count-1] == '\n') | 506 | if (s[count - 1] == '\n') |
513 | count--; | 507 | count--; |
514 | if (count == 1 && s[0] == '0') | 508 | if (count == 1 && s[0] == '0') |
515 | return 1; | 509 | return 1; |
@@ -526,7 +520,7 @@ static void entry_status(Node *e, char *page) | |||
526 | { | 520 | { |
527 | char *dp; | 521 | char *dp; |
528 | char *status = "disabled"; | 522 | char *status = "disabled"; |
529 | const char * flags = "flags: "; | 523 | const char *flags = "flags: "; |
530 | 524 | ||
531 | if (test_bit(Enabled, &e->flags)) | 525 | if (test_bit(Enabled, &e->flags)) |
532 | status = "enabled"; | 526 | status = "enabled"; |
@@ -540,19 +534,15 @@ static void entry_status(Node *e, char *page) | |||
540 | dp = page + strlen(page); | 534 | dp = page + strlen(page); |
541 | 535 | ||
542 | /* print the special flags */ | 536 | /* print the special flags */ |
543 | sprintf (dp, "%s", flags); | 537 | sprintf(dp, "%s", flags); |
544 | dp += strlen (flags); | 538 | dp += strlen(flags); |
545 | if (e->flags & MISC_FMT_PRESERVE_ARGV0) { | 539 | if (e->flags & MISC_FMT_PRESERVE_ARGV0) |
546 | *dp ++ = 'P'; | 540 | *dp++ = 'P'; |
547 | } | 541 | if (e->flags & MISC_FMT_OPEN_BINARY) |
548 | if (e->flags & MISC_FMT_OPEN_BINARY) { | 542 | *dp++ = 'O'; |
549 | *dp ++ = 'O'; | 543 | if (e->flags & MISC_FMT_CREDENTIALS) |
550 | } | 544 | *dp++ = 'C'; |
551 | if (e->flags & MISC_FMT_CREDENTIALS) { | 545 | *dp++ = '\n'; |
552 | *dp ++ = 'C'; | ||
553 | } | ||
554 | *dp ++ = '\n'; | ||
555 | |||
556 | 546 | ||
557 | if (!test_bit(Magic, &e->flags)) { | 547 | if (!test_bit(Magic, &e->flags)) { |
558 | sprintf(dp, "extension .%s\n", e->magic); | 548 | sprintf(dp, "extension .%s\n", e->magic); |
@@ -580,7 +570,7 @@ static void entry_status(Node *e, char *page) | |||
580 | 570 | ||
581 | static struct inode *bm_get_inode(struct super_block *sb, int mode) | 571 | static struct inode *bm_get_inode(struct super_block *sb, int mode) |
582 | { | 572 | { |
583 | struct inode * inode = new_inode(sb); | 573 | struct inode *inode = new_inode(sb); |
584 | 574 | ||
585 | if (inode) { | 575 | if (inode) { |
586 | inode->i_ino = get_next_ino(); | 576 | inode->i_ino = get_next_ino(); |
@@ -620,13 +610,14 @@ static void kill_node(Node *e) | |||
620 | /* /<entry> */ | 610 | /* /<entry> */ |
621 | 611 | ||
622 | static ssize_t | 612 | static ssize_t |
623 | bm_entry_read(struct file * file, char __user * buf, size_t nbytes, loff_t *ppos) | 613 | bm_entry_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) |
624 | { | 614 | { |
625 | Node *e = file_inode(file)->i_private; | 615 | Node *e = file_inode(file)->i_private; |
626 | ssize_t res; | 616 | ssize_t res; |
627 | char *page; | 617 | char *page; |
628 | 618 | ||
629 | if (!(page = (char*) __get_free_page(GFP_KERNEL))) | 619 | page = (char *) __get_free_page(GFP_KERNEL); |
620 | if (!page) | ||
630 | return -ENOMEM; | 621 | return -ENOMEM; |
631 | 622 | ||
632 | entry_status(e, page); | 623 | entry_status(e, page); |
@@ -645,26 +636,28 @@ static ssize_t bm_entry_write(struct file *file, const char __user *buffer, | |||
645 | int res = parse_command(buffer, count); | 636 | int res = parse_command(buffer, count); |
646 | 637 | ||
647 | switch (res) { | 638 | switch (res) { |
648 | case 1: | 639 | case 1: |
649 | /* Disable this handler. */ | 640 | /* Disable this handler. */ |
650 | clear_bit(Enabled, &e->flags); | 641 | clear_bit(Enabled, &e->flags); |
651 | break; | 642 | break; |
652 | case 2: | 643 | case 2: |
653 | /* Enable this handler. */ | 644 | /* Enable this handler. */ |
654 | set_bit(Enabled, &e->flags); | 645 | set_bit(Enabled, &e->flags); |
655 | break; | 646 | break; |
656 | case 3: | 647 | case 3: |
657 | /* Delete this handler. */ | 648 | /* Delete this handler. */ |
658 | root = dget(file->f_path.dentry->d_sb->s_root); | 649 | root = dget(file->f_path.dentry->d_sb->s_root); |
659 | mutex_lock(&root->d_inode->i_mutex); | 650 | mutex_lock(&root->d_inode->i_mutex); |
660 | 651 | ||
661 | kill_node(e); | 652 | kill_node(e); |
662 | 653 | ||
663 | mutex_unlock(&root->d_inode->i_mutex); | 654 | mutex_unlock(&root->d_inode->i_mutex); |
664 | dput(root); | 655 | dput(root); |
665 | break; | 656 | break; |
666 | default: return res; | 657 | default: |
658 | return res; | ||
667 | } | 659 | } |
660 | |||
668 | return count; | 661 | return count; |
669 | } | 662 | } |
670 | 663 | ||
@@ -752,34 +745,36 @@ bm_status_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | |||
752 | return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s)); | 745 | return simple_read_from_buffer(buf, nbytes, ppos, s, strlen(s)); |
753 | } | 746 | } |
754 | 747 | ||
755 | static ssize_t bm_status_write(struct file * file, const char __user * buffer, | 748 | static ssize_t bm_status_write(struct file *file, const char __user *buffer, |
756 | size_t count, loff_t *ppos) | 749 | size_t count, loff_t *ppos) |
757 | { | 750 | { |
758 | int res = parse_command(buffer, count); | 751 | int res = parse_command(buffer, count); |
759 | struct dentry *root; | 752 | struct dentry *root; |
760 | 753 | ||
761 | switch (res) { | 754 | switch (res) { |
762 | case 1: | 755 | case 1: |
763 | /* Disable all handlers. */ | 756 | /* Disable all handlers. */ |
764 | enabled = 0; | 757 | enabled = 0; |
765 | break; | 758 | break; |
766 | case 2: | 759 | case 2: |
767 | /* Enable all handlers. */ | 760 | /* Enable all handlers. */ |
768 | enabled = 1; | 761 | enabled = 1; |
769 | break; | 762 | break; |
770 | case 3: | 763 | case 3: |
771 | /* Delete all handlers. */ | 764 | /* Delete all handlers. */ |
772 | root = dget(file->f_path.dentry->d_sb->s_root); | 765 | root = dget(file->f_path.dentry->d_sb->s_root); |
773 | mutex_lock(&root->d_inode->i_mutex); | 766 | mutex_lock(&root->d_inode->i_mutex); |
774 | 767 | ||
775 | while (!list_empty(&entries)) | 768 | while (!list_empty(&entries)) |
776 | kill_node(list_entry(entries.next, Node, list)); | 769 | kill_node(list_entry(entries.next, Node, list)); |
777 | 770 | ||
778 | mutex_unlock(&root->d_inode->i_mutex); | 771 | mutex_unlock(&root->d_inode->i_mutex); |
779 | dput(root); | 772 | dput(root); |
780 | break; | 773 | break; |
781 | default: return res; | 774 | default: |
775 | return res; | ||
782 | } | 776 | } |
777 | |||
783 | return count; | 778 | return count; |
784 | } | 779 | } |
785 | 780 | ||
@@ -796,14 +791,16 @@ static const struct super_operations s_ops = { | |||
796 | .evict_inode = bm_evict_inode, | 791 | .evict_inode = bm_evict_inode, |
797 | }; | 792 | }; |
798 | 793 | ||
799 | static int bm_fill_super(struct super_block * sb, void * data, int silent) | 794 | static int bm_fill_super(struct super_block *sb, void *data, int silent) |
800 | { | 795 | { |
796 | int err; | ||
801 | static struct tree_descr bm_files[] = { | 797 | static struct tree_descr bm_files[] = { |
802 | [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO}, | 798 | [2] = {"status", &bm_status_operations, S_IWUSR|S_IRUGO}, |
803 | [3] = {"register", &bm_register_operations, S_IWUSR}, | 799 | [3] = {"register", &bm_register_operations, S_IWUSR}, |
804 | /* last one */ {""} | 800 | /* last one */ {""} |
805 | }; | 801 | }; |
806 | int err = simple_fill_super(sb, BINFMTFS_MAGIC, bm_files); | 802 | |
803 | err = simple_fill_super(sb, BINFMTFS_MAGIC, bm_files); | ||
807 | if (!err) | 804 | if (!err) |
808 | sb->s_op = &s_ops; | 805 | sb->s_op = &s_ops; |
809 | return err; | 806 | return err; |