IOError on file close

Michael S. Fischer michael+usenet at dynamine.net
Fri Mar 29 17:59:56 EST 2002


On 29 Mar 2002 23:27:43 +0100, Martin v. Loewis <martin at v.loewis.de> wrote:

> No, but I can tell you how to find out. Write these commands into a
> script, then run the script under strace(1). Find the system call that
> returns error 38 (ENOSYS). Once you found it, you will know what
> system call is not supported by that part of the proc file system.

It appears that the write() call is the one that's failing, not the
close() call.  Python is throwing the exception at the wrong time. 
Should I report this as a Python bug?

open("/proc/scsi/scsi", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x40016000
write(3, "scsi add-single-device 0 0 1 0\n", 31) = -1 ENOSYS (Function not 
implemented)
close(3)                                = 0
munmap(0x40016000, 4096)                = 0
write(2, "Traceback (most recent call last"..., 35Traceback (most recent call 
last):

Also strange is the fact that a shell script has nearly the same syscall
trace results but doesn't return an error to me:

#!/bin/sh
echo "scsi add-single-device 0 0 1 0" > /proc/scsi/scsi

open("/proc/scsi/scsi", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = 3
fcntl64(1, F_GETFD)                     = 0
fcntl64(1, F_DUPFD, 10)                 = 10
fcntl64(1, F_GETFD)                     = 0
fcntl64(10, F_SETFD, FD_CLOEXEC)        = 0
dup2(3, 1)                              = 1
close(3)                                = 0
write(1, "scsi add-single-device 0 0 1 0\n", 31) = -1 ENOSYS (Function not 
implemented)

> If you then want to understand it even deeper, you must locate the
> relevant part of the Linux source code, and check why it returns
> -ENOSYS. Most likely, it has a NULL function pointer in it somewhere,
> and the syscall layer return ENOSYS.

That indeed appears to be the case, but it looks like a bug in the 
kernel to me.

-- 
Michael S. Fischer / michael at dynamine.net / +1 650-533-4684
Lead Hacketeer, Dynamine Consulting, Silicon Valley, CA



More information about the Python-list mailing list