On 22 Jan 2004 at 17h01, Michael Schmitz wrote: Hi,
> Sure, that's understood. You have to be careful to not let it go to sleep > (hacking an -EBUSY return code in the sleep ioctl code for your kernel, > for instance). Well I tried that (works correctly: nothing happens on `snooze -f` except a "Devices rejected sleep" log from the kernel). > With CAN_SLEEP added, does pmud start OK now?? (you could still use it for > pwrctl-based power management, and just shut down on battery low). Nope, still the same error. Strace relevant bit: fcntl64(5, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(5, F_SETFL, O_RDONLY|O_NONBLOCK|O_EXCL|O_SYNC|O_ASYNC|O_DIRECT|O_LARGEFILE|O_DIRECTORY|O_NOFOLLOW|0x7ffc002c) = -1 EINVAL (Invalid argument) Which made me read the code and fcntl's manpage, in which I found your calls were looking strange... (It says, amongst other things: int fcntl(int fd, int cmd); int fcntl(int fd, int cmd, long arg); F_GETFL Read the file descriptor's flags. F_SETFL Set the file status flags part of the descriptor's flags to the value specified by arg. RETURN VALUE F_GETFL Value of flags. The attached patch makes pmud function again for me (tested with -d and with Batmon). Could this be due to some changes in fcntl's lib (glibc i guess) ? -- Colin
--- pmud.orig 2004-01-22 21:49:48.351629584 +0100 +++ pmud.c 2004-01-22 21:53:45.464582936 +0100 @@ -360,10 +360,10 @@ chk(pmu_fd < 0, "Couldn't open " PMU_FILE " or " PMU_DEVFS_FILE); - chk(fcntl(pmu_fd, F_GETFL, &fl) < 0, "fcntl(F_GETFL)"); + chk( (fl = fcntl(pmu_fd, F_GETFL)) < 0, "fcntl(F_GETFL)"); fl |= O_NONBLOCK; - chk(fcntl(pmu_fd, F_SETFL, &fl) < 0, "fcntl(F_SETFL)"); + chk(fcntl(pmu_fd, F_SETFL, fl) < 0, "fcntl(F_SETFL)"); add_fd(pmu_fd, POLLIN, pmu_intr, NULL); @@ -1194,10 +1194,10 @@ struct sockstate *ss; fe = accept(fd, NULL, 0); - chk(fcntl(fe, F_GETFL, &fl) < 0, "fcntl(F_GETFL)"); + chk((fl =fcntl(fe, F_GETFL)) < 0, "fcntl(F_GETFL)"); fl |= O_NONBLOCK; - chk(fcntl(fe, F_SETFL, &fl) < 0, "fcntl(F_SETFL)"); + chk(fcntl(fe, F_SETFL, fl) < 0, "fcntl(F_SETFL)"); ss = malloc(sizeof(*ss)); if (ss == 0)