Solved

How to use "exportfs" programatically

Posted on 2004-03-24
8
353 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most of the applications these days are on Cloud. Cloud is ubiquitous with many service providers in the market. Since it has many benefits such as cost reduction, software updates, remote access, disaster recovery and much more.
WARNING:   If you follow the instructions here, you will wipe out your VTP and VLAN configurations.  Make sure you have backed up your switch!!! I recently had some issues with a few low-end Cisco routers (RV325) and I opened a case with Cisco TA…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

628 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