Subject: bug#37884: 27.0.50; Cannot write to a file in VirtualBox shared directory

From: Bernardo <[email-masked]>
Date: Wed, 30 Oct 2019 19:44:35 +1100

Robert Pluim <[email-masked]> writes:

>>>>>> On Tue, 29 Oct 2019 10:04:01 +0100, Andreas Schwab <[email-masked]> said:
>     Andreas> You need to move this check under the condition above, otherwise you may
>     Andreas> get a false positive if unlink didn't fail or wasn't called at all.
>
>     >> +    {
>     >> +      chmod (lfname, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
>     >> +      err = 0;
>     >> +      errno = 0;
>
> Indeed. Next time maybe Iʼll try actually compiling my patches before
> I send them. Take 3
>
> diff --git a/src/filelock.c b/src/filelock.c
> index ff25d6475d..bd1e8d9b2d 100644
> --- a/src/filelock.c
> +++ b/src/filelock.c
> @@ -731,9 +731,20 @@ unlock_file (Lisp_Object fn)
>  
>    int err = current_lock_owner (0, lfname);
>    if (err == -2 && unlink (lfname) != 0 && errno != ENOENT)
> +    {
>      err = errno;
> -  if (0 < err)
> -    report_file_errno ("Unlocking file", filename, err);
> +  /* On certain filesystems the file must be writable for unlink to
> +     succeed, so make it writable and retry (Bug#37784).  */
> +    if (errno == EPERM)
> +      {
> +        chmod (lfname, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
> +        err = 0;
> +        if (unlink (lfname) != 0 && errno != ENOENT)
> +          err = errno;
> +      }
> +    }
> +    if (0 < err)
> +      report_file_errno ("Unlocking file", filename, err);
>  
>    SAFE_FREE ();
>  }

confirmed this patch works fine;
thanks for the effort (and persistence)

-- 
Rgds, Bernardo