summaryrefslogtreecommitdiff
path: root/legacy/eeze/src/bin/eeze_mount.c
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-01-29 04:21:53 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2011-01-29 04:21:53 +0000
commitc9e2fc434e2d477be0a1c2e2c5f19bcbe715aa80 (patch)
tree4900b9b9e58b1806ee0ce07becb2b14deb85062d /legacy/eeze/src/bin/eeze_mount.c
parent0cb7271e970294065e0d1a4b552897bce28b23dc (diff)
eeze 1.1 in trunk: disk mounting is now possible
SVN revision: 56362
Diffstat (limited to 'legacy/eeze/src/bin/eeze_mount.c')
-rw-r--r--legacy/eeze/src/bin/eeze_mount.c115
1 files changed, 115 insertions, 0 deletions
diff --git a/legacy/eeze/src/bin/eeze_mount.c b/legacy/eeze/src/bin/eeze_mount.c
new file mode 100644
index 0000000000..84b34bf99a
--- /dev/null
+++ b/legacy/eeze/src/bin/eeze_mount.c
@@ -0,0 +1,115 @@
1#include <Eeze.h>
2#include <Eeze_Disk.h>
3#include <Ecore.h>
4#include <Ecore_File.h>
5#include <Ecore_Getopt.h>
6#include <stdio.h>
7
8/** This app can be used as a "dumb" replacement for mount. Just don't try anything fancy yet! */
9static const Ecore_Getopt opts =
10{
11 "eeze_mount",
12 "eeze_mount /dev/sdb1 /media/disk",
13 "1.0",
14 "(C) 2010 Mike Blumenkrantz",
15 "LGPL",
16 "Mount a disk using either its /sys/ path or its /dev/ path\n\n",
17 1,
18 {
19 ECORE_GETOPT_VERSION('V', "version"),
20 ECORE_GETOPT_COPYRIGHT('R', "copyright"),
21 ECORE_GETOPT_LICENSE('L', "license"),
22 ECORE_GETOPT_HELP('h', "help"),
23 ECORE_GETOPT_SENTINEL
24 }
25};
26
27void
28_mount_cb(void *data, int type, Eeze_Event_Disk_Mount *e)
29{
30 (void)data;
31 (void)type;
32 printf("Success!\n");
33 eeze_disk_free(e->disk);
34 ecore_main_loop_quit();
35}
36
37void
38_error_cb(void *data, int type, Eeze_Event_Disk_Error *de)
39{
40 (void)data;
41 (void)type;
42 printf("Could not mount disk with /dev/ path: %s!\n", eeze_disk_devpath_get(de->disk));
43 eeze_disk_free(de->disk);
44 ecore_main_loop_quit();
45}
46
47int
48main(int argc, char *argv[])
49{
50 int args;
51 const char *dev, *mount_point;
52 Eina_Bool exit_option = EINA_FALSE;
53 Eeze_Disk *disk;
54
55 Ecore_Getopt_Value values[] =
56 {
57 ECORE_GETOPT_VALUE_BOOL(exit_option),
58 ECORE_GETOPT_VALUE_BOOL(exit_option),
59 ECORE_GETOPT_VALUE_BOOL(exit_option),
60 ECORE_GETOPT_VALUE_BOOL(exit_option)
61 };
62
63 if (argc < 2)
64 {
65 printf("Insufficient args specified!\n");
66 ecore_getopt_help(stderr, &opts);
67 exit(1);
68 }
69
70 ecore_init();
71 eeze_init();
72 ecore_app_args_set(argc, (const char **)argv);
73 args = ecore_getopt_parse(&opts, values, argc, argv);
74
75 if (exit_option)
76 return 0;
77
78 if (args < 0)
79 {
80 printf("No args specified!\n");
81 ecore_getopt_help(stderr, &opts);
82 exit(1);
83 }
84
85 dev = argv[args];
86 if (args + 1 < argc)
87 mount_point = argv[args + 1];
88 if ((!strncmp(dev, "/sys/", 5)) || (!strncmp(dev, "/dev/", 5)))
89 disk = eeze_disk_new(dev);
90 else if ((argc == 2) && (ecore_file_is_dir(dev)))
91 disk = eeze_disk_new_from_mount(dev);
92 else
93 {
94 printf("[Device] must be either a /dev/ path or a /sys/ path!\n");
95 ecore_getopt_help(stderr, &opts);
96 exit(1);
97 }
98 if (eeze_disk_mounted_get(disk))
99 {
100 printf("[%s] is already mounted!", dev);
101 exit(1);
102 }
103 if (argc > 2)
104 eeze_disk_mount_point_set(disk, mount_point);
105 ecore_event_handler_add(EEZE_EVENT_DISK_MOUNT, (Ecore_Event_Handler_Cb)_mount_cb, NULL);
106 ecore_event_handler_add(EEZE_EVENT_DISK_ERROR, (Ecore_Event_Handler_Cb)_error_cb, NULL);
107 if (!eeze_disk_mount(disk))
108 {
109 printf("Mount operation could not be started!\n");
110 exit(1);
111 }
112 ecore_main_loop_begin();
113
114 return 0;
115}