qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] virtiofsd: fix compile error if 'F_OFD_GETLK' n


From: piaojun
Subject: Re: [Qemu-devel] [PATCH] virtiofsd: fix compile error if 'F_OFD_GETLK' not defined
Date: Tue, 30 Jul 2019 21:08:54 +0800
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

Hi Liam,

On 2019/7/30 20:22, Liam Merwick wrote:
> On 30/07/2019 01:27, piaojun wrote:
>> Use F_GETLK for fcntl when F_OFD_GETLK not defined.
> 
> 
> Use F_GETLK/F_SETLK for fcntl when F_OFD_GETLK/F_OFD_SETLK not defined.
> 
>>
>> Signed-off-by: Jun Piao <address@hidden>
>> ---
>>   contrib/virtiofsd/passthrough_ll.c | 9 +++++++++
>>   1 file changed, 9 insertions(+)
>>
>> diff --git a/contrib/virtiofsd/passthrough_ll.c 
>> b/contrib/virtiofsd/passthrough_ll.c
>> index 9ae1381..757785b 100644
>> --- a/contrib/virtiofsd/passthrough_ll.c
>> +++ b/contrib/virtiofsd/passthrough_ll.c
>> @@ -1619,7 +1619,11 @@ static void lo_getlk(fuse_req_t req, fuse_ino_t ino,
>>           return;
>>       }
>>
>> +#ifdef F_OFD_GETLK
>>       ret = fcntl(plock->fd, F_OFD_GETLK, lock);
>> +#else
>> +    ret = fcntl(plock->fd, F_GETLK, lock);
>> +#endif
>>       if (ret == -1)
>>           saverr = errno;
>>       pthread_mutex_unlock(&inode->plock_mutex);
>> @@ -1668,7 +1672,12 @@ static void lo_setlk(fuse_req_t req, fuse_ino_t ino,
>>
>>       /* TODO: Is it alright to modify flock? */
>>       lock->l_pid = 0;
>> +
>> +#ifdef F_OFD_GETLK
> 
> 
> This checks for F_OFD_GETLK but uses F_OFD_SETLK (albeit unlikely one being 
> defined without the other)

Right, F_OFD_SETLK looks better.

> 
> 
>>       ret = fcntl(plock->fd, F_OFD_SETLK, lock);
>> +#else
>> +    ret = fcntl(plock->fd, F_SETLK, lock);
>> +#endif
>>       if (ret == -1) {
>>           saverr = errno;
>>       }
>>
> Might qemu_lock_fd()/qemu_unlock_fd() in util/osdep.c be useful to hide this 
> instead?

Yes, I'm trying re-write do_getlk/setlk with qemu_lock_fd, and thanks for
your suggestion.

Thanks,
Jun

> 
> Regards,
> Liam
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]