diff options
author | peter <peter@FreeBSD.org> | 1997-09-13 11:41:50 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1997-09-13 11:41:50 +0000 |
commit | 763b84b2965e460b085c5f5e2edd1fda366f7841 (patch) | |
tree | 0fe42166fe0a90bad4815970c0a830885b25ff9a /sbin/newfs/mkfs.c | |
parent | feaeba35cd6a2eb29f6751f4ea6527b8966d49c8 (diff) | |
download | FreeBSD-src-763b84b2965e460b085c5f5e2edd1fda366f7841.zip FreeBSD-src-763b84b2965e460b085c5f5e2edd1fda366f7841.tar.gz |
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.
Diffstat (limited to 'sbin/newfs/mkfs.c')
-rw-r--r-- | sbin/newfs/mkfs.c | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/sbin/newfs/mkfs.c b/sbin/newfs/mkfs.c index c95183a..6531437 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 */ |