Two routines have been built for purging buffers.
FLUSH-BUFFER(ENT) writes out ENT if it is dirty and unlocked. It returns TERMINATED if ENT is locked, RETRYERR if the write is attempted and fails, and SUCCESS otherwise.
PURGE-BUFFER(ENT) writes out ENT if it is dirty and then frees up the buffer. This IGNORES the access status of the buffer, so it should not be called by users; it always returns SUCCESS.
Use (DO-SEG-BUFFERS SEG FUNC) to apply a function to all the buffers of a given segment; for example, (DO-SEG-BUFFERS SEG FLUSH-BUFFER) can be used to guarantee that segment SEG's disk file is up to date. DO-SEG-BUFFERS halts if FUNC returns other than SUCCESS; the result of FUNC is returned. SUCCESS is returned if all buffers have been successfully processed. To process all segments, use SEG = #f.
(CHECK-BUFFER ENT) checks that the buffer is written and unlocked, and repairs those that are not.