1 /*- 2 * Copyright (c) 1991 The Regents of the University of California. 3 * All rights reserved. 4 * 5 * %sccs.include.proprietary.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)freeze.c 4.3 (Berkeley) 04/17/91"; 10 #endif /* not lint */ 11 12 #include "stdio.h" 13 freeze(s) char *s; 14 { int fd; 15 unsigned int *len; 16 len = (unsigned int *)sbrk(0); 17 if((fd = creat(s, 0666)) < 0) { 18 perror(s); 19 return(1); 20 } 21 write(fd, &len, sizeof(len)); 22 write(fd, (char *)0, len); 23 close(fd); 24 return(0); 25 } 26 27 thaw(s) char *s; 28 { int fd; 29 unsigned int *len; 30 if(*s == 0) { 31 fprintf(stderr, "empty restore file\n"); 32 return(1); 33 } 34 if((fd = open(s, 0)) < 0) { 35 perror(s); 36 return(1); 37 } 38 read(fd, &len, sizeof(len)); 39 (void) brk(len); 40 read(fd, (char *)0, len); 41 close(fd); 42 return(0); 43 } 44