"W:>Reti>big-lmfs-file-patch.lisp.newest"¨(:ELEMENT-TYPE CHARACTER :CREATION-DATE 3073838600 :AUTHOR "Reti" :LENGTH-IN-BYTES 5093)¨;;;-*-mode:!Flisp;package:!Flmfs;!Fbase:!F8;!Flowercase:yes;¨!FPatch-File:!FYes!F-*-"T"T(defstorage!F(block-check-words)"¨T!F!F(file-id"P!F!F!F!F!F!Ffixnum)"T!F!F(word-0s-rel-addr!F!¨F!Fbit!F31.)"P"P"P;get!Fin!Flow!Forder"T!F!F(headerp"P!F!F!F¨!F!F!Fflag))"T"T(defun!Fbitsalv-process-file-buffer!F(svi!Ff¨d!Fbuf!F&aux!F(part!F(svi-partition))!Ffile-id"T"P"P"P"P!F!F¨!F!F(array!F(fb-array!Fbuf)))"T!F!F;;!FTry!Fto!Fpsych!Fout!F¨whether!Fthis!Fguy!Fis!Freally!Fa!Fheader."T"T!F!F(with-fs-l¨ocked-for-salvager"T!F!F!F!F;;!FThe!Ffollowing!Fmacro!Fwill!¨Fdownreference!Fthe!Fbuffer!Fwhen!Fall!Fis!Fsaid!Fand!Fdone.¨%%-731583917¨"T!F!F!F!F(protect-buffer-addressor!F(adr!F(obtain-8bit-addr¨array!Fbuf))"T!F!F!F!F!F!F(set-word-address-in-addressor!Fad¨r!Farray!F0)"P;look!Fat!Fcheck!Fwords"T!F!F!F!F!F!F(when!F(a¨nd!F(not!F(zerop!F(setq!Ffile-id!F(block-check-words-file-id¨!Fadr))))"T"P"P!F(zerop!F(block-check-words-word-0s-rel-addr¨!Fadr))"T"P"P!F(block-check-words-headerp!Fadr)"T"P"P!F(prog¨n!F(set-word-address-in-addressor"T"P"P"P!F!Fadr"T"P"P"P!F!F¨array"T"P"P"P!F!F(-!F(partt-record-size-words!Fpart)"T"P"P"P¨!F!F!F!F!F(block-check-words-size-in-words)))"T"P"P"P(=!Ffil¨e-id!F(block-check-words-file-id!Fadr)))"T"P"P!F(progn!F(set¨%%-246537237¨-word-address-in-addressor"T"P"P"P!F!Fadr"T"P"P"P!F!Farray"T¨"P"P"P!F!F(-!F(partt-block-size-words!Fpart)"T"P"P"P!F!F!F!F¨!F(block-check-words-size-in-words)))"T"P"P"P(=!Ffile-id!F(b¨lock-check-words-file-id!Fadr)))"T"P"P!F;"P!F!F!F!F!F(or!F(a¨nd"T"P"P!F;"P!F!F!F(=!F(block-check-words-word-0s-rel-addr!F¨adr)"T"P"P!F;!F!F!F!F!F(-!F(partt-block-size-words!Fpart)"T"¨P"P!F;!F!F!F!F!F!F!F!F(*!F2!F(block-check-words-size-in-word¨s))))))"T"P"P!F)"T"P(*catch"T"P!F!F'file-header-loses"T"P!F!¨F(bitsalv-process-file-header!Fsvi!Fbuf!Ffile-id))))"T!F!F!F¨!F(salv-free-bufs-for-bogus-file!Ffd)!F!F!F!F"T!F!F!F!F))"T"¨%%110224564¨T;check!Fis!Fnil!Fto!Fstore!Fthe!Fcheck!Fwords,!Ft!Fto!Fchec¨k!Fthem,!Fcollect!Fto!Freturn!Fa!Flist!Fof!Fthem"T(defun!Fpl¨ace-buffer-block-check-words!F(buf!Fcheck)"T!F!F(fs-ckarg-ty¨pe!Fbuf!Ffile-buffer)"T!F!F(let!F((fd!F(fb-file-desc!Fbuf))"¨T"P(r0p!F(=!F(fb-lowest-header-addr!Fbuf)!F0)))"T!F!F!F!F(if¨!F(null!Ffd)"T"Pt"P"P"P"P"P"P;return!Fas!Fif!Fcheck!Fcase!Fa¨nyway"T"P(protect-buffer-addressor!F(adr!F(obtain-8bit-addra¨rray"T"P"P"P"P"P!F(upreference-file-buffer!Fbuf)))"T"P!F!F(l¨et*!F((part!F(fd-partition-desc!Ffd))"T"P"P!F(block-size-wor¨ds!F(partt-block-size-words!Fpart))"T"P"P!F(record-size-bloc¨%%-776095568¨ks!F(partt-record-size-blocks!Fpart))"T"P"P!F(dataw-per-bloc¨k!F(partt-dataw-per-block!Fpart))"T"P"P!F(uid!F(fd-uid!Ffd))¨"T"P"P!F(array!F(fb-array!Fbuf))"T"P"P!F(result!Fnil))"T"P!F¨!F!F!F(loop!Frepeat!Frecord-size-blocks"T"P"P!F!Ffor!Fbuf-of¨fset!Ffrom!F0!Fby!Fblock-size-words"T"P"P!F!Fand!Fdata-addr!¨Ffrom!F(if!F(>!F(fb-highest-data-addr+1!Fbuf)!F(fb-lowest-da¨ta-addr!Fbuf))"T"P"P"P"P"P!F(fb-lowest-data-addr!Fbuf)"T"P"P¨"P"P"P!F-9999999.)!Fby!Fdataw-per-block"T"P"P!F!Fand!Fhdr-ad¨dr!Ffrom!F(if!F(>!F(fb-highest-header-addr+1!Fbuf)!F(fb-lowe¨st-header-addr!Fbuf))"T"P"P"P"P"P(fb-lowest-header-addr!Fbuf¨%%-1372504870¨)"T"P"P"P"P"P-9999999.)!Fby!Fdataw-per-block"T"P"P!F!Ffinall¨y!F(return!F(or!Fresult!Ft))"T"P"P!F!Fdo"T"P"P!F!F(let*!F((h¨eaderp!F(minusp!Fdata-addr))"T"P"P"P!F(rel!F(if!Fheaderp!Fhd¨r-addr!Fdata-addr)))"T"P"P!F!F!F!F(set-word-address-in-addre¨ssor!Fadr!Farray!Fbuf-offset)"T"P"P!F!F!F!F(cond!F((eq!Fchec¨k!F'collect)"T"P"P"P!F!F!F(setq!Fresult!F(nconc!Fresult"T"P"¨P"P"P"P!F!F!F!F!F!F!F(list*!Fuid"T"P"P"P"P"P"P!F!F!F!F!F!F(b¨lock-check-words-file-id!Fadr)"T"P"P"P"P"P"P!F!F!F!F!F!F(+!F¨(if!Fheaderp!F1"&31.!F0)!Frel)"T"P"P"P"P"P"P!F!F!F!F!F!F(+!F¨(if!F(block-check-words-headerp!Fadr)"T"P"P"P"P"P"P"P!F!F!F!¨%%-1585802269¨F!F1"&31.!F0)"T"P"P"P"P"P"P"P!F(block-check-words-word-0s-re¨l-addr"T"P"P"P"P"P"P"P!F!F!Fadr))"T"P"P"P"P"P"P!F!F!F!F!F!Fn¨il))))"T"P"P"P!F!F(check"T"P"P"P!F!F!F(if!F(and!F*checking-c¨heck-words*"T"P"P"P"P!F!F!F!F(check-the-actual-words!Fadr!Fu¨id!Fheaderp!Frel!Fr0p))"T"P"P"P!F!F!F!F!F!F!F(return!Fnil)))¨"T"P"P"P!F!F(t"T"P"P"P!F!F!F(setf!F(block-check-words-header¨p!Fadr)!Fheaderp)"T"P"P"P!F!F!F(setf!F(block-check-words-wor¨d-0s-rel-addr!Fadr)!Frel)"T"P"P"P!F!F!F(setf!F(block-check-w¨ords-file-id!Fadr)!Fuid)))"T"T"P"P!F!F!F!F(set-word-address-¨in-addressor!Fadr!Farray"T"P"P"P"P"P"P!F!F!F(-!F(+!Fblock-si¨%%645049146¨ze-words!Fbuf-offset)"T"P"P"P"P"P"P!F!F!F!F!F!F(block-check-¨words-size-in-words)))"T"P"P!F!F!F!F(cond!F((eq!Fcheck!F'col¨lect)"T"P"P"P!F!F!F(setq!Fresult!F(nconc!Fresult"T"P"P"P"P"P¨!F!F!F!F!F!F!F(list*!Fuid"T"P"P"P"P"P"P!F!F!F!F!F!F(block-ch¨eck-words-file-id!Fadr)"T"P"P"P"P"P"P!F!F!F!F!F!F(+!F(if!Fhe¨aderp!F1"&31.!F0)!Frel)"T"P"P"P"P"P"P!F!F!F!F!F!F(+!F(if!F(b¨lock-check-words-headerp!Fadr)"T"P"P"P"P"P"P"P!F!F!F!F!F1"&3¨1.!F0)"T"P"P"P"P"P"P"P!F(block-check-words-word-0s-rel-addr"¨T"P"P"P"P"P"P"P!F!F!Fadr))"T"P"P"P"P"P"P!F!F!F!F!F!Fnil))))"¨T"P"P"P!F!F(check"T"P"P"P!F!F!F(if!F(and!F*checking-check-wo¨%%-1504024886¨rds*"T"P"P"P"P!F!F!F!F(check-the-actual-words!Fadr!Fuid!Fhea¨derp!Frel!Fr0p))"T"P"P"P!F!F!F!F!F!F!F(return!Fnil)))"T"P"P"¨P!F!F(t"T"P"P"P!F!F!F(setf!F(block-check-words-headerp!Fadr)¨!Fheaderp)"T"P"P"P!F!F!F(setf!F(block-check-words-word-0s-re¨l-addr!Fadr)!Frel)"T"P"P"P!F!F!F(setf!F(block-check-words-fi¨le-id!Fadr)!Fuid))))))))))"T"T;;;Check!Factual!Fcheck!Fwords¨.!F!FReturn!FValue!Fof!FT!Fmeans!Fno-good,!Fthey!Flose.!FNIL¨!Fmeans!FO.K."T(defun!Fcheck-the-actual-words!F(adr!Fuid!Fhe¨aderp!Frel!Fr0p)"P;val!Fof!Ft!Fmeans!Flose"T!F!F(if!F(null!F¨uid)"P"P"P"P;root!Factivate"T!F!F!F!F!F!Fnil"P"P"P"P"P;it's!¨%%-917677572¨Fok"T!F!F!F!F!F!F(not!F(and!F;;!FThis!Fmagic!Fmacro!Favoids!¨Fbignum!Fconsing."T"P"P(block-check-words-compare-file-id!Fa¨dr!Fuid)"T"P"P(or!Fr0p"T"P"P!F!F!F!F(and!F(eq!F(block-check-¨words-headerp!Fadr)!Fheaderp)"T"P"P"P!F(=!F(block-check-word¨s-word-0s-rel-addr!Fadr)!Frel)))))))"T"T"T!I"C"T"T(defun!Fwr¨ite-file-to-bytes!F(&optional!F(name!F!Hlocal:>foo.bar!H)!F(¨bytes!F100000000))"T!F!F(with-open-file!F(o!Fname!F:directio¨n!F:out!F:element-type'(unsigned-byte!F8)"T"P"P!F!F!F!F!F:es¨timated-length!Fbytes)"T!F!F!F!F(loop!Fwith!Ftodo!F=!Fbytes"¨T"P!F!Fwith!Fbuf!Fand!Fstart!Fand!Flimit"T"P!F!Fdo!F(multipl¨%%422366898¨e-value-setq!F(buf!Fstart!Flimit)"T"P"P"P"P!F!F(send!Fo!F:ge¨t-output-buffer))"T"P!F!Fwhile!Fbuf"T"P!F!Fdo!F(let!F((this!¨F(min!Ftodo!F(-!Flimit!Fstart))))"T"P!F!F!F!F!F!F!F(send!Fo!¨F:advance-output-buffer!F(+!Fstart!Fthis))"T"P!F!F!F!F!F!F!F¨(decf!Ftodo!Fthis))"T"P!F!Funtil!F(zerop!Ftodo))))"T"T"T"C!I¨¨%%-1270787322¨%$-1917500341¨