LinuxQuestions.org
Help answer threads with 0 replies.
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, 01: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, 02:36 AM   #2
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,284

Rep: Reputation: 371Reputation: 371Reputation: 371Reputation: 371
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, 03:13 AM   #3
murugesan
Member
 
Registered: May 2003
Posts: 151

Rep: Reputation: 28
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


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


All times are GMT -5. The time now is 11:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration