The reason that you might still want to use mkdir, where this whole
thread originally started, is that from a Bourne shell script, there is
no safe way to write to a file in a world-writable directory. Even if
you create the lock file with ln, you will have to create the temporary
lock file which you link and if your shell does not have some strong
random number generator, it is easy for an attacker to guess the
temporary lock name.
Therefore, the safest way to create a lock from a shell is to create a
directory (not forgetting umask 077 before that), create the temporary
lock file in the new directory, link that temporary lock to the real lock
and remove the temporary file and directory. That way you get all the
benifits ln and your shell script will be safe.
Zoltan