patch-2.3.17 linux/ipc/shm.c
Next file: linux/kernel/exec_domain.c
Previous file: linux/init/main.c
Back to the patch index
Back to the overall index
- Lines: 81
- Date:
Tue Sep 7 10:55:54 1999
- Orig file:
v2.3.16/linux/ipc/shm.c
- Orig date:
Tue Aug 31 17:29:15 1999
diff -u --recursive --new-file v2.3.16/linux/ipc/shm.c linux/ipc/shm.c
@@ -372,7 +372,7 @@
* shmd->vm_next next attach for task
* shmd->vm_next_share next attach for segment
* shmd->vm_offset offset into segment
- * shmd->vm_pte signature for this attach
+ * shmd->vm_private_data signature for this attach
*/
static struct vm_operations_struct shm_vm_ops = {
@@ -511,7 +511,7 @@
goto out;
}
- shmd->vm_pte = SWP_ENTRY(SHM_SWP_TYPE, id);
+ shmd->vm_private_data = shm_segs + id;
shmd->vm_start = addr;
shmd->vm_end = addr + shp->shm_npages * PAGE_SIZE;
shmd->vm_mm = current->mm;
@@ -547,16 +547,10 @@
/* This is called by fork, once for every shm attach. */
static void shm_open (struct vm_area_struct *shmd)
{
- unsigned int id;
struct shmid_kernel *shp;
lock_kernel();
- id = SWP_OFFSET(shmd->vm_pte) & SHM_ID_MASK;
- shp = shm_segs[id];
- if (shp == IPC_UNUSED) {
- printk("shm_open: unused id=%d PANIC\n", id);
- return;
- }
+ shp = *(struct shmid_kernel **) shmd->vm_private_data;
insert_attach(shp,shmd); /* insert shmd into shp->attaches */
shp->u.shm_nattch++;
shp->u.shm_atime = CURRENT_TIME;
@@ -573,17 +567,17 @@
static void shm_close (struct vm_area_struct *shmd)
{
struct shmid_kernel *shp;
- int id;
lock_kernel();
/* remove from the list of attaches of the shm segment */
- id = SWP_OFFSET(shmd->vm_pte) & SHM_ID_MASK;
- shp = shm_segs[id];
+ shp = *(struct shmid_kernel **) shmd->vm_private_data;
remove_attach(shp,shmd); /* remove from shp->attaches */
shp->u.shm_lpid = current->pid;
shp->u.shm_dtime = CURRENT_TIME;
- if (--shp->u.shm_nattch <= 0 && shp->u.shm_perm.mode & SHM_DEST)
+ if (--shp->u.shm_nattch <= 0 && shp->u.shm_perm.mode & SHM_DEST) {
+ unsigned int id = (struct shmid_kernel **)shmd->vm_private_data - shm_segs;
killseg (id);
+ }
unlock_kernel();
}
@@ -628,20 +622,12 @@
{
pte_t pte;
struct shmid_kernel *shp;
- unsigned int id, idx;
+ unsigned int idx;
unsigned long page;
struct page * page_map;
- id = SWP_OFFSET(shmd->vm_pte) & SHM_ID_MASK;
+ shp = *(struct shmid_kernel **) shmd->vm_private_data;
idx = (address - shmd->vm_start + shmd->vm_offset) >> PAGE_SHIFT;
-
-#ifdef DEBUG_SHM
- if (id > max_shmid) {
- printk ("shm_nopage: id=%d too big. proc mem corrupted\n", id);
- return 0;
- }
-#endif
- shp = shm_segs[id];
#ifdef DEBUG_SHM
if (shp == IPC_UNUSED || shp == IPC_NOID) {
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)