This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about fcntl64




On 2018年09月13日 01:32, Florian Weimer wrote:
On 09/12/2018 04:23 PM, Hongzhi, Song wrote:
Testcase source code: ltp/testcases/kernel/syscalls/fcntl/fcntl34.c


In function 'thread_fn_01', struct flock64 lck.l_len is set '1'.

thread_fn_01 ---> SAFE_FCNTL(fd, F_OFD_SETLKW, &lck) ---> fcntl64

Please quote the relevant parts of the source code.  What is SAFE_FNCTL?


OK,

1.part of source code: ltp/testcases/kernel/syscalls/fcntl/fcntl34.c
---
struct flock64 lck = {
          .l_whence = SEEK_SET,
          .l_start  = 0,
--->    .l_len    = 1, <---
};
lck.l_type = F_WRLCK
SAFE_FCNTL(fd, F_OFD_SETLKW, &lck);
---

2.SAFE_FCNTL is defined as a macro:
---
#define SAFE_FCNTL(fd, cmd, ...)                            \
   ---> ({int tst_ret_ = fcntl(fd, cmd, ##__VA_ARGS__);     \ <---
      tst_ret_ == -1 ?                                  \
       tst_brk(TBROK | TERRNO,                          \
                "fcntl(%i,%s,...) failed", fd, #cmd), 0 \
     : tst_ret_;})
---

3. I used "strace -f ./fcntl34" found that: l_len was changed to '0'.

fcntl64(6, F_OFD_SETLKW, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, ---> l_len=0 <---}

4. The question is that l_len was set '1', but why it is changed to '0' when it is passed to fcntl64.

Thanks,
--Hongzhi

Thanks,
Florian



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]