Fix crash in fsck, when reconnecting lost file.

This commit is contained in:
Serge Vakulenko
2015-09-07 21:31:33 -07:00
parent 0aaf6c25f6
commit 2c41b4d9e1
3 changed files with 10 additions and 14 deletions

View File

@@ -508,7 +508,8 @@ linkup(orphan, pdir)
} }
declncnt(orphan); declncnt(orphan);
*pathp++ = '/'; *pathp++ = '/';
bcopy(idesc.id_name, pathp, len + 1); len = strlen(tempname);
bcopy(tempname, pathp, len + 1);
pathp += len; pathp += len;
if (lostdir) { if (lostdir) {
dp = ginode(orphan); dp = ginode(orphan);

View File

@@ -138,8 +138,6 @@ daddr_t *muldup; /* multiple dups part of table */
ino_t zlnlist[MAXLNCNT]; /* zero link count table */ ino_t zlnlist[MAXLNCNT]; /* zero link count table */
ino_t *zlnp; ino_t *zlnp;
#define MAXDATA (84 * 1024)
#define MEMUNIT 64
#define NINOBLK 4 /* number of blocks of inodes to read at once */ #define NINOBLK 4 /* number of blocks of inodes to read at once */
char inobuf[NINOBLK*INOPB*sizeof (struct dinode)]; /* allocate now */ char inobuf[NINOBLK*INOPB*sizeof (struct dinode)]; /* allocate now */

View File

@@ -24,6 +24,8 @@
extern int returntosingle; extern int returntosingle;
static char memdata[16 * sizeof(BUFAREA)];
char * char *
unrawname(cp) unrawname(cp)
char *cp; char *cp;
@@ -221,12 +223,12 @@ main(argc, argv)
{ {
struct fstab *fsp; struct fstab *fsp;
int pid, passno, anygtr, sumstatus; int pid, passno, anygtr, sumstatus;
char *name, inbuf[128], outbuf[128]; char *name, inbuf[64], outbuf[64], errbuf[64];
extern void _start(); extern void _start();
setbuffer(stdin, inbuf, sizeof (inbuf)); setvbuf(stdin, inbuf, _IOFBF, sizeof (inbuf));
setbuffer(stdout, outbuf, sizeof (outbuf)); setvbuf(stdout, outbuf, _IOLBF, sizeof (outbuf));
setlinebuf(stdout); setvbuf(stderr, errbuf, _IOLBF, sizeof (errbuf));
sync(); sync();
while (--argc > 0 && **++argv == '-') { while (--argc > 0 && **++argv == '-') {
@@ -273,13 +275,8 @@ main(argc, argv)
errexit("Can't open checklist file: %s\n", _PATH_FSTAB); errexit("Can't open checklist file: %s\n", _PATH_FSTAB);
setpassent(1); setpassent(1);
memsize = (char*) sbrk(0) - (char*) &_start; membase = memdata;
memsize = MAXDATA - memsize - sizeof(int); memsize = sizeof(memdata);
while (memsize >= 2 * sizeof(BUFAREA) &&
(membase = (char *)sbrk(memsize)) == (char *)-1)
memsize -= MEMUNIT;
if (memsize < 2 * sizeof(BUFAREA))
errexit("Can't get memory\n");
if (signal(SIGINT, SIG_IGN) != SIG_IGN) if (signal(SIGINT, SIG_IGN) != SIG_IGN)
(void)signal(SIGINT, catch); (void)signal(SIGINT, catch);