kernel - shmid_ds structure needs to change on 64-bit :-(
authorMatthew Dillon <dillon@apollo.backplane.com>
Sat, 29 Oct 2011 00:17:30 +0000 (17:17 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Sat, 29 Oct 2011 00:17:30 +0000 (17:17 -0700)
* shmid_ds had very old parameters and used 'int' for the shm segment
  size.  It has to be adjusted to use size_t to accomodate shm segments
  greater than 2GB.

  This will break binary package compatibility on 64-bit systems until
  the related packages are recompiled.

* shmget() system call now takes a size_t instead of an int.

sys/kern/syscalls.master
sys/kern/sysv_shm.c
sys/sys/shm.h

index f8dc2f2..ab0183e 100644 (file)
 229    STD     BSD     { int shmctl(int shmid, int cmd, \
                            struct shmid_ds *buf); }
 230    STD     BSD     { int shmdt(void *shmaddr); }
-231    STD     BSD     { int shmget(key_t key, int size, int shmflg); }
+231    STD     BSD     { int shmget(key_t key, size_t size, int shmflg); }
 ;
 232    STD     POSIX   { int clock_gettime(clockid_t clock_id, \
                            struct timespec *tp); }
index f26e478..83f3ae0 100644 (file)
@@ -131,21 +131,21 @@ struct    shminfo shminfo = {
 
 static int shm_use_phys;
 
-TUNABLE_INT("kern.ipc.shmmin", &shminfo.shmmin);
-TUNABLE_INT("kern.ipc.shmmni", &shminfo.shmmni);
-TUNABLE_INT("kern.ipc.shmseg", &shminfo.shmseg);
-TUNABLE_INT("kern.ipc.shmmaxpgs", &shminfo.shmall);
+TUNABLE_LONG("kern.ipc.shmmin", &shminfo.shmmin);
+TUNABLE_LONG("kern.ipc.shmmni", &shminfo.shmmni);
+TUNABLE_LONG("kern.ipc.shmseg", &shminfo.shmseg);
+TUNABLE_LONG("kern.ipc.shmmaxpgs", &shminfo.shmall);
 TUNABLE_INT("kern.ipc.shm_use_phys", &shm_use_phys);
 
-SYSCTL_INT(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, shmmax, CTLFLAG_RW, &shminfo.shmmax, 0,
     "Max shared memory segment size");
-SYSCTL_INT(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, shmmin, CTLFLAG_RW, &shminfo.shmmin, 0,
     "Min shared memory segment size");
-SYSCTL_INT(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RD, &shminfo.shmmni, 0,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, shmmni, CTLFLAG_RD, &shminfo.shmmni, 0,
     "Max number of shared memory identifiers");
-SYSCTL_INT(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RW, &shminfo.shmseg, 0,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, shmseg, CTLFLAG_RW, &shminfo.shmseg, 0,
     "Max shared memory segments per process");
-SYSCTL_INT(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0,
+SYSCTL_LONG(_kern_ipc, OID_AUTO, shmall, CTLFLAG_RW, &shminfo.shmall, 0,
     "Max pages of shared memory");
 SYSCTL_INT(_kern_ipc, OID_AUTO, shm_use_phys, CTLFLAG_RW, &shm_use_phys, 0,
     "Use phys pager allocation instead of swap pager allocation");
@@ -227,7 +227,7 @@ sys_shmdt(struct shmdt_args *uap)
        struct thread *td = curthread;
        struct proc *p = td->td_proc;
        struct shmmap_state *shmmap_s;
-       int i;
+       long i;
        int error;
 
        if (!jail_sysvipc_allowed && td->td_ucred->cr_prison != NULL)
@@ -261,7 +261,8 @@ sys_shmat(struct shmat_args *uap)
 {
        struct thread *td = curthread;
        struct proc *p = td->td_proc;
-       int error, i, flags;
+       int error, flags;
+       long i;
        struct shmid_ds *shmseg;
        struct shmmap_state *shmmap_s = NULL;
        struct shm_handle *shm_handle;
index 178f097..0053fca 100644 (file)
 
 struct shmid_ds {
        struct ipc_perm shm_perm;       /* operation permission structure */
-       int             shm_segsz;      /* size of segment in bytes */
+       size_t          shm_segsz;      /* size of segment in bytes */
        pid_t           shm_lpid;   /* process ID of last shared memory op */
        pid_t           shm_cpid;       /* process ID of creator */
-       short           shm_nattch;     /* number of current attaches */
+       int             shm_nattch;     /* number of current attaches */
        time_t          shm_atime;      /* time of last shmat() */
        time_t          shm_dtime;      /* time of last shmdt() */
        time_t          shm_ctime;      /* time of last change by shmctl() */
@@ -71,7 +71,7 @@ struct shmid_ds {
  * might be of interest to user programs.  Do we really want/need this?
  */
 struct shminfo {
-       int     shmmax,         /* max shared memory segment size (bytes) */
+       long    shmmax,         /* max shared memory segment size (bytes) */
                shmmin,         /* min shared memory segment size (bytes) */
                shmmni,         /* max number of shared memory identifiers */
                shmseg,         /* max shared memory segments per process */