LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2008, 06:40 AM   #1
Karbon
LQ Newbie
 
Registered: Jun 2008
Posts: 5

Rep: Reputation: 0
Question Linux programming "program to format an external storage device?"


Hi,

I am a newbie to programming on linux.

I wanted to write a program to detect and format an external Usb storage device connected to linux.

I need info from a programming point of view:

1. how does linux tell me if a new mass storage usb device is plugged into the system?

2. How do i format the device connected ? I checked man pages and found reference to "mkfs". The only way to make it work through code is by using the system() API. I do not want to use system() API. Is there any other way of doing this ?

Thanks in advance,

- Karbon.
 
Old 06-19-2008, 05:45 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
  1. A few ways (e.g., udev or hal) are available. If you want to monitor from your own program, you can interface with hal using the dbus interface or libhal.
  2. Well there are obviously many different types of “format” for a filesystem. If you want to create your own, you are welcome to perform simple write()s on the block device representing the volume. Otherwise, you can use one of the programs specifically designed to format partitions (e.g., mkfs.ext3 or mkfs.vfat). If you don’t want to launch an external program, you might find libraries which give you the ability to do this (e.g., libext2fs).
 
  


Reply



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
External HD "Not a valid block device" Slackware 10.0 ZiggyJustice Linux - Hardware 2 03-02-2005 03:18 PM
Getting error: "ALSA device "default" is already in use by another program." brynjarh Debian 7 02-04-2005 11:45 AM
Linux "broke" USB-mass storage device? - no longer workable in Windows XP lrt2003 Linux - Hardware 3 06-13-2004 10:56 PM
USB storage device works in 2.4 not 2.6 "no device error" critch Linux - Hardware 4 05-18-2004 11:13 AM
USB-Storage "6 in 1" device alfiejohn Linux - Hardware 2 09-06-2003 07:52 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:16 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