~sircmpwn/hare#715: 
F_SETLKW fcntl fails with EINVAL

The definition of F_SETLKW seems to not work with fcntl. I believe this is due to the hare definition actually referring to F_SETLKW64.

use rt;
use os;
use fs;

export fn main() void = {
	let f = os::create("test.lock", 0o644, fs::flags::RDWR)!;
	let F_WRLCK: i16 = 2; // Missing from rt currently.

	let lock_arg = rt::st_flock{ l_type = F_WRLCK,  ... };
	let fcntl_arg: rt::fcntl_arg = &lock_arg;
	
	// Works
	rt::fcntl(f: int, 7: int, fcntl_arg)!;

	// Fails
	rt::fcntl(f: int, rt::F_SETLKW: int, fcntl_arg)!;
};

strace:

execve("./bug", ["./bug"], 0x7fffe213a930 /* 61 vars */) = 0
openat(AT_FDCWD, "test.lock", O_RDWR|O_CREAT|O_NOCTTY|O_CLOEXEC, 0644) = 3
fcntl(3, F_SETLKW, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fcntl(3, F_SETLKW64, 0x7ffcb9c983d0)    = -1 EINVAL (Invalid argument)
Status
REPORTED
Submitter
~ach
Assigned to
No-one
Submitted
2 years ago
Updated
2 years ago
Labels
bug

~ach 2 years ago

Minor correction, the type '2' is F_UNLCK as seen in the strace, the issue is the same.

~sircmpwn 2 years ago

Send a patch?

~ach 2 years ago

I don't yet fully understand why what is there currently doesn't work. Need to do a bit more research.

Register here or Log in to comment, or comment via email.