Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

mntd_mount.c

00001 /***************************************************************************
00002  * CVSID: $Id: mntd_mount.c,v 1.5 2004/04/04 14:28:51 stefanb Exp $
00003  *
00004  * mntd_mount.c : Mount helper for MNT daemon
00005  *
00006  * Copyright (C) 2004 Stefan Bambach, <stefan@bambach.biz>
00007  *
00008  * Licensed under the GNU General Public License 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  **************************************************************************/
00025  
00026 #ifdef HAVE_CONFIG_H
00027 #  include <config.h>
00028 #endif
00029 
00030 #include <stdlib.h>
00031 #include <glib.h>
00032 
00033 #include "mntd_mount.h"
00034 #include "errmanager.h"
00035 
00036 
00052 int 
00053 mntd_mount_mount(const char *options, const char *device, const char *mntpnt)
00054 {
00055     char *command = NULL;
00056     char cmd[] = "/bin/mount";
00057     int res = -1;
00058     
00059     g_assert(options!=NULL);
00060     g_assert(device!=NULL);
00061     g_assert(mntpnt!=NULL);
00062     
00063     command = (char *) malloc(sizeof(char)*(strlen(cmd)+strlen(options)+
00064                                         strlen(device)+strlen(mntpnt)+4));
00065     if (command!=NULL) {
00066         sprintf(command, "%s %s %s %s", cmd, options, device, mntpnt);
00067         res = system(command);
00068         if (command!=NULL) {
00069             free(command);
00070             command = NULL;
00071         }
00072     }
00073     
00074     return res;
00075 }
00076 
00077 
00084 int 
00085 mntd_mount_umount(const char *options, const char *path)
00086 {
00087     char *command = NULL;
00088     char cmd[] = "/bin/umount";
00089     int res = -1;
00090     
00091     g_assert(options!=NULL);
00092     g_assert(path!=NULL);
00093     
00094     command = (char *) malloc(sizeof(char)*(strlen(cmd)+strlen(options)+
00095                                         strlen(path)+3));
00096     if (command!=NULL) {
00097         sprintf(command, "%s %s %s", cmd, options, path);
00098         res = system(command);
00099         if (command!=NULL) {
00100             free(command);
00101             command = NULL;
00102         }
00103     }
00104     
00105     return res;
00106 }
00107 
00108 

Generated on Thu May 27 23:27:28 2004 for Mntd by doxygen 1.3.5