00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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