Re: Programmatically detect removed usb stick?

2011-07-10 Thread T
On Sat, Jun 11, 2011 at 3:47 PM, Benny Lofgren wrote: > On 2011-06-11 10.08, T wrote: >> I'm writing a small program which changes working dir to a >> specific directory (using chdir()), and then opens, reads, and >> closes files in that directory, depending on user actions. >> Sometimes this dire

Re: Programmatically detect removed usb stick?

2011-06-11 Thread Ted Unangst
On Sat, Jun 11, 2011 at 4:08 AM, T wrote: > So is there some reliable way of detecting whether the underlying > storage device has gone away when a library/system call fails, > even if the OS still regards the filesystem as being mounted? Can > I, upon detecting errno==ENOENT after fopen(), use so

Re: Programmatically detect removed usb stick?

2011-06-11 Thread Martin Schröder
2011/6/11 Benny Lofgren : > If you get -1 and ENOENT then the file system where you've parked > your cwd is no longer mounted (statfs() should also work equally What if the cwd has been removed by another process instead? Best Martin

Re: Programmatically detect removed usb stick?

2011-06-11 Thread Benny Lofgren
On 2011-06-11 10.08, T wrote: > I'm writing a small program which changes working dir to a > specific directory (using chdir()), and then opens, reads, and > closes files in that directory, depending on user actions. > Sometimes this directory is located on a mounted USB stick. > > I'm looking for

Programmatically detect removed usb stick?

2011-06-11 Thread T
Hello, I'm writing a small program which changes working dir to a specific directory (using chdir()), and then opens, reads, and closes files in that directory, depending on user actions. Sometimes this directory is located on a mounted USB stick. I'm looking for a simple way to detect, from with