LinuxQuestions.org
Have you listened to LQ Radio?
Go Back   LinuxQuestions.org > Forums > Linux > 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
 
Thread Tools
Old 11-06-2009, 01:41 PM   #1
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Easy Peasy, Ubuntu, AntiX
Posts: 124
Thanked: 1
How to release /dev entry of unplugged storage device while a program has a file open


[Log in to get rid of this advertisement]
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?
linux 10110111 is offline     Reply With Quote
Old 11-08-2009, 03:46 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 16,722
Blog Entries: 30
Thanked: 285
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.
linux unSpawn is offline     Reply With Quote
Old 11-09-2009, 12:32 PM   #3
10110111
Member
 
Registered: Jun 2008
Location: St.-Petersburg, Russia
Distribution: (B)LFS, Easy Peasy, Ubuntu, AntiX
Posts: 124
Thanked: 1

Original Poster
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.
linux 10110111 is offline     Reply With Quote
Old 11-09-2009, 02:44 PM   #4
tredegar
Senior Member
 
Registered: May 2003
Location: London, UK
Distribution: Kubuntu6.06.1LTS (still excellent!). Kubuntu 8.04.1
Posts: 4,384
Thanked: 144
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).
linuxubuntu tredegar is offline     Reply With Quote
Old 11-09-2009, 03:21 PM   #5
unSpawn
Moderator
 
Registered: May 2001
Posts: 16,722
Blog Entries: 30
Thanked: 285
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.
linux unSpawn is offline     Reply With Quote

Reply

Bookmarks


Thread Tools

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 07:01 AM
Cannot open master raw device '/dev/rawctl' (No such file or directory) ayyappa1 Linux - Hardware 1 03-27-2009 09:19 AM
creation of dynamic device node entry in /dev balalin Linux - Kernel 0 04-10-2007 05:29 AM
Assign one USB-storage device to one device file Misel Linux - Hardware 1 08-28-2004 04:52 AM
how can usb-storage device attach to specific /dev/sd* xxie Linux - Hardware 0 05-25-2004 11:14 PM


All times are GMT -5. The time now is 10:29 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration