Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-05-2010, 12:09 AM   #1
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);

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
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
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:

The option -v from the manual of mkdir command:
print a message for each created directory
It is similar to the following codes:


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 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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:22 PM.

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