summaryrefslogtreecommitdiff
path: root/src/bin/eeze/eeze_mount.c
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-02-03 00:04:19 +0100
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2017-02-03 10:59:04 +0100
commit94ddd709dbae52a729179d8ad7ac4f8b06845ea3 (patch)
tree4c52f7f8a329a59beb3a9e552af4f5d7a92c0043 /src/bin/eeze/eeze_mount.c
parenteab798c753e72eece526ceccf3c9beb441b5f5ff (diff)
eeze: move binaries into subdirectories
in order to move to cmake we are moving every binary into its own subdirectory.
Diffstat (limited to 'src/bin/eeze/eeze_mount.c')
-rw-r--r--src/bin/eeze/eeze_mount.c134
1 files changed, 0 insertions, 134 deletions
diff --git a/src/bin/eeze/eeze_mount.c b/src/bin/eeze/eeze_mount.c
deleted file mode 100644
index 929437629c..0000000000
--- a/src/bin/eeze/eeze_mount.c
+++ /dev/null
@@ -1,134 +0,0 @@
1#ifdef HAVE_CONFIG_H
2# include <config.h>
3#endif
4
5#include <Eeze.h>
6#include <Eeze_Disk.h>
7#include <Ecore.h>
8#include <Ecore_File.h>
9#include <Ecore_Getopt.h>
10#include <stdio.h>
11
12/** This app can be used as a "dumb" replacement for mount. Just don't try anything fancy yet! */
13static const Ecore_Getopt opts =
14{
15 "eeze_mount",
16 "eeze_mount /dev/sdb1 /media/disk",
17 "1.0",
18 "(C) 2010 Mike Blumenkrantz",
19 "LGPL",
20 "Mount a disk using either its /sys/ path or its /dev/ path\n\n",
21 1,
22 {
23 ECORE_GETOPT_STORE_TRUE('v', "verbose", "Enable debug output"),
24 ECORE_GETOPT_VERSION('V', "version"),
25 ECORE_GETOPT_COPYRIGHT('R', "copyright"),
26 ECORE_GETOPT_LICENSE('L', "license"),
27 ECORE_GETOPT_HELP('h', "help"),
28 ECORE_GETOPT_SENTINEL
29 }
30};
31
32void
33_mount_cb(void *data, int type, Eeze_Event_Disk_Mount *e)
34{
35 (void)data;
36 (void)type;
37 printf("Success!\n");
38 eeze_disk_free(e->disk);
39 ecore_main_loop_quit();
40}
41
42void
43_error_cb(void *data, int type, Eeze_Event_Disk_Error *de)
44{
45 (void)data;
46 (void)type;
47 printf("Could not mount disk with /dev/ path: %s!\n", eeze_disk_devpath_get(de->disk));
48 eeze_disk_free(de->disk);
49 ecore_main_loop_quit();
50}
51
52int
53main(int argc, char *argv[])
54{
55 int args;
56 const char *dev, *mount_point = NULL;
57 Eina_Bool verbose = EINA_FALSE, exit_option = EINA_FALSE;
58 Eeze_Disk *disk;
59
60 Ecore_Getopt_Value values[] =
61 {
62 ECORE_GETOPT_VALUE_BOOL(verbose),
63 ECORE_GETOPT_VALUE_BOOL(exit_option),
64 ECORE_GETOPT_VALUE_BOOL(exit_option),
65 ECORE_GETOPT_VALUE_BOOL(exit_option),
66 ECORE_GETOPT_VALUE_BOOL(exit_option)
67 };
68
69 if (argc < 2)
70 {
71 printf("Insufficient args specified!\n");
72 ecore_getopt_help(stderr, &opts);
73 exit(1);
74 }
75
76 ecore_init();
77 eeze_init();
78 ecore_app_args_set(argc, (const char **)argv);
79 args = ecore_getopt_parse(&opts, values, argc, argv);
80
81 if (exit_option)
82 return 0;
83
84 if (args < 0)
85 {
86 printf("No args specified!\n");
87 ecore_getopt_help(stderr, &opts);
88 exit(1);
89 }
90 if (verbose) eina_log_domain_level_set("eeze_disk", EINA_LOG_LEVEL_DBG);
91 dev = argv[args];
92 if (args + 1 < argc)
93 mount_point = argv[args + 1];
94 if ((!strncmp(dev, "/sys/", 5)) || (!strncmp(dev, "/dev/", 5)))
95 disk = eeze_disk_new(dev);
96 else if ((args == argc - 1) && (ecore_file_is_dir(dev)))
97 disk = eeze_disk_new_from_mount(dev);
98 else
99 {
100 printf("[Device] must be either a /dev/ path or a /sys/ path!\n");
101 ecore_getopt_help(stderr, &opts);
102 exit(1);
103 }
104 if (eeze_disk_mounted_get(disk))
105 {
106 printf("[%s] is already mounted!", dev);
107 exit(1);
108 }
109 if (argc - args > 1)
110 {
111 eeze_disk_mount_point_set(disk, mount_point);
112 if (eina_str_has_extension(dev, "iso"))
113 {
114 int f;
115 f = eeze_disk_mountopts_get(disk);
116 eeze_disk_mountopts_set(disk, f | EEZE_DISK_MOUNTOPT_LOOP);
117 }
118 }
119 ecore_event_handler_add(EEZE_EVENT_DISK_MOUNT, (Ecore_Event_Handler_Cb)_mount_cb, NULL);
120 ecore_event_handler_add(EEZE_EVENT_DISK_ERROR, (Ecore_Event_Handler_Cb)_error_cb, NULL);
121 eeze_disk_mountopts_get(disk);
122 if (!eeze_disk_mount(disk))
123 {
124 const char *mp;
125
126 mp = eeze_disk_mount_point_get(disk);
127 if (!mp) fprintf(stderr, "No mount point passed!\n");
128 else fprintf(stderr, "Mount operation could not be started!\n");
129 exit(1);
130 }
131 ecore_main_loop_begin();
132
133 return 0;
134}