Skip to content

Commit 00b43eb

Browse files
committed
loooots of bugfixes and changes: check changelog. Most noticeably: libudev is now mandatory.
1 parent 8199f9e commit 00b43eb

File tree

14 files changed

+200
-242
lines changed

14 files changed

+200
-242
lines changed

Changelog

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
02 / 05 / 2016
2+
* fixed iso files mounting. Now works fine and reliably.
3+
* removed is_mounted and relying on mntent function (get_mount_points)
4+
* fixed check_cwd function and moved those checks to mount_fs (only when unmounting), to make them useful even when unmounting an iso.
5+
* fixed is_iso_mounted check: it will now perform check to see if a loop device with the same backingfile is unmounted (but already present...created by user or another program), and mount the iso on this loop dev, instead of creating another loop dev.
6+
* moved SetAutoclear on loopdevices to its own function: it has to be called after add_device mounts the loop_dev.
7+
* fixed a bug if compiled with clang ( uint8_t bytes = '\0' was const, with gcc worked fine, but not with clang)
8+
* fixed add_device: relying on some udev dev property values instead of is_mounted function.
9+
* fixed print_info: if info_win is not present, it won't do anything.
10+
* helper_string (helper_win) content will now change together with compile time options, hiding the useless ones.
11+
* libudev is now mandatory
12+
* fixes in add_device: checking if a "size" property is really available for current dev.
13+
114
02 / 02 / 2016
215
* using basename() and dirname() functions instead of manually strrchr path strings. Way cleaner and probably more reliable.
316
* using change_dir when creating new_tab to check for chdir errors and reuse more code.

PKGBUILD

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ optdepends=('xdg-utils: xdg-open support'
1313
'udisks2: mountable drives and ISO mount support'
1414
'packagekit: package installation support'
1515
'upower: AC (dis)connection events support')
16-
# libcups, libconfig, libx11, openssl, and systemd are optional build dep.
16+
# libcups, libconfig, libx11, and openssl are optional build dep.
1717
# If compiled without them, the program will run just fine;
18-
# but that would disable xdg-open, config file read, printing, shasum, powermanagement inhibition,
19-
# drives/iso mount, local packages installation and upower AC (dis)connection signals support.
18+
# but that would disable xdg-open, config file read, printing, and shasum support.
19+
# systemd too is an optdep. But in arch libudev is packaged together with it,
20+
# and libudev is a mandatory dep.
2021
makedepends=('git')
2122
source=("git://github.com/FedeDP/${_gitname}.git")
2223
backup=('etc/default/ncursesFM.conf')

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ It can be built with a very small set of dependencies, as i tried to make as man
1616
* Every feature you would expect by a basic FM.
1717
* Terminal window resize support.
1818
* 2 tabs support. Their content is kept in sync. Jump between tabs with arrow keys (left/right).
19-
* Simple sysinfo monitor that will refresh every 30s: clock, battery and some system info; battery monitor needs libudev.
19+
* Simple sysinfo monitor that will refresh every 30s: clock, battery and some system info.
2020
If you've got Upower installed, AC (dis)connection will refresh battery status instantly, instead of waiting up to 30s until next refresh.
2121
* Fast browse mode: enable it with ','. It lets you jump between files by just typing their names.
2222
* '.' to change files/dirs sorting mode: alphabetically (default), by size, by last modified or by type.
@@ -37,7 +37,7 @@ You can add whatever type of file you wish as bookmark from within ncursesFM. Yo
3737
* Powermanagement inhibition while processing a job (eg: while pasting a file) to avoid data loss.
3838
* Internal udisks2 monitor, to poll for new devices. It can automount new connected devices too.
3939
Device monitor will list only mountable devices, eg: dvd reader will not be listed until a cd/dvd is inserted.
40-
* Drives/usb sticks/ISO files (un)mount through udisks2. For drives/usb sticks mount, you also need libudev.
40+
* Drives/usb sticks/ISO files (un)mount through udisks2.
4141
* Distro package files installation.
4242
* It can reveice AC (dis)connection events from upower, to instantly update battery monitor.
4343

@@ -72,27 +72,26 @@ Log file is located at "$HOME/.ncursesfm.log". It is overwritten each time ncurs
7272
* 3 : log disabled.
7373

7474
## Build requirements
75-
* linux>=3.4 -> pipe2() O_DIRECT flag. See: http://man7.org/linux/man-pages/man2/pipe.2.html
75+
* linux >= 3.4 -> pipe2() O_DIRECT flag. See: http://man7.org/linux/man-pages/man2/pipe.2.html
7676
* ncurses -> UI
7777
* libarchive -> archiving/extracting support
7878
* pkg-config -> to manage libraries link in makefile
79-
* glibc -> to set locale, for inotify, and for mntent functions (useful only if compiled with libudev too)
79+
* glibc -> to set locale, for inotify, and for mntent functions.
80+
* libudev -> needed for devices/iso mount, and batteries polling.
8081
* git -> to clone repo
8182

8283
## Optional compile time dependencies
8384
* libcups -> print support.
8485
* libconfig -> config file parsing.
8586
* libx11 -> check whether ncursesFM is started in a X environment or not, and xdg-open support.
8687
* sd-bus -> needed for powermanagement inhibition functions, devices/iso mount and packages installation.
87-
* libudev -> needed for devices/iso mount, and batteries polling.
8888
* openssl -> for shasum function support.
8989

9090
**Build options (to be passed to make)**
9191
* CC={gcc/clang} to choose the compiler. By default, env CC will be used.
9292
* DISABLE_LIBX11=1 to disable libx11 support.
9393
* DISABLE_LIBCONFIG=1 to disable libconfig support.
9494
* DISABLE_LIBSYSTEMD=1 to disable libsystemd (sd-bus) support.
95-
* DISABLE_LIBUDEV=1 to disable libudev support.
9695
* DISABLE_LIBOPENSSL=1 ti disable openssl support.
9796
* DISABLE_LIBCUPS=1 to disable libcups support.
9897

@@ -114,11 +113,11 @@ Log file is located at "$HOME/.ncursesfm.log". It is overwritten each time ncurs
114113

115114
On Ubuntu install required packages:
116115

117-
# apt-get install libncursesw5-dev libarchive-dev pkg-config git build-essential
116+
# apt-get install libncursesw5-dev libarchive-dev pkg-config git build-essential libudev-dev
118117

119118
Optional:
120119

121-
# apt-get install libcups2-dev libconfig-dev libx11-dev libsystemd-dev libudev-dev libssl-dev
120+
# apt-get install libcups2-dev libconfig-dev libx11-dev libsystemd-dev libssl-dev
122121

123122
Clone the repo and move inside new dir, then:
124123

inc/declarations.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ struct conf {
7474
int second_tab_starting_dir;
7575
#ifdef SYSTEMD_PRESENT
7676
int inhibit;
77-
#ifdef LIBUDEV_PRESENT
7877
int automount;
79-
#endif
8078
#endif
8179
int starting_helper;
8280
int loglevel;

inc/mount.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
1-
#ifdef SYSTEMD_PRESENT
2-
31
#include "fm_functions.h"
4-
#include <systemd/sd-bus.h>
5-
6-
void isomount(const char *str);
72

8-
#ifdef LIBUDEV_PRESENT
3+
#ifdef SYSTEMD_PRESENT
94

5+
#include <systemd/sd-bus.h>
106
#include <libudev.h>
117
#include <mntent.h>
128

9+
void isomount(const char *str);
1310
int start_monitor(void);
1411
void devices_bus_process(void);
1512
void show_devices_tab(void);
1613
void manage_mount_device(void);
1714
void manage_enter_device(void);
1815
void leave_device_mode(void);
1916
void free_device_monitor(void);
20-
#endif
17+
2118
#endif

inc/string_constants.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
#ifdef SYSTEMD_PRESENT
12
#define HELPER_HEIGHT 14
3+
#else
4+
#define HELPER_HEIGHT 12
5+
#endif
6+
27
#define LONG_FILE_OPERATIONS 5
38
#define SHORT_FILE_OPERATIONS 3
49

@@ -67,9 +72,6 @@ const char *helper_string[HELPER_HEIGHT - 2];
6772
const char *pkg_quest;
6873
const char *install_th_wait;
6974
const char *package_warn;
70-
#endif
71-
72-
#ifdef LIBUDEV_PRESENT
7375
const char *device_mode_str;
7476
#endif
7577
const char *bookmarks_mode_str;

makefile

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
LIBS =-lpthread $(shell pkg-config --silence-errors --libs libarchive ncurses)
1+
LIBS =-lpthread $(shell pkg-config --silence-errors --libs libarchive ncurses libudev)
22
CFLAGS =-D_GNU_SOURCE
33
RM = rm
44
INSTALL = install -p
@@ -24,14 +24,11 @@ endif
2424
ifneq ("$(DISABLE_LIBSYSTEMD)","1")
2525
LIBSYSTEMD=$(shell pkg-config --silence-errors --libs libsystemd)
2626
endif
27-
ifneq ("$(DISABLE_LIBUDEV)","1")
28-
LIBUDEV=$(shell pkg-config --silence-errors --libs libudev)
29-
endif
3027
ifneq ("$(DISABLE_OPENSSL)","1")
3128
LIBOPENSSL=$(shell pkg-config --silence-errors --libs openssl)
3229
endif
3330

34-
LIBS+=$(LIBX11) $(LIBCONFIG) $(LIBSYSTEMD) $(LIBUDEV) $(LIBOPENSSL)
31+
LIBS+=$(LIBX11) $(LIBCONFIG) $(LIBSYSTEMD) $(LIBOPENSSL)
3532

3633
ifneq ("$(LIBX11)","")
3734
CFLAGS+=-DLIBX11_PRESENT
@@ -61,11 +58,6 @@ CFLAGS+=-DSYSTEMD_PRESENT
6158
$(info libsystemd support enabled.)
6259
endif
6360

64-
ifneq ("$(LIBUDEV)","")
65-
CFLAGS+=-DLIBUDEV_PRESENT
66-
$(info libudev support enabled.)
67-
endif
68-
6961
endif
7062

7163
all: ncursesFM clean

src/log.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,12 @@ static void log_current_options(void) {
3737
fprintf(log_file, "* Second tab starting dir: %d\n", config.second_tab_starting_dir);
3838
#ifdef SYSTEMD_PRESENT
3939
fprintf(log_file, "* Inhibition: %d\n", config.inhibit);
40-
#ifdef LIBUDEV_PRESENT
4140
fprintf(log_file, "* Automount: %d\n", config.automount);
42-
#endif
4341
#endif
4442
fprintf(log_file, "* Starting with helper window: %d\n", config.starting_helper);
4543
fprintf(log_file, "* Log level: %d\n", config.loglevel);
4644
fprintf(log_file, "* Log persistency: %d\n", config.persistent_log);
47-
#ifdef LIBUDEV_PRESENT
4845
fprintf(log_file, "* Low battery threshold: %d\n\n", config.bat_low_level);
49-
#endif
5046
}
5147

5248
void log_message(const char *filename, int lineno, const char *funcname, const char *log_msg, char type, int log_level) {

src/main.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static void read_config_file(void);
3838
#endif
3939
static void config_checks(void);
4040
static void main_loop(void);
41-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
41+
#ifdef SYSTEMD_PRESENT
4242
static void check_device_mode(void);
4343
#endif
4444
static void manage_enter(struct stat current_file_stat);
@@ -91,7 +91,7 @@ static void set_signals(void) {
9191
}
9292

9393
static void set_pollfd(void) {
94-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
94+
#ifdef SYSTEMD_PRESENT
9595
nfds = 6;
9696
#else
9797
nfds = 5;
@@ -122,7 +122,7 @@ static void set_pollfd(void) {
122122
.fd = info_fd[0],
123123
.events = POLLIN,
124124
};
125-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
125+
#ifdef SYSTEMD_PRESENT
126126
main_p[DEVMON_IX] = (struct pollfd) {
127127
.fd = start_monitor(),
128128
.events = POLLIN,
@@ -157,11 +157,9 @@ static void sigsegv_handler(int signum) {
157157
static void helper_function(int argc, const char *argv[]) {
158158
/* default value for starting_helper, bat_low_level and device_mode */
159159
config.starting_helper = 1;
160-
#ifdef LIBUDEV_PRESENT
161160
config.bat_low_level = 15;
162161
#ifdef SYSTEMD_PRESENT
163162
device_mode = DEVMON_STARTING;
164-
#endif
165163
#endif
166164

167165
if ((argc > 1) && (!strcmp(argv[1], "--help"))) {
@@ -190,11 +188,7 @@ static void helper_function(int argc, const char *argv[]) {
190188
static void parse_cmd(int argc, const char *argv[]) {
191189
int j = 1;
192190
#ifdef SYSTEMD_PRESENT
193-
#ifdef LIBUDEV_PRESENT
194191
const char *cmd_switch[] = {"--editor", "--starting_dir", "--helper_win", "--loglevel", "--persistent_log", "--low_level", "--inhibit", "--automount"};
195-
#else
196-
const char *cmd_switch[] = {"--editor", "--starting_dir", "--helper_win", "--loglevel", "--persistent_log", "--low_level", "--inhibit"};
197-
#endif
198192
#else
199193
const char *cmd_switch[] = {"--editor", "--starting_dir", "--helper_win", "--loglevel", "--persistent_log", "--low_level"};
200194
#endif
@@ -217,11 +211,9 @@ static void parse_cmd(int argc, const char *argv[]) {
217211
else if ((!strcmp(cmd_switch[6], argv[j])) && (argv[j + 1])) {
218212
config.inhibit = atoi(argv[j + 1]);
219213
}
220-
#ifdef LIBUDEV_PRESENT
221214
else if ((!strcmp(cmd_switch[7], argv[j])) && (argv[j + 1])) {
222215
config.automount = atoi(argv[j + 1]);
223216
}
224-
#endif
225217
#endif
226218
else {
227219
break;
@@ -253,9 +245,7 @@ static void read_config_file(void) {
253245
config_lookup_int(&cfg, "starting_helper", &config.starting_helper);
254246
#ifdef SYSTEMD_PRESENT
255247
config_lookup_int(&cfg, "inhibit", &config.inhibit);
256-
#ifdef LIBUDEV_PRESENT
257248
config_lookup_int(&cfg, "automount", &config.automount);
258-
#endif
259249
#endif
260250
config_lookup_int(&cfg, "loglevel", &config.loglevel);
261251
config_lookup_int(&cfg, "persistent_log", &config.persistent_log);
@@ -398,7 +388,7 @@ static void main_loop(void) {
398388
}
399389
break;
400390
#endif
401-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
391+
#ifdef SYSTEMD_PRESENT
402392
case 'm': // m to mount/unmount fs
403393
check_device_mode();
404394
break;
@@ -447,7 +437,7 @@ static void main_loop(void) {
447437
}
448438
}
449439

450-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
440+
#ifdef SYSTEMD_PRESENT
451441
static void check_device_mode(void) {
452442
if (sv.searching == 3 + active || bookmarks_mode[active]) {
453443
return;
@@ -472,7 +462,7 @@ static void manage_enter(struct stat current_file_stat) {
472462
sv.found_searched[ps[active].curr_pos][index] = '\0';
473463
leave_search_mode(sv.found_searched[ps[active].curr_pos]);
474464
}
475-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
465+
#ifdef SYSTEMD_PRESENT
476466
else if (device_mode == 1 + active) {
477467
manage_enter_device();
478468
}
@@ -492,7 +482,7 @@ static void manage_quit(void) {
492482
if (sv.searching == 3 + active) {
493483
leave_search_mode(ps[active].my_cwd);
494484
}
495-
#if defined SYSTEMD_PRESENT && LIBUDEV_PRESENT
485+
#ifdef SYSTEMD_PRESENT
496486
else if (device_mode == 1 + active) {
497487
leave_device_mode();
498488
}

0 commit comments

Comments
 (0)