diff options
author | Davidlohr Bueso <davidlohr@hp.com> | 2014-01-27 20:07:05 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-01-28 00:02:39 -0500 |
commit | 8001c85810dd2277d75ae60376e840456afa9b7e (patch) | |
tree | 60a03cdecbbbb6e2bdca6b132b4b332f90a728ad /ipc/util.c | |
parent | 239521f31d7496a5322ee664ed8bbd1027b98c4b (diff) |
ipc: standardize code comments
IPC commenting style is all over the place, *specially* in util.c. This
patch orders things a bit.
Signed-off-by: Davidlohr Bueso <davidlohr@hp.com>
Cc: Aswin Chandramouleeswaran <aswin@hp.com>
Cc: Rik van Riel <riel@redhat.com>
Acked-by: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/util.c')
-rw-r--r-- | ipc/util.c | 239 |
1 files changed, 114 insertions, 125 deletions
diff --git a/ipc/util.c b/ipc/util.c index fdf03fa6869d..af976fc6a464 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
@@ -110,15 +110,15 @@ static struct notifier_block ipc_memory_nb = { | |||
110 | }; | 110 | }; |
111 | 111 | ||
112 | /** | 112 | /** |
113 | * ipc_init - initialise IPC subsystem | 113 | * ipc_init - initialise ipc subsystem |
114 | * | 114 | * |
115 | * The various system5 IPC resources (semaphores, messages and shared | 115 | * The various sysv ipc resources (semaphores, messages and shared |
116 | * memory) are initialised | 116 | * memory) are initialised. |
117 | * A callback routine is registered into the memory hotplug notifier | 117 | * |
118 | * chain: since msgmni scales to lowmem this callback routine will be | 118 | * A callback routine is registered into the memory hotplug notifier |
119 | * called upon successful memory add / remove to recompute msmgni. | 119 | * chain: since msgmni scales to lowmem this callback routine will be |
120 | * called upon successful memory add / remove to recompute msmgni. | ||
120 | */ | 121 | */ |
121 | |||
122 | static int __init ipc_init(void) | 122 | static int __init ipc_init(void) |
123 | { | 123 | { |
124 | sem_init(); | 124 | sem_init(); |
@@ -131,13 +131,12 @@ static int __init ipc_init(void) | |||
131 | __initcall(ipc_init); | 131 | __initcall(ipc_init); |
132 | 132 | ||
133 | /** | 133 | /** |
134 | * ipc_init_ids - initialise IPC identifiers | 134 | * ipc_init_ids - initialise ipc identifiers |
135 | * @ids: Identifier set | 135 | * @ids: ipc identifier set |
136 | * | 136 | * |
137 | * Set up the sequence range to use for the ipc identifier range (limited | 137 | * Set up the sequence range to use for the ipc identifier range (limited |
138 | * below IPCMNI) then initialise the ids idr. | 138 | * below IPCMNI) then initialise the ids idr. |
139 | */ | 139 | */ |
140 | |||
141 | void ipc_init_ids(struct ipc_ids *ids) | 140 | void ipc_init_ids(struct ipc_ids *ids) |
142 | { | 141 | { |
143 | init_rwsem(&ids->rwsem); | 142 | init_rwsem(&ids->rwsem); |
@@ -159,11 +158,11 @@ void ipc_init_ids(struct ipc_ids *ids) | |||
159 | #ifdef CONFIG_PROC_FS | 158 | #ifdef CONFIG_PROC_FS |
160 | static const struct file_operations sysvipc_proc_fops; | 159 | static const struct file_operations sysvipc_proc_fops; |
161 | /** | 160 | /** |
162 | * ipc_init_proc_interface - Create a proc interface for sysipc types using a seq_file interface. | 161 | * ipc_init_proc_interface - create a proc interface for sysipc types using a seq_file interface. |
163 | * @path: Path in procfs | 162 | * @path: Path in procfs |
164 | * @header: Banner to be printed at the beginning of the file. | 163 | * @header: Banner to be printed at the beginning of the file. |
165 | * @ids: ipc id table to iterate. | 164 | * @ids: ipc id table to iterate. |
166 | * @show: show routine. | 165 | * @show: show routine. |
167 | */ | 166 | */ |
168 | void __init ipc_init_proc_interface(const char *path, const char *header, | 167 | void __init ipc_init_proc_interface(const char *path, const char *header, |
169 | int ids, int (*show)(struct seq_file *, void *)) | 168 | int ids, int (*show)(struct seq_file *, void *)) |
@@ -191,16 +190,15 @@ void __init ipc_init_proc_interface(const char *path, const char *header, | |||
191 | #endif | 190 | #endif |
192 | 191 | ||
193 | /** | 192 | /** |
194 | * ipc_findkey - find a key in an ipc identifier set | 193 | * ipc_findkey - find a key in an ipc identifier set |
195 | * @ids: Identifier set | 194 | * @ids: ipc identifier set |
196 | * @key: The key to find | 195 | * @key: key to find |
197 | * | 196 | * |
198 | * Requires ipc_ids.rwsem locked. | 197 | * Returns the locked pointer to the ipc structure if found or NULL |
199 | * Returns the LOCKED pointer to the ipc structure if found or NULL | 198 | * otherwise. If key is found ipc points to the owning ipc structure |
200 | * if not. | 199 | * |
201 | * If key is found ipc points to the owning ipc structure | 200 | * Called with ipc_ids.rwsem held. |
202 | */ | 201 | */ |
203 | |||
204 | static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key) | 202 | static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key) |
205 | { | 203 | { |
206 | struct kern_ipc_perm *ipc; | 204 | struct kern_ipc_perm *ipc; |
@@ -227,12 +225,11 @@ static struct kern_ipc_perm *ipc_findkey(struct ipc_ids *ids, key_t key) | |||
227 | } | 225 | } |
228 | 226 | ||
229 | /** | 227 | /** |
230 | * ipc_get_maxid - get the last assigned id | 228 | * ipc_get_maxid - get the last assigned id |
231 | * @ids: IPC identifier set | 229 | * @ids: ipc identifier set |
232 | * | 230 | * |
233 | * Called with ipc_ids.rwsem held. | 231 | * Called with ipc_ids.rwsem held. |
234 | */ | 232 | */ |
235 | |||
236 | int ipc_get_maxid(struct ipc_ids *ids) | 233 | int ipc_get_maxid(struct ipc_ids *ids) |
237 | { | 234 | { |
238 | struct kern_ipc_perm *ipc; | 235 | struct kern_ipc_perm *ipc; |
@@ -258,17 +255,17 @@ int ipc_get_maxid(struct ipc_ids *ids) | |||
258 | } | 255 | } |
259 | 256 | ||
260 | /** | 257 | /** |
261 | * ipc_addid - add an IPC identifier | 258 | * ipc_addid - add an ipc identifier |
262 | * @ids: IPC identifier set | 259 | * @ids: ipc identifier set |
263 | * @new: new IPC permission set | 260 | * @new: new ipc permission set |
264 | * @size: limit for the number of used ids | 261 | * @size: limit for the number of used ids |
265 | * | 262 | * |
266 | * Add an entry 'new' to the IPC ids idr. The permissions object is | 263 | * Add an entry 'new' to the ipc ids idr. The permissions object is |
267 | * initialised and the first free entry is set up and the id assigned | 264 | * initialised and the first free entry is set up and the id assigned |
268 | * is returned. The 'new' entry is returned in a locked state on success. | 265 | * is returned. The 'new' entry is returned in a locked state on success. |
269 | * On failure the entry is not locked and a negative err-code is returned. | 266 | * On failure the entry is not locked and a negative err-code is returned. |
270 | * | 267 | * |
271 | * Called with writer ipc_ids.rwsem held. | 268 | * Called with writer ipc_ids.rwsem held. |
272 | */ | 269 | */ |
273 | int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size) | 270 | int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size) |
274 | { | 271 | { |
@@ -320,14 +317,14 @@ int ipc_addid(struct ipc_ids *ids, struct kern_ipc_perm *new, int size) | |||
320 | } | 317 | } |
321 | 318 | ||
322 | /** | 319 | /** |
323 | * ipcget_new - create a new ipc object | 320 | * ipcget_new - create a new ipc object |
324 | * @ns: namespace | 321 | * @ns: ipc namespace |
325 | * @ids: IPC identifer set | 322 | * @ids: ipc identifer set |
326 | * @ops: the actual creation routine to call | 323 | * @ops: the actual creation routine to call |
327 | * @params: its parameters | 324 | * @params: its parameters |
328 | * | 325 | * |
329 | * This routine is called by sys_msgget, sys_semget() and sys_shmget() | 326 | * This routine is called by sys_msgget, sys_semget() and sys_shmget() |
330 | * when the key is IPC_PRIVATE. | 327 | * when the key is IPC_PRIVATE. |
331 | */ | 328 | */ |
332 | static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, | 329 | static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, |
333 | struct ipc_ops *ops, struct ipc_params *params) | 330 | struct ipc_ops *ops, struct ipc_params *params) |
@@ -341,19 +338,19 @@ static int ipcget_new(struct ipc_namespace *ns, struct ipc_ids *ids, | |||
341 | } | 338 | } |
342 | 339 | ||
343 | /** | 340 | /** |
344 | * ipc_check_perms - check security and permissions for an IPC | 341 | * ipc_check_perms - check security and permissions for an ipc object |
345 | * @ns: IPC namespace | 342 | * @ns: ipc namespace |
346 | * @ipcp: ipc permission set | 343 | * @ipcp: ipc permission set |
347 | * @ops: the actual security routine to call | 344 | * @ops: the actual security routine to call |
348 | * @params: its parameters | 345 | * @params: its parameters |
349 | * | 346 | * |
350 | * This routine is called by sys_msgget(), sys_semget() and sys_shmget() | 347 | * This routine is called by sys_msgget(), sys_semget() and sys_shmget() |
351 | * when the key is not IPC_PRIVATE and that key already exists in the | 348 | * when the key is not IPC_PRIVATE and that key already exists in the |
352 | * ids IDR. | 349 | * ds IDR. |
353 | * | 350 | * |
354 | * On success, the IPC id is returned. | 351 | * On success, the ipc id is returned. |
355 | * | 352 | * |
356 | * It is called with ipc_ids.rwsem and ipcp->lock held. | 353 | * It is called with ipc_ids.rwsem and ipcp->lock held. |
357 | */ | 354 | */ |
358 | static int ipc_check_perms(struct ipc_namespace *ns, | 355 | static int ipc_check_perms(struct ipc_namespace *ns, |
359 | struct kern_ipc_perm *ipcp, | 356 | struct kern_ipc_perm *ipcp, |
@@ -374,18 +371,18 @@ static int ipc_check_perms(struct ipc_namespace *ns, | |||
374 | } | 371 | } |
375 | 372 | ||
376 | /** | 373 | /** |
377 | * ipcget_public - get an ipc object or create a new one | 374 | * ipcget_public - get an ipc object or create a new one |
378 | * @ns: namespace | 375 | * @ns: ipc namespace |
379 | * @ids: IPC identifer set | 376 | * @ids: ipc identifer set |
380 | * @ops: the actual creation routine to call | 377 | * @ops: the actual creation routine to call |
381 | * @params: its parameters | 378 | * @params: its parameters |
382 | * | 379 | * |
383 | * This routine is called by sys_msgget, sys_semget() and sys_shmget() | 380 | * This routine is called by sys_msgget, sys_semget() and sys_shmget() |
384 | * when the key is not IPC_PRIVATE. | 381 | * when the key is not IPC_PRIVATE. |
385 | * It adds a new entry if the key is not found and does some permission | 382 | * It adds a new entry if the key is not found and does some permission |
386 | * / security checkings if the key is found. | 383 | * / security checkings if the key is found. |
387 | * | 384 | * |
388 | * On success, the ipc id is returned. | 385 | * On success, the ipc id is returned. |
389 | */ | 386 | */ |
390 | static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, | 387 | static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, |
391 | struct ipc_ops *ops, struct ipc_params *params) | 388 | struct ipc_ops *ops, struct ipc_params *params) |
@@ -431,14 +428,13 @@ static int ipcget_public(struct ipc_namespace *ns, struct ipc_ids *ids, | |||
431 | 428 | ||
432 | 429 | ||
433 | /** | 430 | /** |
434 | * ipc_rmid - remove an IPC identifier | 431 | * ipc_rmid - remove an ipc identifier |
435 | * @ids: IPC identifier set | 432 | * @ids: ipc identifier set |
436 | * @ipcp: ipc perm structure containing the identifier to remove | 433 | * @ipcp: ipc perm structure containing the identifier to remove |
437 | * | 434 | * |
438 | * ipc_ids.rwsem (as a writer) and the spinlock for this ID are held | 435 | * ipc_ids.rwsem (as a writer) and the spinlock for this ID are held |
439 | * before this function is called, and remain locked on the exit. | 436 | * before this function is called, and remain locked on the exit. |
440 | */ | 437 | */ |
441 | |||
442 | void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp) | 438 | void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp) |
443 | { | 439 | { |
444 | int lid = ipcid_to_idx(ipcp->id); | 440 | int lid = ipcid_to_idx(ipcp->id); |
@@ -453,13 +449,12 @@ void ipc_rmid(struct ipc_ids *ids, struct kern_ipc_perm *ipcp) | |||
453 | } | 449 | } |
454 | 450 | ||
455 | /** | 451 | /** |
456 | * ipc_alloc - allocate ipc space | 452 | * ipc_alloc - allocate ipc space |
457 | * @size: size desired | 453 | * @size: size desired |
458 | * | 454 | * |
459 | * Allocate memory from the appropriate pools and return a pointer to it. | 455 | * Allocate memory from the appropriate pools and return a pointer to it. |
460 | * NULL is returned if the allocation fails | 456 | * NULL is returned if the allocation fails |
461 | */ | 457 | */ |
462 | |||
463 | void *ipc_alloc(int size) | 458 | void *ipc_alloc(int size) |
464 | { | 459 | { |
465 | void *out; | 460 | void *out; |
@@ -471,14 +466,13 @@ void *ipc_alloc(int size) | |||
471 | } | 466 | } |
472 | 467 | ||
473 | /** | 468 | /** |
474 | * ipc_free - free ipc space | 469 | * ipc_free - free ipc space |
475 | * @ptr: pointer returned by ipc_alloc | 470 | * @ptr: pointer returned by ipc_alloc |
476 | * @size: size of block | 471 | * @size: size of block |
477 | * | 472 | * |
478 | * Free a block created with ipc_alloc(). The caller must know the size | 473 | * Free a block created with ipc_alloc(). The caller must know the size |
479 | * used in the allocation call. | 474 | * used in the allocation call. |
480 | */ | 475 | */ |
481 | |||
482 | void ipc_free(void *ptr, int size) | 476 | void ipc_free(void *ptr, int size) |
483 | { | 477 | { |
484 | if (size > PAGE_SIZE) | 478 | if (size > PAGE_SIZE) |
@@ -488,11 +482,11 @@ void ipc_free(void *ptr, int size) | |||
488 | } | 482 | } |
489 | 483 | ||
490 | /** | 484 | /** |
491 | * ipc_rcu_alloc - allocate ipc and rcu space | 485 | * ipc_rcu_alloc - allocate ipc and rcu space |
492 | * @size: size desired | 486 | * @size: size desired |
493 | * | 487 | * |
494 | * Allocate memory for the rcu header structure + the object. | 488 | * Allocate memory for the rcu header structure + the object. |
495 | * Returns the pointer to the object or NULL upon failure. | 489 | * Returns the pointer to the object or NULL upon failure. |
496 | */ | 490 | */ |
497 | void *ipc_rcu_alloc(int size) | 491 | void *ipc_rcu_alloc(int size) |
498 | { | 492 | { |
@@ -534,17 +528,16 @@ void ipc_rcu_free(struct rcu_head *head) | |||
534 | } | 528 | } |
535 | 529 | ||
536 | /** | 530 | /** |
537 | * ipcperms - check IPC permissions | 531 | * ipcperms - check ipc permissions |
538 | * @ns: IPC namespace | 532 | * @ns: ipc namespace |
539 | * @ipcp: IPC permission set | 533 | * @ipcp: ipc permission set |
540 | * @flag: desired permission set. | 534 | * @flag: desired permission set |
541 | * | 535 | * |
542 | * Check user, group, other permissions for access | 536 | * Check user, group, other permissions for access |
543 | * to ipc resources. return 0 if allowed | 537 | * to ipc resources. return 0 if allowed |
544 | * | 538 | * |
545 | * @flag will most probably be 0 or S_...UGO from <linux/stat.h> | 539 | * @flag will most probably be 0 or S_...UGO from <linux/stat.h> |
546 | */ | 540 | */ |
547 | |||
548 | int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag) | 541 | int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag) |
549 | { | 542 | { |
550 | kuid_t euid = current_euid(); | 543 | kuid_t euid = current_euid(); |
@@ -572,15 +565,13 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag) | |||
572 | */ | 565 | */ |
573 | 566 | ||
574 | /** | 567 | /** |
575 | * kernel_to_ipc64_perm - convert kernel ipc permissions to user | 568 | * kernel_to_ipc64_perm - convert kernel ipc permissions to user |
576 | * @in: kernel permissions | 569 | * @in: kernel permissions |
577 | * @out: new style IPC permissions | 570 | * @out: new style ipc permissions |
578 | * | 571 | * |
579 | * Turn the kernel object @in into a set of permissions descriptions | 572 | * Turn the kernel object @in into a set of permissions descriptions |
580 | * for returning to userspace (@out). | 573 | * for returning to userspace (@out). |
581 | */ | 574 | */ |
582 | |||
583 | |||
584 | void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out) | 575 | void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out) |
585 | { | 576 | { |
586 | out->key = in->key; | 577 | out->key = in->key; |
@@ -593,14 +584,13 @@ void kernel_to_ipc64_perm(struct kern_ipc_perm *in, struct ipc64_perm *out) | |||
593 | } | 584 | } |
594 | 585 | ||
595 | /** | 586 | /** |
596 | * ipc64_perm_to_ipc_perm - convert new ipc permissions to old | 587 | * ipc64_perm_to_ipc_perm - convert new ipc permissions to old |
597 | * @in: new style IPC permissions | 588 | * @in: new style ipc permissions |
598 | * @out: old style IPC permissions | 589 | * @out: old style ipc permissions |
599 | * | 590 | * |
600 | * Turn the new style permissions object @in into a compatibility | 591 | * Turn the new style permissions object @in into a compatibility |
601 | * object and store it into the @out pointer. | 592 | * object and store it into the @out pointer. |
602 | */ | 593 | */ |
603 | |||
604 | void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out) | 594 | void ipc64_perm_to_ipc_perm(struct ipc64_perm *in, struct ipc_perm *out) |
605 | { | 595 | { |
606 | out->key = in->key; | 596 | out->key = in->key; |
@@ -635,8 +625,8 @@ struct kern_ipc_perm *ipc_obtain_object(struct ipc_ids *ids, int id) | |||
635 | } | 625 | } |
636 | 626 | ||
637 | /** | 627 | /** |
638 | * ipc_lock - Lock an ipc structure without rwsem held | 628 | * ipc_lock - lock an ipc structure without rwsem held |
639 | * @ids: IPC identifier set | 629 | * @ids: ipc identifier set |
640 | * @id: ipc id to look for | 630 | * @id: ipc id to look for |
641 | * | 631 | * |
642 | * Look for an id in the ipc ids idr and lock the associated ipc object. | 632 | * Look for an id in the ipc ids idr and lock the associated ipc object. |
@@ -693,11 +683,11 @@ out: | |||
693 | 683 | ||
694 | /** | 684 | /** |
695 | * ipcget - Common sys_*get() code | 685 | * ipcget - Common sys_*get() code |
696 | * @ns : namsepace | 686 | * @ns: namsepace |
697 | * @ids : IPC identifier set | 687 | * @ids: ipc identifier set |
698 | * @ops : operations to be called on ipc object creation, permission checks | 688 | * @ops: operations to be called on ipc object creation, permission checks |
699 | * and further checks | 689 | * and further checks |
700 | * @params : the parameters needed by the previous operations. | 690 | * @params: the parameters needed by the previous operations. |
701 | * | 691 | * |
702 | * Common routine called by sys_msgget(), sys_semget() and sys_shmget(). | 692 | * Common routine called by sys_msgget(), sys_semget() and sys_shmget(). |
703 | */ | 693 | */ |
@@ -711,7 +701,7 @@ int ipcget(struct ipc_namespace *ns, struct ipc_ids *ids, | |||
711 | } | 701 | } |
712 | 702 | ||
713 | /** | 703 | /** |
714 | * ipc_update_perm - update the permissions of an IPC. | 704 | * ipc_update_perm - update the permissions of an ipc object |
715 | * @in: the permission given as input. | 705 | * @in: the permission given as input. |
716 | * @out: the permission of the ipc to set. | 706 | * @out: the permission of the ipc to set. |
717 | */ | 707 | */ |
@@ -732,7 +722,7 @@ int ipc_update_perm(struct ipc64_perm *in, struct kern_ipc_perm *out) | |||
732 | 722 | ||
733 | /** | 723 | /** |
734 | * ipcctl_pre_down_nolock - retrieve an ipc and check permissions for some IPC_XXX cmd | 724 | * ipcctl_pre_down_nolock - retrieve an ipc and check permissions for some IPC_XXX cmd |
735 | * @ns: the ipc namespace | 725 | * @ns: ipc namespace |
736 | * @ids: the table of ids where to look for the ipc | 726 | * @ids: the table of ids where to look for the ipc |
737 | * @id: the id of the ipc to retrieve | 727 | * @id: the id of the ipc to retrieve |
738 | * @cmd: the cmd to check | 728 | * @cmd: the cmd to check |
@@ -779,14 +769,13 @@ err: | |||
779 | 769 | ||
780 | 770 | ||
781 | /** | 771 | /** |
782 | * ipc_parse_version - IPC call version | 772 | * ipc_parse_version - ipc call version |
783 | * @cmd: pointer to command | 773 | * @cmd: pointer to command |
784 | * | 774 | * |
785 | * Return IPC_64 for new style IPC and IPC_OLD for old style IPC. | 775 | * Return IPC_64 for new style IPC and IPC_OLD for old style IPC. |
786 | * The @cmd value is turned from an encoding command and version into | 776 | * The @cmd value is turned from an encoding command and version into |
787 | * just the command code. | 777 | * just the command code. |
788 | */ | 778 | */ |
789 | |||
790 | int ipc_parse_version(int *cmd) | 779 | int ipc_parse_version(int *cmd) |
791 | { | 780 | { |
792 | if (*cmd & IPC_64) { | 781 | if (*cmd & IPC_64) { |