| 
     
      
      
      From: Jeff D. <jd...@ka...> - 2000-08-26 22:13:40
       
   | 
an...@su... said: > To link the final `linux` executable I need this patch: Thanks. I think gcc must have changed its behavior at some point because obviously I don't see that problem. Jeff  | 
| 
     
      
      
      From: Jeff D. <jd...@ka...> - 2000-08-27 18:52:35
       
   | 
> This patch seems to work for both cases (I now reach "Kernel panic: > VFS: Unable to mount root fs on 62:00" at least :) Thanks. I'll look this over and apply it. Jeff  | 
| 
     
      
      
      From: Jeff D. <jd...@ka...> - 2000-08-28 19:17:21
       
   | 
an...@su... said: > This below other patch allows me to run user mode linux. Thanks again for that. I was beginning to wonder whether you were having any success at all :) > The 0x40000000-0x40002000 was part of the kernel_maps because during > the read_map function such 0x40000000-0x40002000 vma was present: > 40000000-40002000 rw-p 0000000000000000 00:00 0 That's bogus. That has to go away because that's where shared libraries are going to load. Whatever mapped that memory there is going to be surprised when it finds a shared library there. Jeff  | 
| 
     
      
      
      From: Andrea A. <an...@su...> - 2000-08-29 10:15:12
       
   | 
On Mon, 28 Aug 2000, Jeff Dike wrote: >I was beginning to wonder whether you were having any success at all :) I had success after that :)) >> The 0x40000000-0x40002000 was part of the kernel_maps because during >> the read_map function such 0x40000000-0x40002000 vma was present: > >> 40000000-40002000 rw-p 0000000000000000 00:00 0 > >That's bogus. That has to go away because that's where shared libraries are >going to load. Whatever mapped that memory there is going to be surprised Yes. Andrea  | 
| 
     
      
      
      From: Jeff D. <jd...@ka...> - 2000-08-31 14:20:12
       
   | 
an...@su... said: > This below other patch allows me to run user mode linux. I've put it in and it seems to be fine. I got rid of your heuristics for choosing between two conflicting maps. Instead, I made the code more careful about blocking off the 0x40000000-0x60000000 region so that any mallocs that happen get mapped outside that area. In your case, that mystery mapping turns out to be from the stdio library mallocing a page or two as a buffer. Have you managed to get uml booting beyond "init=/bin/sh"? As far as I'm concerned, your problems are over now :-) Jeff  | 
| 
     
      
      
      From: Andrea A. <an...@su...> - 2000-08-31 15:01:00
       
   | 
On Thu, 31 Aug 2000, Jeff Dike wrote: >I got rid of your heuristics for choosing between two conflicting maps. >Instead, I made the code more careful about blocking off the >0x40000000-0x60000000 region so that any mallocs that happen get mapped >outside that area. Ok, fine. >In your case, that mystery mapping turns out to be from the stdio library >mallocing a page or two as a buffer. I guessed that. You were using a buffer on the stack for the read(2) and that's why you didn't needed to explicitly skip the malloced area. I believe that the change will give more robusteness to the virtual boot process. >Have you managed to get uml booting beyond "init=/bin/sh"? As far as I'm >concerned, your problems are over now :-) Yes, I booted into the resque disk just fine (I only had to change some bit in the /sbin/init.d/boot /etc/fstab w.r.t. to devfs and /devfs/ubd/0 :) Thanks, Andrea  | 
| 
     
      
      
      From: Bjorn E. <md...@al...> - 2000-08-31 17:15:25
       
   | 
Hi list, I'm trying to boot dos under um-linux but didn't get very far. The first road-block was that /proc/cpuinfo doesn't provide much useful info. But even after I've unmounted /proc and created a fake cpuinfo-file dos-emu complains that "vm86plus service not available in your kernel". I'm using UM-Linux to create and debug my embedded rootfs. Very useful stuff, thanks to everyone involved. //Björnen.  | 
| 
     
      
      
      From: Andrea A. <an...@su...> - 2000-08-27 17:00:50
       
   | 
On Sat, 26 Aug 2000, Jeff Dike wrote:
>an...@su... said:
>> To link the final `linux` executable I need this patch: 
>
>Thanks.  
Other problem, with 2.2.x lfs the maps file looks like this:
andrea@laser:~ > cat /proc/self/maps 
08048000-0804b000 r-xp 0000000000000000 03:02 55341      /bin/cat
0804b000-0804c000 rw-p 0000000000002000 03:02 55341      /bin/cat
40000000-40013000 r-xp 0000000000000000 03:02 61507      /lib/ld-2.1.2.so
40013000-40014000 rw-p 0000000000012000 03:02 61507      /lib/ld-2.1.2.so
40014000-40015000 rwxp 0000000000000000 00:00 0
4001e000-40111000 r-xp 0000000000000000 03:02 61512      /lib/libc.so.6
40111000-40115000 rw-p 00000000000f2000 03:02 61512      /lib/libc.so.6
40115000-40119000 rw-p 0000000000000000 00:00 0
bfffe000-c0000000 rwxp fffffffffffff000 00:00 0
Due LFS the file offset of the mapping can go over 2G. On 2.4.x we still
print only 8 chars but it can overflow and it can print corrupted
results, while 2.2.x-LFS handle that correctly but ./linux fails.
This patch seems to work for both cases (I now reach "Kernel panic: VFS:
Unable to mount root fs on 62:00" at least :)
--- ./arch/um/include/user_util.h.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/include/user_util.h	Sun Aug 27 18:12:07 2000
@@ -12,12 +12,6 @@
 extern int unlockpt(int __fd);
 extern char *ptsname(int __fd);
 
-#define LONG_LEN (8)
-#define PERM_LEN (4)
-#define DEV_LEN (2)
-#define LONG_DEC_LEN (10)
-#define SIG_LEN (2)
-
 #ifndef	_UNISTD_H
 extern int write(int, const char *, int);
 #endif
@@ -56,12 +50,12 @@
 
 extern int physmem_inode;
 
-extern int open_maps(void);
-extern int read_map(int fd, unsigned long *start_out, unsigned long *end_out,
+extern void * open_maps(void);
+extern int read_map(void *, unsigned long *start_out, unsigned long *end_out,
 		    char *r_out, char *w_out, char *x_out, char *p_out, 
-		    unsigned long *offset_out, unsigned long *major_out, 
+		    unsigned long long *offset_out, unsigned long *major_out, 
 		    unsigned long *minor_out, unsigned int *inode_out);
-extern void close_maps(int fd);
+extern void close_maps(void *);
 extern unsigned long get_brk(void);
 extern int file_size(char *file);
 extern void stop(void);
--- ./arch/um/kernel/mem.c.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/kernel/mem.c	Sun Aug 27 18:12:35 2000
@@ -38,17 +38,19 @@
 
 static void add_process_vmas(void)
 {
-	unsigned long start, end, offset, major, minor;
-	int fd, inode;
+	unsigned long start, end, major, minor;
+	unsigned long long offset;
+	int inode;
 	char rperm, wperm, xperm, private;
+	void * maps;
 
-	fd = open_maps();
-	while(read_map(fd, &start, &end, &rperm, &wperm, &xperm, &private, 
+	maps = open_maps();
+	while(read_map(maps, &start, &end, &rperm, &wperm, &xperm, &private, 
 		       &offset, &major, &minor, &inode)){
 		add_perm_vma(start, end, rperm, wperm, xperm, private, offset);
 	}
 	add_perm_vma(high_physmem, end_vm, 'r', 'w', 'x', '-', 0);
-	close_maps(fd);
+	close_maps(maps);
 }
 
 void mem_init(void)
--- ./arch/um/kernel/user_util.c.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/kernel/user_util.c	Sun Aug 27 18:14:38 2000
@@ -23,78 +23,69 @@
 #include "kern_util.h"
 #include "user.h"
 
-int open_maps(void)
+static int create_vm_file(unsigned long len)
 {
 	int fd;
-	char proc_map[sizeof("/proc/#####/maps")];
+	char zero;
 
-	sprintf(proc_map, "/proc/%d/maps", getpid());
-	fd = open(proc_map, O_RDONLY, 0);
-	if(fd < 0){
-		perror("open_maps");
+	if((fd = open("vm_file", O_RDWR | O_CREAT | O_EXCL, 0777)) < 0){
+		perror("open - cannot create ./vm_file");
+		exit(1);
+	}
+	if(unlink("vm_file") < 0){
+		perror("unlink");
+		exit(1);
+	}
+	if(lseek(fd, len, SEEK_SET) < 0){
+		perror("lseek");
+		exit(1);
+	}
+	zero = 0;
+	if(write(fd, &zero, 1) != 1){
+		perror("write");
 		exit(1);
 	}
 	return(fd);
 }
 
-static char *read_one_map(int fd, char *buf, int fixed, int var)
+void * open_maps(void)
 {
-	int i, res;
-	char *ptr, c;
+	FILE * maps;
 
-	res = read(fd, buf, fixed);
-	if(res == 0) return(NULL);
-	else if(res < fixed){
-		perror("Reading fixed portion of map");
-		exit(1);
-	}
-	ptr = &buf[fixed];
-	for(i=0;i<var;i++){
-		res = read(fd, ptr, 1);
-		if(res < 1){
-			perror("Reading fixed portion of map");
-			exit(1);
-		}
-		if(*ptr == ' '){
-			*ptr = '\0';
-			break;
-		}
-		else if(*ptr == '\n'){
-			*ptr = '\0';
-			return(buf);
-		}
-		ptr++;
-	}
-	do {
-		res = read(fd, &c, 1);
-		if(res < 1){
-			perror("Reading variable portion of map");
-			exit(1);
-		}
-	} while(c != '\n');
-	return(buf);
-}
+	maps = fopen("/proc/self/maps", "r");
+	if(!maps)
+		perror("open_maps") , exit(1);
 
-#define MAP_FIXED_LEN (LONG_LEN + 1 + LONG_LEN + 1 + PERM_LEN + 1 + \
-			   LONG_LEN + 1 + DEV_LEN + 1 + DEV_LEN + 1)
-#define MAP_VAR_LEN (LONG_DEC_LEN)
+	return maps;
+}
 
-int read_map(int fd, unsigned long *start_out, unsigned long *end_out,
+int read_map(void * maps, unsigned long *start_out, unsigned long *end_out,
 	     char *r_out, char *w_out, char *x_out, char *p_out, 
-	     unsigned long *offset_out, unsigned long *major_out, 
+	     unsigned long long *offset_out, unsigned long *major_out, 
 	     unsigned long *minor_out, unsigned int *inode_out)
 {
 	unsigned int inode;
-	unsigned long start, end, major, minor, offset;
-	char map_buf[MAP_FIXED_LEN + MAP_VAR_LEN], r, w, x, p;
-
-	if(read_one_map(fd, map_buf, MAP_FIXED_LEN, MAP_VAR_LEN) == NULL)
-		return(0);
-	if(sscanf(map_buf, "%lx-%lx %c%c%c%c %lx %lx:%lx %d", &start, &end, &r, &w,
-		  &x, &p, &offset, &major, &minor, &inode) != 10){
-		perror("Scanning a map line");
-		exit(1);
+	unsigned long start, end, major, minor, ret;
+	unsigned long long offset;
+	char r, w, x, p;
+	char seek;
+	FILE * __maps = (FILE *) maps;
+
+	ret = fscanf(__maps, "%lx-%lx %c%c%c%c %Lx %lx:%lx %d", &start, &end, &r, &w,
+		     &x, &p, &offset, &major, &minor, &inode);
+
+	if (ret == EOF)
+		return 0;
+	if (ret != 10)
+		perror("Scanning a map line"),	exit(1);
+
+	for (;;) {
+		if (!fread(&seek, 1, 1, __maps))
+			perror("Seeking a map line"), exit(1);
+		if (seek == '\n')
+			break;
 	}
+
 	if(start_out != NULL) *start_out = start;
 	if(end_out != NULL) *end_out = end;
 	if(r_out != NULL) *r_out = r;
@@ -108,45 +99,24 @@
 	return(1);
 }
 
-void close_maps(int fd)
+void close_maps(void * maps)
 {
-	close(fd);
-}
-
-static int create_vm_file(unsigned long len)
-{
-	int fd;
-	char zero;
+	FILE * __maps = (FILE *) maps;
 
-	if((fd = open("vm_file", O_RDWR | O_CREAT | O_EXCL, 0777)) < 0){
-		perror("open - cannot create ./vm_file");
-		exit(1);
-	}
-	if(unlink("vm_file") < 0){
-		perror("unlink");
-		exit(1);
-	}
-	if(lseek(fd, len, SEEK_SET) < 0){
-		perror("lseek");
-		exit(1);
-	}
-	zero = 0;
-	if(write(fd, &zero, 1) != 1){
-		perror("write");
-		exit(1);
-	}
-	return(fd);
+	if (fclose(__maps) == EOF)
+		perror("close_maps"), exit(1);
 }
 
 void remap_data(void *segment_start, void *segment_end)
 {
 	void *addr;
 	unsigned long start, end, size;
-	int fd, data, prot;
+	int data, prot;
 	char r, w, x;
+	void * maps;
 
-	fd = open_maps();
-	while(read_map(fd, &start, &end, &r, &w, &x, NULL, NULL, NULL, NULL, 
+	maps = open_maps();
+	while(read_map(maps, &start, &end, &r, &w, &x, NULL, NULL, NULL, NULL, 
 		       NULL) != 0){
 		if(((unsigned long) segment_start >= start) && 
 		   ((unsigned long) segment_end <= end)){
@@ -165,7 +135,7 @@
 				printf("switcheroo failed\n");
 				exit(1);
 			}
-			close_maps(fd);
+			close_maps(maps);
 			return;
 		}
 	}
--- ./arch/um/kernel/tlb.c.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/kernel/tlb.c	Sun Aug 27 18:13:26 2000
@@ -235,12 +235,13 @@
 	struct vm_area_struct *vma;
 
 	if(process_vmas == NULL){
-		int fd, count = 0;
-		fd = open_maps();
-		while(read_map(fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
+		int count = 0;
+		void * maps;
+		maps = open_maps();
+		while(read_map(maps, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
 			       NULL, NULL, NULL))
 			count++;
-		close_maps(fd);
+		close_maps(maps);
 		process_vmas = alloc_bootmem((count + 1) * 
 					     sizeof(*process_vmas));
 		if(process_vmas == NULL)
Andrea
 | 
| 
     
      
      
      From: Andrea A. <an...@su...> - 2000-08-28 17:51:13
       
   | 
On Sun, 27 Aug 2000, Andrea Arcangeli wrote:
>This patch seems to work for both cases (I now reach "Kernel panic: VFS:
>Unable to mount root fs on 62:00" at least :)
This below other patch allows me to run user mode linux.
There was a bug where two overlapping vmas was inserted (not sure if that 
bug was triggered by my changes to the read_map that uses the stdio
library, maybe some dynamic allocation caused that vma to show up).
load_elf_interp was inserting 0x40000000-0x40006000 into the kernel_maps
during elf_map() and then later start_thread was calling add_kernel_vma
that was inserting 0x40000000-0x40002000 that overlaps with the previous
one loaded by the elf interpreter. This caused the vma list to become
corrupted.
The 0x40000000-0x40002000 was part of the kernel_maps because during the
read_map function such 0x40000000-0x40002000 vma was present:
andrea@inspiron:~ > cat /proc/11595/maps
10000000-10001000 r-xp 0000000000000000 03:06 775062     /home/andrea/kernel/devel/2.4.0-test7-umk/linux
10001000-1011f000 rwxs 0000000000000000 03:06 775063     /home/andrea/kernel/devel/2.4.0-test7-umk/vm_file (deleted)
1011f000-10131000 rwxs 0000000000000000 03:06 775069     /home/andrea/kernel/devel/2.4.0-test7-umk/vm_file (deleted)
10131000-1016c000 rwxs 0000000000000000 03:06 775070     /home/andrea/kernel/devel/2.4.0-test7-umk/vm_file (deleted)
1016c000-1016d000 rwxp 000000000003b000 00:00 0
40000000-40002000 rw-p 0000000000000000 00:00 0
50000000-51000000 rw-s 0000000000000000 03:06 775071     /home/andrea/kernel/devel/2.4.0-test7-umk/vm_file (deleted)
bffff000-c0000000 rwxp 0000000000000000 00:00 0
That seems plain anonymous memory and at the time of the read_maps (during
add_process_vmas while building the kernel_maps vma list) it was the only
one with priority rw-p, so I identifyed it as the one with such priority
to avoid to add it to the kernel_maps. Now I can boot fine using `./linux
init=/bin/bash'.
There was also a little bug while setting the vm_pgoff that have page
granularity. New patch below against test7-1um.
--- ./arch/um/include/user_util.h.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/include/user_util.h	Sun Aug 27 18:12:07 2000
@@ -12,12 +12,6 @@
 extern int unlockpt(int __fd);
 extern char *ptsname(int __fd);
 
-#define LONG_LEN (8)
-#define PERM_LEN (4)
-#define DEV_LEN (2)
-#define LONG_DEC_LEN (10)
-#define SIG_LEN (2)
-
 #ifndef	_UNISTD_H
 extern int write(int, const char *, int);
 #endif
@@ -56,12 +50,12 @@
 
 extern int physmem_inode;
 
-extern int open_maps(void);
-extern int read_map(int fd, unsigned long *start_out, unsigned long *end_out,
+extern void * open_maps(void);
+extern int read_map(void *, unsigned long *start_out, unsigned long *end_out,
 		    char *r_out, char *w_out, char *x_out, char *p_out, 
-		    unsigned long *offset_out, unsigned long *major_out, 
+		    unsigned long long *offset_out, unsigned long *major_out, 
 		    unsigned long *minor_out, unsigned int *inode_out);
-extern void close_maps(int fd);
+extern void close_maps(void *);
 extern unsigned long get_brk(void);
 extern int file_size(char *file);
 extern void stop(void);
--- ./arch/um/include/kern_util.h.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/include/kern_util.h	Mon Aug 28 03:17:42 2000
@@ -58,7 +58,7 @@
 extern void ret_from_sys_call(void *t);
 extern void add_perm_vma(unsigned long start, unsigned long end, char rperm,
 			 char wperm, char xperm, char private, 
-			 unsigned long offset);
+			 unsigned long long offset);
 extern void kern_finish_exec(void *task, unsigned long ip, unsigned long sp, 
 			     int pid);
 extern int page_size(void);
--- ./arch/um/kernel/mem.c.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/kernel/mem.c	Mon Aug 28 04:09:42 2000
@@ -38,17 +38,21 @@
 
 static void add_process_vmas(void)
 {
-	unsigned long start, end, offset, major, minor;
-	int fd, inode;
+	unsigned long start, end, major, minor;
+	unsigned long long offset;
+	int inode;
 	char rperm, wperm, xperm, private;
+	void * maps;
 
-	fd = open_maps();
-	while(read_map(fd, &start, &end, &rperm, &wperm, &xperm, &private, 
+	maps = open_maps();
+	while(read_map(maps, &start, &end, &rperm, &wperm, &xperm, &private, 
 		       &offset, &major, &minor, &inode)){
+		if (rperm == 'r' && wperm == 'w' && xperm == '-' && private == 'p')
+			continue;
 		add_perm_vma(start, end, rperm, wperm, xperm, private, offset);
 	}
 	add_perm_vma(high_physmem, end_vm, 'r', 'w', 'x', '-', 0);
-	close_maps(fd);
+	close_maps(maps);
 }
 
 void mem_init(void)
--- ./arch/um/kernel/user_util.c.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/kernel/user_util.c	Mon Aug 28 00:09:55 2000
@@ -23,78 +23,69 @@
 #include "kern_util.h"
 #include "user.h"
 
-int open_maps(void)
+static int create_vm_file(unsigned long len)
 {
 	int fd;
-	char proc_map[sizeof("/proc/#####/maps")];
+	char zero;
 
-	sprintf(proc_map, "/proc/%d/maps", getpid());
-	fd = open(proc_map, O_RDONLY, 0);
-	if(fd < 0){
-		perror("open_maps");
+	if((fd = open("vm_file", O_RDWR | O_CREAT | O_EXCL, 0777)) < 0){
+		perror("open - cannot create ./vm_file");
+		exit(1);
+	}
+	if(unlink("vm_file") < 0){
+		perror("unlink");
+		exit(1);
+	}
+	if(lseek(fd, len, SEEK_SET) < 0){
+		perror("lseek");
+		exit(1);
+	}
+	zero = 0;
+	if(write(fd, &zero, 1) != 1){
+		perror("write");
 		exit(1);
 	}
 	return(fd);
 }
 
-static char *read_one_map(int fd, char *buf, int fixed, int var)
+void * open_maps(void)
 {
-	int i, res;
-	char *ptr, c;
+	FILE * maps;
 
-	res = read(fd, buf, fixed);
-	if(res == 0) return(NULL);
-	else if(res < fixed){
-		perror("Reading fixed portion of map");
-		exit(1);
-	}
-	ptr = &buf[fixed];
-	for(i=0;i<var;i++){
-		res = read(fd, ptr, 1);
-		if(res < 1){
-			perror("Reading fixed portion of map");
-			exit(1);
-		}
-		if(*ptr == ' '){
-			*ptr = '\0';
-			break;
-		}
-		else if(*ptr == '\n'){
-			*ptr = '\0';
-			return(buf);
-		}
-		ptr++;
-	}
-	do {
-		res = read(fd, &c, 1);
-		if(res < 1){
-			perror("Reading variable portion of map");
-			exit(1);
-		}
-	} while(c != '\n');
-	return(buf);
-}
+	maps = fopen("/proc/self/maps", "r");
+	if(!maps)
+		perror("open_maps") , exit(1);
 
-#define MAP_FIXED_LEN (LONG_LEN + 1 + LONG_LEN + 1 + PERM_LEN + 1 + \
-			   LONG_LEN + 1 + DEV_LEN + 1 + DEV_LEN + 1)
-#define MAP_VAR_LEN (LONG_DEC_LEN)
+	return maps;
+}
 
-int read_map(int fd, unsigned long *start_out, unsigned long *end_out,
+int read_map(void * maps, unsigned long *start_out, unsigned long *end_out,
 	     char *r_out, char *w_out, char *x_out, char *p_out, 
-	     unsigned long *offset_out, unsigned long *major_out, 
+	     unsigned long long *offset_out, unsigned long *major_out, 
 	     unsigned long *minor_out, unsigned int *inode_out)
 {
 	unsigned int inode;
-	unsigned long start, end, major, minor, offset;
-	char map_buf[MAP_FIXED_LEN + MAP_VAR_LEN], r, w, x, p;
-
-	if(read_one_map(fd, map_buf, MAP_FIXED_LEN, MAP_VAR_LEN) == NULL)
-		return(0);
-	if(sscanf(map_buf, "%lx-%lx %c%c%c%c %lx %lx:%lx %d", &start, &end, &r, &w,
-		  &x, &p, &offset, &major, &minor, &inode) != 10){
-		perror("Scanning a map line");
-		exit(1);
+	unsigned long start, end, major, minor, ret;
+	unsigned long long offset;
+	char r, w, x, p;
+	char seek;
+	FILE * __maps = (FILE *) maps;
+
+	ret = fscanf(__maps, "%lx-%lx %c%c%c%c %Lx %lx:%lx %d", &start, &end, &r, &w,
+		     &x, &p, &offset, &major, &minor, &inode);
+
+	if (ret == EOF)
+		return 0;
+	if (ret != 10)
+		perror("Scanning a map line"),	exit(1);
+
+	for (;;) {
+		if (!fread(&seek, 1, 1, __maps))
+			perror("Seeking a map line"), exit(1);
+		if (seek == '\n')
+			break;
 	}
+
 	if(start_out != NULL) *start_out = start;
 	if(end_out != NULL) *end_out = end;
 	if(r_out != NULL) *r_out = r;
@@ -108,45 +99,24 @@
 	return(1);
 }
 
-void close_maps(int fd)
+void close_maps(void * maps)
 {
-	close(fd);
-}
-
-static int create_vm_file(unsigned long len)
-{
-	int fd;
-	char zero;
+	FILE * __maps = (FILE *) maps;
 
-	if((fd = open("vm_file", O_RDWR | O_CREAT | O_EXCL, 0777)) < 0){
-		perror("open - cannot create ./vm_file");
-		exit(1);
-	}
-	if(unlink("vm_file") < 0){
-		perror("unlink");
-		exit(1);
-	}
-	if(lseek(fd, len, SEEK_SET) < 0){
-		perror("lseek");
-		exit(1);
-	}
-	zero = 0;
-	if(write(fd, &zero, 1) != 1){
-		perror("write");
-		exit(1);
-	}
-	return(fd);
+	if (fclose(__maps) == EOF)
+		perror("close_maps"), exit(1);
 }
 
 void remap_data(void *segment_start, void *segment_end)
 {
 	void *addr;
 	unsigned long start, end, size;
-	int fd, data, prot;
+	int data, prot;
 	char r, w, x;
+	void * maps;
 
-	fd = open_maps();
-	while(read_map(fd, &start, &end, &r, &w, &x, NULL, NULL, NULL, NULL, 
+	maps = open_maps();
+	while(read_map(maps, &start, &end, &r, &w, &x, NULL, NULL, NULL, NULL, 
 		       NULL) != 0){
 		if(((unsigned long) segment_start >= start) && 
 		   ((unsigned long) segment_end <= end)){
@@ -165,7 +135,7 @@
 				printf("switcheroo failed\n");
 				exit(1);
 			}
-			close_maps(fd);
+			close_maps(maps);
 			return;
 		}
 	}
--- ./arch/um/kernel/tlb.c.~1~	Sat Aug 26 16:35:04 2000
+++ ./arch/um/kernel/tlb.c	Mon Aug 28 04:10:12 2000
@@ -230,17 +230,22 @@
 static int num_process_vmas = 0;
 
 void add_perm_vma(unsigned long start, unsigned long end, char rperm, 
-		  char wperm, char xperm, char private, unsigned long offset)
+		  char wperm, char xperm, char private, unsigned long long offset)
 {
 	struct vm_area_struct *vma;
 
 	if(process_vmas == NULL){
-		int fd, count = 0;
-		fd = open_maps();
-		while(read_map(fd, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 
-			       NULL, NULL, NULL))
+		int count = 0;
+		char r, w, x, p;
+		void * maps;
+		maps = open_maps();
+		while(read_map(maps, NULL, NULL, &r, &w, &x, &p, NULL, 
+			       NULL, NULL, NULL)) {
+			if (r == 'r' && w == 'w' && x == '-' && p == 'p')
+				continue;
 			count++;
-		close_maps(fd);
+		}
+		close_maps(maps);
 		process_vmas = alloc_bootmem((count + 1) * 
 					     sizeof(*process_vmas));
 		if(process_vmas == NULL)
@@ -251,7 +256,7 @@
 		&kernel_maps, start, end, NULL, 
 		vm_prot(rperm, wperm, xperm, private), 
 		vm_flags(rperm, wperm, xperm, private), 0, NULL, NULL, NULL, 
-		NULL, NULL, offset, NULL, 0
+		NULL, NULL, offset >> PAGE_SIZE, NULL, 0
 	});
 	insert_vm_struct(&kernel_maps, vma);
 }
--- ./arch/um/Makefile.~1~	Sat Aug 26 17:36:29 2000
+++ ./arch/um/Makefile	Sat Aug 26 17:48:28 2000
@@ -47,7 +47,7 @@
 linux: $(ARCH_SYMLINKS) $(ARCH_DIR)/main.o vmlinux $(ARCH_DIR)/link.ld
 	mv vmlinux vmlinux.o
 	gcc -Wl,-T,$(ARCH_DIR)/link.ld $(LINK_PROFILE) -o linux -static \
-		$(ARCH_DIR)/main.o vmlinux.o
+		$(ARCH_DIR)/main.o vmlinux.o -L/usr/lib
 	rm -f $(ARCH_DIR)/link.ld
 
 USER_CFLAGS = $(patsubst -I%,,$(CFLAGS))
Andrea
PS. I'm offlist so CC directly if you want me to read the reply ;)
 |