LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-06-2009, 12:41 PM   #1
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 403

Rep: Reputation: 51
How to release /dev entry of unplugged storage device while a program has a file open


I plug a USB device, it gets a /dev entry, e.g. sdf, i mount its filesystem, then some program opens a file on this filesystem. I unplug this device, its /dev entry disappears, but if i replug this device again, it gets another name - sdg.
How can i force the program to close the file so the filesystem is ready to be unmounted without using "lazy unmount" to release the device name, BUT so that the program doesn't crash after trying to make I/O to this file, and, of course, without having to kill the program?
 
Old 11-08-2009, 02:46 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
Quote:
Originally Posted by 10110111 View Post
How can i force the program to close the file so the filesystem is ready to be unmounted without using "lazy unmount" to release the device name, BUT so that the program doesn't crash after trying to make I/O to this file, and, of course, without having to kill the program?
If the filesystem a file resides on is no longer available then it would be not be a design flaw or application error but rather a human misunderstanding of concepts to assert it is still valid to write to it.
 
Old 11-09-2009, 11:32 AM   #3
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Ubuntu, SliTaz
Posts: 403

Original Poster
Rep: Reputation: 51
Quote:
design flaw or application error
I didn't mean any of this. There exist some programs which is wouldn't like to stop running, but i need them to release any file pointers which make OS give newly inserted devices not next unused name, but some greater one (e.g. sdg instead of sdf), leaving sdf inexistant in /dev at all. So, the question is how to do this.
 
Old 11-09-2009, 01:44 PM   #4
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Testing"
Posts: 6,119

Rep: Reputation: 416Reputation: 416Reputation: 416Reputation: 416Reputation: 416
To make USB devices appear in the same place always you need to use udev

Please read this introduction / tutorial / examples.

Then come back here with your results (success or fail).
 
Old 11-09-2009, 02:21 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594Reputation: 3594
Quote:
Originally Posted by 10110111 View Post
There exist some programs which is wouldn't like to stop running, but i need them to release any file pointers
As far as I know there are only two possibilities: a) kill the application or b) do not unplug and change the device. As far as releasing file pointers there is no middle way I know of.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error.../Desktop/Floppy Device is of type FSDevice but has no Dev=...entry suejohn Linux - Newbie 1 04-30-2009 06:01 AM
Cannot open master raw device '/dev/rawctl' (No such file or directory) ayyappa1 Linux - Hardware 1 03-27-2009 08:19 AM
creation of dynamic device node entry in /dev balalin Linux - Kernel 0 04-10-2007 04:29 AM
Assign one USB-storage device to one device file Misel Linux - Hardware 1 08-28-2004 03:52 AM
how can usb-storage device attach to specific /dev/sd* xxie Linux - Hardware 0 05-25-2004 10:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration