On Tue, 20 Dec 2005, Erik Kangas wrote:
I
would consider building a manual defragmentation tool which would be
as close to safe with c-client programs (imapd, ipop3d, Pine, etc.) as
possible if the community considers it to be worthwhile.
I would vote for this and I would use this.

I have built a single file defragmentation tool on:
        ftp://ftp.cac.washington.edu/mail/powertools/defrag.c

This program was written for Linux, and may need modification on other operating systems. It takes a single argument, the file name of a file to defragment, and will defragment it as best as the filesystem will allow. It will decline to act on any file that is currently open and locked.

It does this by opening, exclusive-locking, copying the file to a temp file, truncating the file to zero bytes, then copying it back. This has the benefit of preserving the inode number in case anything cares.

There is a known failure case which will cause problems for the user and require manual remedy. If, after starting the copy-back, an I/O error occurs, the program will stop and report an error. However, it will not delete the temp file in this case.

There are other failure cases which will also stop and report an error, but no change was made to the original file

Note that although the atime and mtime are preserved, it is not possible to prevent the ctime from being changed. This will cause the file to be flagged as \Marked in IMAP lists. I can't do anything about this, sorry.

As for the more ambitious program that you outlined, that's dependent upon the underlying filesystem and is more research than I care to undertake. All I tried to do is to build a program that will safely (or rather, as safely as possible) defragment a file on a live system without risking possible loss of mail.

-- Mark --

http://staff.washington.edu/mrc
Science does not emerge from voting, party politics, or public debate.
Si vis pacem, para bellum.
_______________________________________________
Imap-uw mailing list
[email protected]
https://mailman1.u.washington.edu/mailman/listinfo/imap-uw

Reply via email to