Re: [Regression] Editting stale symlink removes symlink and creates file symlink points to

Pavel Roskin wrote:

Max Derzhak <max /at/> reported new regression in mcedit. If you type F4 on stale symlink and press Esc-Esc or F10 after it (no editting at all) mcedit creates empty file symlink points to and removes original symlink.

The problem is not related to VFS, so I'll talk in terms on libc

stat() fails, the file is opened with O_CREAT, creating the link target. If the file has not been modified, it's removed. open() resolves
symlinks, unlink() doesn't, hence the result.

I think that editing stale symlinks is insane.  If stat() fails, then we
expect to create a new file.  That's what O_EXCL is for.  I'm applying a
patch that uses O_EXCL whenever stat() fails.  Editing stale symlinks is
now impossible.  I think it's reasonable.

I realize that O_EXCL may not be implemented in every VFS, but it's a
separate problem.  Actually, direntry.c knows this flag, so only
filesystems with its own open() need to be changed.

Fine and elegant solution!

Thanks a lot!

Andrew V. Samoilov

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]