ProFTPD module mod_counter

The mod_counter module is designed to allow a sort of
"locking" to be enforced when the same file is being uploaded
or downloaded by multiple clients at the same time.

The mod_counter works by creating a SysV semaphore for a file
being read/written, and placing a number of reader or writer "counters" in that
semaphore. When the configured maximum number of counters is reached, the
FTP command which seeks to add another reader/writer counter will be denied.
This allows site to configure the maximum number of clients which can be
reading/writing any file at one time.

This module is contained in the mod_counter.c file for
ProFTPD 1.2.x/1.3.x, and is not compiled by default.
Installation instructions are discussed here.
Example configurations and further details are discussed in the
usage section.

The CounterEngine directive enables or disables the module's
runtime counter engine. If it is set to off this module does no
"locking". Use this directive to disable the module instead of
commenting out all mod_counter directives.

The CounterLog directive is used to a specify a log file for
mod_counter reporting and debugging, and can be done a per-server
basis. The path parameter must be the full path to the file to use for
logging. Note that this path must not be to a world-writeable
directory and, unless AllowLogSymlinks is explicitly set to
on (generally a bad idea), the path must not be a symbolic
link.

If path is "none", no logging will be done at all; this
setting can be used to override a CounterLog setting inherited from
a <Global> context.

The CounterMaxReaders directive specifies the maximum number
of clients allowed to be reading to the same file at the same time. By
default, all clients are allowed to read the same file at one time
by mod_counter.

The CounterMaxWriters directive specifies the maximum number
of clients allowed to be writing to the same file at the same time. By
default, only one client is allowed to write to the same file at one time
by mod_counter.

This means, for example, that you can use mod_counter to prevent
an uploaded file from being deleted or renamed before the uploading client
has finished the upload by using:

<IfModule mod_counter.c>
CounterEngine on
CounterFile /var/proftpd/counter.txt
# Allow only one client at a time to be writing (including deletes and renames) to a given file.
CounterMaxWriters 1
</IfModule>

Likewise, if for some reason you need to limit the number of clients which
can be downloading a given file at the same time, you would use the
CounterMaxReaders directive:

<IfModule mod_counter.c>
CounterEngine on
CounterFile /var/proftpd/counter.txt
# Allow only three clients at a time to be reading the same file
CounterMaxReaders 3
</IfModule>