LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-05-2010, 12:09 AM   #1
nehapawar
LQ Newbie
 
Registered: May 2009
Posts: 22

Rep: Reputation: 15
how to give options like '-v' for mkdir using system call mkdir() ?


i've written a program which creates a directory using the system call mkdir()

int status;
status = mkdir("myDirectory",S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
printf("%d",status);

how can i execute 'mkdir -v' using this system call? is there another system call to include options?
 
Old 02-05-2010, 01:36 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,290

Rep: Reputation: 378Reputation: 378Reputation: 378Reputation: 378
The mkdir command is different than the mkdir system call -- there is not a one-to-one correspondence between command options and system call options. To use the mkdir(2) system call in this manner, in your program, you'll need to tewst if each level of the parent directory (below the root) exists, and if not make it. Alternatively, you could just try to make the directory, check for the ENOENT error return and if you get it cycle through the path and find the missing component(s).
 
Old 02-05-2010, 02:13 AM   #3
murugesan
Member
 
Registered: May 2003
Location: Bangalore ,Karnataka, India, Asia, Earth, Solar system, milky way galaxy, black hole
Distribution: murugesan openssl
Posts: 181

Rep: Reputation: 29
You can refer to the following urls related to mkdir "-p" option:

http://help.lockergnome.com/linux/mk...ict487118.html

http://www.koders.com/cpp/fid3005DF8...aspx?s=mkdir_p


The option -v from the manual of mkdir command:
print a message for each created directory
It is similar to the following codes:
http://murugesan.webnode.com/technical/c/mkdir-v/
 
  


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
mkdir freezes entire file system for 30secs Hegemon Linux - General 3 04-29-2009 06:03 AM
mkdir options sravanth.svk Linux - Newbie 4 10-26-2006 12:31 AM
mkdir: cannot create directory `test': Read-only file system punt Linux - General 2 04-16-2005 09:58 PM
Unpacking files=Cannot mkdir: Read-only file system Regenten Linux - Newbie 5 09-08-2004 03:23 AM
"mkdir: cannot create directory `foo': Read-only file system" on FAT32 maddes Linux - Hardware 1 11-26-2003 06:19 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:43 AM.

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