summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--discover/device-handler.c56
-rw-r--r--discover/network.c9
-rw-r--r--ui/ncurses/nc-add-url.c8
-rw-r--r--ui/ncurses/nc-boot-editor.c17
-rw-r--r--ui/ncurses/nc-config.c8
-rw-r--r--ui/ncurses/nc-lang.c1
-rw-r--r--ui/ncurses/nc-menu.c1
7 files changed, 90 insertions, 10 deletions
diff --git a/discover/device-handler.c b/discover/device-handler.c
index 5d9f988..f053713 100644
--- a/discover/device-handler.c
+++ b/discover/device-handler.c
@@ -1082,6 +1082,20 @@ static void device_handler_reinit_sources(struct device_handler *handler)
handler->dry_run);
}
+static const char *fs_parameters(unsigned int rw_flags, const char *fstype)
+{
+ if ((rw_flags | MS_RDONLY) != MS_RDONLY)
+ return "";
+
+ /* Avoid writing back to the disk on journaled filesystems */
+ if (!strncmp(fstype, "ext4", strlen("ext4")))
+ return "norecovery";
+ if (!strncmp(fstype, "xfs", strlen("xfs")))
+ return "norecovery";
+
+ return "";
+}
+
static bool check_existing_mount(struct discover_device *dev)
{
struct stat devstat, mntstat;
@@ -1155,6 +1169,13 @@ static int mount_device(struct discover_device *dev)
if (!fstype)
return 0;
+ /* ext3 treats the norecovery option as an error, so mount the device
+ * as an ext4 filesystem instead */
+ if (!strncmp(fstype, "ext3", strlen("ext3"))) {
+ pb_debug("Mounting ext3 filesystem as ext4\n");
+ fstype = talloc_asprintf(dev, "ext4");
+ }
+
dev->mount_path = join_paths(dev, mount_base(),
dev->device_path);
@@ -1167,7 +1188,8 @@ static int mount_device(struct discover_device *dev)
pb_log("mounting device %s read-only\n", dev->device_path);
errno = 0;
rc = mount(dev->device_path, dev->mount_path, fstype,
- MS_RDONLY | MS_SILENT, "");
+ MS_RDONLY | MS_SILENT,
+ fs_parameters(MS_RDONLY, fstype));
if (!rc) {
dev->mounted = true;
dev->mounted_rw = false;
@@ -1209,6 +1231,7 @@ static int umount_device(struct discover_device *dev)
int device_request_write(struct discover_device *dev, bool *release)
{
+ const char *fstype;
int rc;
*release = false;
@@ -1219,25 +1242,48 @@ int device_request_write(struct discover_device *dev, bool *release)
if (dev->mounted_rw)
return 0;
+ fstype = discover_device_get_param(dev, "ID_FS_TYPE");
+
pb_log("remounting device %s read-write\n", dev->device_path);
- rc = mount(dev->device_path, dev->mount_path, "",
- MS_REMOUNT | MS_SILENT, "");
- if (rc)
+
+ rc = umount(dev->mount_path);
+ if (rc) {
+ pb_log("Failed to unmount %s\n", dev->mount_path);
return -1;
+ }
+ rc = mount(dev->device_path, dev->mount_path, fstype,
+ MS_SILENT,
+ fs_parameters(MS_REMOUNT, fstype));
+ if (rc)
+ goto mount_ro;
dev->mounted_rw = true;
*release = true;
return 0;
+
+mount_ro:
+ pb_log("Unable to remount device %s read-write\n", dev->device_path);
+ rc = mount(dev->device_path, dev->mount_path, fstype,
+ MS_RDONLY | MS_SILENT,
+ fs_parameters(MS_RDONLY, fstype));
+ if (rc)
+ pb_log("Unable to recover mount for %s\n", dev->device_path);
+ return -1;
}
void device_release_write(struct discover_device *dev, bool release)
{
+ const char *fstype;
+
if (!release)
return;
+ fstype = discover_device_get_param(dev, "ID_FS_TYPE");
+
pb_log("remounting device %s read-only\n", dev->device_path);
mount(dev->device_path, dev->mount_path, "",
- MS_REMOUNT | MS_RDONLY | MS_SILENT, "");
+ MS_REMOUNT | MS_RDONLY | MS_SILENT,
+ fs_parameters(MS_RDONLY, fstype));
dev->mounted_rw = false;
}
diff --git a/discover/network.c b/discover/network.c
index 3946694..0dad087 100644
--- a/discover/network.c
+++ b/discover/network.c
@@ -510,6 +510,15 @@ static int network_handle_nlmsg(struct network *network, struct nlmsghdr *nlmsg)
add_interface(network, interface);
}
+ /* A repeated RTM_NEWLINK can represent an interface name change */
+ if (strncmp(interface->name, ifname, IFNAMSIZ)) {
+ pb_debug("ifname update: %s -> %s\n", interface->name, ifname);
+ strncpy(interface->name, ifname, sizeof(interface->name) - 1);
+ talloc_free(interface->dev->device->id);
+ interface->dev->device->id =
+ talloc_strdup(interface->dev->device, ifname);
+ }
+
/* notify the sysinfo code about changes to this interface */
if (strcmp(interface->name, "lo"))
system_info_register_interface(
diff --git a/ui/ncurses/nc-add-url.c b/ui/ncurses/nc-add-url.c
index 386d813..cf55b03 100644
--- a/ui/ncurses/nc-add-url.c
+++ b/ui/ncurses/nc-add-url.c
@@ -43,6 +43,7 @@ struct add_url_screen {
bool exit;
bool show_help;
+ bool need_redraw;
void (*on_exit)(struct cui *);
int label_x;
@@ -93,6 +94,7 @@ static void add_url_screen_process_key(struct nc_scr *scr, int key)
} else if (screen->show_help) {
screen->show_help = false;
+ screen->need_redraw = true;
cui_show_help(screen->cui, _("Retrieve Config"),
&add_url_help_text);
@@ -106,7 +108,10 @@ static int add_url_screen_post(struct nc_scr *scr)
struct add_url_screen *screen = add_url_screen_from_scr(scr);
widgetset_post(screen->widgetset);
nc_scr_frame_draw(scr);
- redrawwin(scr->main_ncw);
+ if (screen->need_redraw) {
+ redrawwin(scr->main_ncw);
+ screen->need_redraw = false;
+ }
wrefresh(screen->scr.main_ncw);
return 0;
}
@@ -224,6 +229,7 @@ struct add_url_screen *add_url_screen_init(struct cui *cui,
screen->on_exit = on_exit;
screen->label_x = 2;
screen->field_x = 25;
+ screen->need_redraw = false;
nc_scr_init(&screen->scr, pb_add_url_screen_sig, 0,
cui, add_url_screen_process_key,
diff --git a/ui/ncurses/nc-boot-editor.c b/ui/ncurses/nc-boot-editor.c
index 409e638..274bd9d 100644
--- a/ui/ncurses/nc-boot-editor.c
+++ b/ui/ncurses/nc-boot-editor.c
@@ -44,6 +44,7 @@ struct boot_editor {
void (*on_exit)(struct cui *cui,
struct pmenu_item *item,
struct pb_boot_data *bd);
+ bool need_redraw;
int label_x;
int field_x;
@@ -111,7 +112,10 @@ static int boot_editor_post(struct nc_scr *scr)
struct boot_editor *boot_editor = boot_editor_from_scr(scr);
widgetset_post(boot_editor->widgetset);
nc_scr_frame_draw(scr);
- redrawwin(scr->main_ncw);
+ if (boot_editor->need_redraw) {
+ redrawwin(scr->main_ncw);
+ boot_editor->need_redraw = false;
+ }
wrefresh(boot_editor->scr.main_ncw);
pad_refresh(boot_editor);
return 0;
@@ -173,6 +177,10 @@ static struct pb_boot_data *boot_editor_prepare_data(
s = widget_textbox_get_value(boot_editor->widgets.image_f);
bd->image = conditional_prefix(bd, prefix, s);
+ if (!bd->image) {
+ talloc_free(bd);
+ return NULL;
+ }
s = widget_textbox_get_value(boot_editor->widgets.initrd_f);
bd->initrd = conditional_prefix(bd, prefix, s);
@@ -216,12 +224,18 @@ static void boot_editor_process_key(struct nc_scr *scr, int key)
case STATE_SAVE:
item = boot_editor->item;
bd = boot_editor_prepare_data(boot_editor);
+ if (!bd) {
+ /* Incomplete entry */
+ boot_editor->state = STATE_EDIT;
+ break;
+ }
/* fall through */
case STATE_CANCEL:
boot_editor->on_exit(boot_editor->cui, item, bd);
break;
case STATE_HELP:
boot_editor->state = STATE_EDIT;
+ boot_editor->need_redraw = true;
cui_show_help(boot_editor->cui, _("Boot Option Editor"),
&boot_editor_help_text);
break;
@@ -559,6 +573,7 @@ struct boot_editor *boot_editor_init(struct cui *cui,
boot_editor->item = item;
boot_editor->on_exit = on_exit;
boot_editor->state = STATE_EDIT;
+ boot_editor->need_redraw = false;
int ncols1 = strncols(_("Device tree:"));
int ncols2 = strncols(_("Boot arguments:"));
diff --git a/ui/ncurses/nc-config.c b/ui/ncurses/nc-config.c
index 17cc380..c45df34 100644
--- a/ui/ncurses/nc-config.c
+++ b/ui/ncurses/nc-config.c
@@ -57,6 +57,7 @@ struct config_screen {
bool exit;
bool show_help;
+ bool need_redraw;
void (*on_exit)(struct cui *);
int scroll_y;
@@ -146,6 +147,7 @@ static void config_screen_process_key(struct nc_scr *scr, int key)
} else if (screen->show_help) {
screen->show_help = false;
+ screen->need_redraw = true;
cui_show_help(screen->cui, _("System Configuration"),
&config_help_text);
@@ -165,7 +167,10 @@ static int config_screen_post(struct nc_scr *scr)
struct config_screen *screen = config_screen_from_scr(scr);
widgetset_post(screen->widgetset);
nc_scr_frame_draw(scr);
- redrawwin(scr->main_ncw);
+ if (screen->need_redraw) {
+ redrawwin(scr->main_ncw);
+ screen->need_redraw = false;
+ }
wrefresh(screen->scr.main_ncw);
pad_refresh(screen);
return 0;
@@ -859,6 +864,7 @@ struct config_screen *config_screen_init(struct cui *cui,
screen->cui = cui;
screen->on_exit = on_exit;
+ screen->need_redraw = false;
screen->label_x = 2;
screen->field_x = 17;
diff --git a/ui/ncurses/nc-lang.c b/ui/ncurses/nc-lang.c
index 0422ebb..0b87156 100644
--- a/ui/ncurses/nc-lang.c
+++ b/ui/ncurses/nc-lang.c
@@ -131,7 +131,6 @@ static int lang_screen_post(struct nc_scr *scr)
struct lang_screen *screen = lang_screen_from_scr(scr);
widgetset_post(screen->widgetset);
nc_scr_frame_draw(scr);
- redrawwin(scr->main_ncw);
wrefresh(screen->scr.main_ncw);
pad_refresh(screen);
return 0;
diff --git a/ui/ncurses/nc-menu.c b/ui/ncurses/nc-menu.c
index 7ff2468..b8f9a35 100644
--- a/ui/ncurses/nc-menu.c
+++ b/ui/ncurses/nc-menu.c
@@ -62,7 +62,6 @@ static int pmenu_post(struct nc_scr *scr)
result = post_menu(menu->ncm);
nc_scr_frame_draw(scr);
- redrawwin(menu->scr.main_ncw);
wrefresh(menu->scr.main_ncw);
return result;
OpenPOWER on IntegriCloud