aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wemm <peter@FreeBSD.org>1997-09-13 11:41:50 +0000
committerPeter Wemm <peter@FreeBSD.org>1997-09-13 11:41:50 +0000
commit079709dc3a35b68657435a35bdf78b2793691932 (patch)
treeea8b7451a533510b57bba5d3ac935507f23b2673
parentedb0d8e9fcc325435e2954282e9681801deeafa0 (diff)
downloadsrc-079709dc3a35b68657435a35bdf78b2793691932.tar.gz
src-079709dc3a35b68657435a35bdf78b2793691932.zip
Some tweaks to get this to cope with ELF where the address space starts
higher up in memory (0x0800000 upwards) rather than near zero (0x1000 for our qmagic a.out format). The method that mount_mfs uses to allocate the memory within data size rlimits for the ram disk is entirely too much of a kludge for my liking. I mean, if it's run as root, surely it makes sense to just raise the resource limits to infinity or something, and if it's a non-root user mount (do these work? with mfs?) it could just fail if it's outside limits.
Notes
Notes: svn path=/head/; revision=29321
-rw-r--r--sbin/newfs/mkfs.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c
index c95183a3d260..6531437a6c06 100644
--- a/sbin/newfs/mkfs.c
+++ b/sbin/newfs/mkfs.c
@@ -208,9 +208,9 @@ mkfs(pp, fsys, fi, fo)
#ifndef STANDALONE
get_memleft();
#endif
- if (fssize * sectorsize > (memleft - 16384))
- fssize = (memleft - 16384) / sectorsize;
- if ((membase = malloc(fssize * sectorsize)) == 0) {
+ if (fssize * sectorsize > (memleft - 131072))
+ fssize = (memleft - 131072) / sectorsize;
+ if ((membase = malloc(fssize * sectorsize)) == NULL) {
perror("malloc");
exit(13);
}
@@ -1210,18 +1210,28 @@ raise_data_limit()
perror("setrlimit");
}
+#ifdef __ELF__
+extern char *_etext;
+#define etext _etext
+#else
+extern char *etext;
+#endif
+
get_memleft()
{
- char *base;
- static u_long pgsz, i;
+ static u_long pgsz;
struct rlimit rlp;
+ u_long freestart;
+ u_long dstart;
+ u_long memused;
- base = sbrk(0);
pgsz = getpagesize() - 1;
- i = ((u_long)(base + pgsz) &~ pgsz);
+ dstart = ((u_long)&etext) &~ pgsz;
+ freestart = ((u_long)(sbrk(0) + pgsz) &~ pgsz);
if (getrlimit(RLIMIT_DATA, &rlp) < 0)
perror("getrlimit");
- memleft = rlp.rlim_cur - (u_long)base - i;
+ memused = freestart - dstart;
+ memleft = rlp.rlim_cur - memused;
}
#endif /* STANDALONE */