Commit 274bd021 authored by Thomas Roessler's avatar Thomas Roessler

Remove a couple of NFS-related hacks which seem to be unnecessary.

parent 3f5d8003
......@@ -709,37 +709,15 @@ dotlock_unlock (const char *realpath)
static int
dotlock_unlink (const char *realpath)
{
struct stat fsb, lsb;
int fd = -1;
struct stat lsb;
int i = -1;
char dummy;
if (dotlock_lock (realpath) != DL_EX_OK)
return DL_EX_ERROR;
if ((fd = open (realpath, O_RDONLY)) == -1)
goto bail;
if ((i = fstat (fd, &fsb)) == -1)
goto bail;
if ((i = lstat (realpath, &lsb)) == -1)
goto bail;
if ((i = dotlock_check_stats (&fsb, &lsb)) == -1)
goto bail;
/*
* don't _really_ trust stat here, but actually try to read one
* character from the supposedly empty file.
*/
if ((fsb.st_size == 0) && (read (fd, &dummy, 1) != 1))
if ((i = lstat (realpath, &lsb)) == 0 && lsb.st_size == 0)
unlink (realpath);
bail:
if (fd != -1) close (fd);
dotlock_unlock (realpath);
return (i == 0) ? DL_EX_OK : DL_EX_ERROR;
......
......@@ -295,12 +295,12 @@ void mx_unlink_empty (const char *path)
{
int fd;
#ifndef USE_DOTLOCK
char b;
struct stat sb;
#endif
if ((fd = open (path, O_RDWR)) == -1)
return;
if (mx_lock_file (path, fd, 1, 0, 1) == -1)
{
close (fd);
......@@ -310,11 +310,12 @@ void mx_unlink_empty (const char *path)
#ifdef USE_DOTLOCK
invoke_dotlock (path, DL_FL_UNLINK, 1);
#else
if (read (fd, &b, 1) != 1)
if (fstat (fd, &sb) == 0 && sb.st_size == 0)
unlink (path);
#endif
mx_unlock_file (path, fd, 0);
close (fd);
}
/* try to figure out what type of mailbox ``path'' is
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment