Solved

How to use "exportfs" programatically

Posted on 2004-03-24
8
325 Views
Last Modified: 2013-12-23
How do I programatically use "exportfs" feature and get the failure if any.
I tried forking new process and using "execpv" function to execute "exportfs" command. But I am not able to get the errors if "exportfs" command fails.

Thanks.
Madhu
0
Comment
Question by:bs_madhu
8 Comments
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 10669869
What do you mean by "get the errors".

Do you mean get the error messages?

If so, you're probably best off to call exportfs from a popen() call.

If you mean get the return code, you'll have to fork(), do the exec() in the child, and wait for  the return status with waitpid().

If you mean both get the return code and the error messages, you'll need to create a pipe(), fork(), dup() stderr to the pipe in the child, then exec() in the child, then read the child's stderr from the pipe in the parent, then wait for the return status with waitpid().

The various man pages should tell you the details you need to implement all this.
0
 

Author Comment

by:bs_madhu
ID: 10674251
My problem is programatically export file system ( so that other hosts can mount it )and inform the user if any error occurs while exporting.
Is their any library function which provides the option to export a file system ?.
I searched linux manpages I found only executable (exportfs) which does this. Since I have to do this programatically I don't know how to get the error codes ( like 'errno' ) and inform the user about the failure.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10675508
these functions depend on your OS
on Solaris for eaxample it's add_share() and del_share() (see /usr/include/sys/share.h)
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:bs_madhu
ID: 10675694
Anything on linux
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 10675903
see linux/nfsd/export.h
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 13238355
sigh, but agreed ..
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13275623
PAQed with no points refunded (of 125)

modulo
Community Support Moderator
0

Featured Post

Give your grad a cloud of their own!

With up to 8TB of storage, give your favorite graduate their own personal cloud to centralize all their photos, videos and music in one safe place. They can save, sync and share all their stuff, and automatic photo backup helps free up space on their smartphone and tablet.

Join & Write a Comment

Lets look at the default installation and configuration of FreeProxy 4.10 REQUIREMENTS 1. FreeProxy 4.10 Application - Can be downloaded here (http://www.handcraftedsoftware.org/index.php?page=download) 2. Ensure that you disable the windows fi…
Even if you have implemented a Mobile Device Management solution company wide, it is a good idea to make sure you are taking into account all of the major risks to your electronic protected health information (ePHI).
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now