root/ipc/util.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. ipc_init
  2. ipcperms
  3. sem_exit
  4. shm_swap
  5. sys_semget
  6. sys_semop
  7. sys_semctl
  8. sys_msgget
  9. sys_msgsnd
  10. sys_msgrcv
  11. sys_msgctl
  12. sys_shmget
  13. sys_shmat
  14. sys_shmdt
  15. sys_shmctl
  16. kerneld_exit

   1 /*
   2  * linux/ipc/util.c
   3  * Copyright (C) 1992 Krishna Balasubramanian
   4  */
   5 
   6 #include <linux/config.h>
   7 #include <linux/errno.h>
   8 #include <asm/segment.h>
   9 #include <linux/sched.h>
  10 #include <linux/mm.h>
  11 #include <linux/sem.h>
  12 #include <linux/msg.h>
  13 #include <linux/shm.h>
  14 #include <linux/stat.h>
  15 
  16 #if defined(CONFIG_SYSVIPC) || defined(CONFIG_KERNELD)
  17 
  18 extern void sem_init (void), msg_init (void), shm_init (void);
  19 
  20 void ipc_init (void)
     /* [previous][next][first][last][top][bottom][index][help] */
  21 {
  22         sem_init();
  23         msg_init();
  24         shm_init();
  25         return;
  26 }
  27 
  28 /* 
  29  * Check user, group, other permissions for access
  30  * to ipc resources. return 0 if allowed
  31  */
  32 int ipcperms (struct ipc_perm *ipcp, short flag)
     /* [previous][next][first][last][top][bottom][index][help] */
  33 {       /* flag will most probably be 0 or S_...UGO from <linux/stat.h> */
  34         int requested_mode, granted_mode;
  35 
  36         if (suser())
  37                 return 0;
  38         requested_mode = (flag >> 6) | (flag >> 3) | flag;
  39         granted_mode = ipcp->mode;
  40         if (current->euid == ipcp->cuid || current->euid == ipcp->uid)
  41                 granted_mode >>= 6;
  42         else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
  43                 granted_mode >>= 3;
  44         /* is there some bit set in requested_mode but not in granted_mode? */
  45         if (requested_mode & ~granted_mode & 0007)
  46                 return -1;
  47         return 0;
  48 }
  49 
  50 #else
  51 /*
  52  * Dummy functions when SYSV IPC isn't configured
  53  */
  54 
  55 void sem_exit (void)
     /* [previous][next][first][last][top][bottom][index][help] */
  56 {
  57     return;
  58 }
  59 
  60 int shm_swap (int prio, unsigned long limit)
     /* [previous][next][first][last][top][bottom][index][help] */
  61 {
  62     return 0;
  63 }
  64 
  65 asmlinkage int sys_semget (key_t key, int nsems, int semflg)
     /* [previous][next][first][last][top][bottom][index][help] */
  66 {
  67         return -ENOSYS;
  68 }
  69 
  70 asmlinkage int sys_semop (int semid, struct sembuf *sops, unsigned nsops)
     /* [previous][next][first][last][top][bottom][index][help] */
  71 {
  72         return -ENOSYS;
  73 }
  74 
  75 asmlinkage int sys_semctl (int semid, int semnum, int cmd, union semun arg)
     /* [previous][next][first][last][top][bottom][index][help] */
  76 {
  77         return -ENOSYS;
  78 }
  79 
  80 asmlinkage int sys_msgget (key_t key, int msgflg)
     /* [previous][next][first][last][top][bottom][index][help] */
  81 {
  82         return -ENOSYS;
  83 }
  84 
  85 asmlinkage int sys_msgsnd (int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg)
     /* [previous][next][first][last][top][bottom][index][help] */
  86 {
  87         return -ENOSYS;
  88 }
  89 
  90 asmlinkage int sys_msgrcv (int msqid, struct msgbuf *msgp, size_t msgsz, long msgtyp,
     /* [previous][next][first][last][top][bottom][index][help] */
  91                        int msgflg)
  92 {
  93         return -ENOSYS;
  94 }
  95 
  96 asmlinkage int sys_msgctl (int msqid, int cmd, struct msqid_ds *buf)
     /* [previous][next][first][last][top][bottom][index][help] */
  97 {
  98         return -ENOSYS;
  99 }
 100 
 101 asmlinkage int sys_shmget (key_t key, int size, int flag)
     /* [previous][next][first][last][top][bottom][index][help] */
 102 {
 103         return -ENOSYS;
 104 }
 105 
 106 asmlinkage int sys_shmat (int shmid, char *shmaddr, int shmflg, ulong *addr)
     /* [previous][next][first][last][top][bottom][index][help] */
 107 {
 108         return -ENOSYS;
 109 }
 110 
 111 asmlinkage int sys_shmdt (char *shmaddr)
     /* [previous][next][first][last][top][bottom][index][help] */
 112 {
 113         return -ENOSYS;
 114 }
 115 
 116 asmlinkage int sys_shmctl (int shmid, int cmd, struct shmid_ds *buf)
     /* [previous][next][first][last][top][bottom][index][help] */
 117 {
 118         return -ENOSYS;
 119 }
 120 
 121 void kerneld_exit(void)
     /* [previous][next][first][last][top][bottom][index][help] */
 122 {
 123 }
 124 #endif /* CONFIG_SYSVIPC */

/* [previous][next][first][last][top][bottom][index][help] */