lseek() on entries in /proc/device-tree returns EINVAL

Joakim Tjernlund Joakim.Tjernlund at transmode.se
Thu Apr 17 07:09:27 EST 2008


> -----Original Message-----
> From: linuxppc-dev-bounces+joakim.tjernlund=transmode.se at ozlabs.org [mailto:linuxppc-dev-
> bounces+joakim.tjernlund=transmode.se at ozlabs.org] On Behalf Of Timur Tabi
> Sent: den 16 april 2008 22:58
> To: linuxppc-dev at ozlabs.org
> Subject: lseek() on entries in /proc/device-tree returns EINVAL
> 
> I'm writing a utility that parses the device tree in /proc/device-tree, and in
> order to read a property into memory, I have to first find out how large it is.
>  So I have the following code:
> 
> 	off_t off;
> 	int f;
> 
> 	f = open(filename, O_RDONLY);
> 	if (f == -1) {
> 		perror(__func__);
> 		return NULL;
> 	}
> 
> 	off = lseek(f, 0, SEEK_END);
> 	if (off == -1) {
> 		perror(__func__);
> 		goto fail;
> 	}
> 
> The lseek() call returns -1, and errno is set to EINVAL.  According to the man
> page, this means:
> 
>        EINVAL The  whence  argument  is  not a proper value, or the resulting
>               file offset would be negative for a regular file, block special
>               file, or directory.
> 
> Is there a limitation for the implementation of /proc/device-tree that prevents
> lseek() from working?  If so, how do I determine the size of a property?

Yeah, just reported a similar problem at LKML. busybox start-stop-daemon broke
between 2.6.23 and current tree. The change was intentional but the borkage
was not. Al Viro has been informed, lets see what comes of it.

 Jocke





More information about the Linuxppc-dev mailing list