[PATCH] BUG 9965: Set lease only on regular files.
Jeff Layton
jlayton at samba.org
Sat Jun 22 09:41:28 MDT 2013
On Sat, 22 Jun 2013 10:48:57 +0200
Andreas Schneider <asn at samba.org> wrote:
>
> Signed-off-by: Andreas Schneider <asn at samba.org>
> ---
> source3/smbd/oplock_linux.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/source3/smbd/oplock_linux.c b/source3/smbd/oplock_linux.c
> index 7fa9b7c..9464d7a 100644
> --- a/source3/smbd/oplock_linux.c
> +++ b/source3/smbd/oplock_linux.c
> @@ -74,8 +74,20 @@ int linux_set_lease_sighandler(int fd)
>
> int linux_setlease(int fd, int leasetype)
> {
> + struct stat sb;
> int ret;
>
> + ret = fstat(fd, &sb);
> + if (ret == -1) {
> + return -1;
> + }
> +
> + /* We can't set a lease on special files like pipes */
> + if (!S_ISREG(sb.st_mode)) {
> + errno = EINVAL;
> + return -1;
> + }
> +
> /* First set the signal handler. */
> if (linux_set_lease_sighandler(fd) == -1) {
> return -1;
(apologies for the resend -- the original mail had a screwed up cc list...)
Attempting to set a lease isn't be harmful, and it seems like adding an
extra fstat() call here to handle the case where it's not a normal file
is less than ideal.
Might it be better instead to go ahead and just try to set a lease and
only do the fstat() if you get an EINVAL back? If it turns out not to
be a regular file then you can just not bother to log the error...
--
Jeff Layton <jlayton at samba.org>
More information about the samba-technical
mailing list