In article <50bf9366-46e0-4a7f-865b-3f7c7b0f6...@googlegroups.com>,
 krishna2pra...@gmail.com wrote:

> I am trying to use os.open() and os.lseek() methods to operate on a device 
> file in Linux. My code goes something like this -
> 
>  # first, open the file as a plain binary
>  try:
>      self.file = open(/dev/relpcfpga, "r+b", buffering=0)
>  
>  except IOError:
>      raise IOError ('Failed to open.')
> 
>  # Figure out file size
>   self.file.seek(0, 2)
>   self.file_size = self.file.tell()
>  
> 
> The method seek() complains "OSError: [Errno 29] Illegal seek"
> The device relpcfpga is a char device.
> 
> The same code works with a normal text file.
> I have tried to use os.open() and os.lseek() methods, but see the same error.
> Is there a different method to operate on device files?

In general, seek() works on special files, when it makes sense.  But, 
the "in general" part is critical.  Not all devices support the seek 
operation.  I have no idea what /dev/relpcfpga is (a google search for 
relpcfpga came up with exactly one hit -- your post!) so I can't tell 
you if it supports seek() or not.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to