From: ewt Date: Fri, 5 Jan 1996 18:15:57 +0000 (+0000) Subject: began to add faFree(), though it doesn't work yet X-Git-Tag: rpm-4.4-release~5600 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99a43e9240395e10e2b365bd35bdecad717bca37;p=platform%2Fupstream%2Frpm.git began to add faFree(), though it doesn't work yet CVS patchset: 135 CVS date: 1996/01/05 18:15:57 --- diff --git a/lib/falloc.c b/lib/falloc.c index ad524df..119641e 100644 --- a/lib/falloc.c +++ b/lib/falloc.c @@ -205,7 +205,21 @@ unsigned int faAlloc(faFile fa, unsigned int size) { /* returns 0 on failure */ return newBlock + sizeof(block); } -void faFree(faFile fa, unsigned int offset); +int faFree(faFile fa, unsigned int offset) { + struct faBlock block; + + /* this is *really* bad ****/ + + offset -= sizeof(block); + if (lseek(fa->fd, offset, SEEK_SET) < 0) return 0; + if (read(fa->fd, &block, sizeof(block)) != sizeof(block)) return 0; + + block.isFree = 1; + if (lseek(fa->fd, offset, SEEK_SET) < 0) return 0; + if (write(fa->fd, &block, sizeof(block)) != sizeof(block)) return 0; + + return 1; +} void faClose(faFile fa) { close(fa->fd); diff --git a/lib/falloc.h b/lib/falloc.h index 49c2add..1e5adf6 100644 --- a/lib/falloc.h +++ b/lib/falloc.h @@ -18,7 +18,7 @@ typedef struct FaPlace * faPlace; /* flags here is the same as for open(2) - NULL returned on error */ faFile faOpen(char * path, int flags, int perms); unsigned int faAlloc(faFile fa, unsigned int size); /* returns 0 on failure */ -void faFree(faFile fa, unsigned int offset); +int faFree(faFile fa, unsigned int offset); void faClose(faFile fa); unsigned int faFirstOffset(faFile fa);