Op maandag 15 oktober 2012 23:25:08 schreef AL13N:
[...]
> -> actively look for new devices (or size-changed devices) and handle those;
> and thus not change all the changes you've made already.
> 
> The point of this is more like stepping stone towards the real things: ie:
> not aborting if there are no disks. and later adding installable
> network-based disks (for diskless systems).
> 
> And also, if your one of your hotplugged disks isn't correctly in it, i'd
> like to refresh it, so the 4th one is detected and so i can add it to the
> raid, for instance. instead of exiting the installer, etc...
> 
> in any case, it seems like someone found that it showed gray for a all
> disks, so it might not be that good after all...
> 
> but it would be nice for me though if i could pick your brain about the code
> and the way of programming though... it's not always easy to get around
> this kind of code.
> 
> Can i ask you in the future to look at this from time to time?
[...]

Ok, so this is a new patch; this time, it's next to the toggle for expert 
button.

I do a new device check, in a separate variable and check with device file as 
unique; if there's one that isn't in the old list. (or if it's changed size). 
in that case i put the new entry into the old list.

however, it seems that a VM shuts itself off on executing the check when a new 
USB disk was added. :-(

Maybe i'm doing some fundamentals wrong, so i'm asking here if anyone has an 
insight, idea or direction i should go to instead.

i'm thinking because i only do 1 of the 5 preparation checks for new disks, 
that maybe not everything is done correctly yet: but a halting VM is not 
exactly what i expected...

AL13N
Index: diskdrake/interactive.pm
===================================================================
--- diskdrake/interactive.pm	(revision 6434)
+++ diskdrake/interactive.pm	(working copy)
@@ -323,7 +323,10 @@
 
 sub hd_possible_actions_extra {
     my ($_hd) = @_;
-    $::expert ? N_("Toggle to normal mode") : N_("Toggle to expert mode");
+    (
+     N_("Refresh"),
+     $::expert ? N_("Toggle to normal mode") : N_("Toggle to expert mode"),
+    );
 }
 
 
@@ -338,6 +341,29 @@
     &hd_possible_actions, N_("Hard disk drive information");
 }
 
+sub Refresh {
+    my ($in, $current_hd, $all_hds) = @_;
+
+    # redo the first2 steps in a diff variable
+    my $all_hds2 = fsedit::get_hds({}, $in);
+    # TODO: do i need to get_raw_hds too? are raw disks shown?
+    # fs::get_raw_hds('', $all_hds2);
+    
+    # file based index of old hds
+    my %old_hds = map { $_->{file} => $_ } @{$all_hds->{hds}};
+
+    # same for new, but also push the new hd to all_hds if it has different size or not exist
+    my %new_hds = map { push @{$all_hds->{hds}} if (!defined $old_hds{$_->{file}} || $_->{total_sectors} != $old_hds{$_->{file}}->{total_sectors}); $_->{file} => $_ } @{$all_hds2->{hds}};
+
+    # find deleted ones
+    for my $hd (@{$all_hds->{hds}}) {
+        if (!defined $new_hds{$hd->{file}}) {
+            # TODO: mark the hd as unavailable
+        }
+    }
+    $all_hds;
+}
+
 sub Clear_all {
     my ($in, $hd, $all_hds) = @_;
     return if detect_devices::is_xbox(); #- do not let them wipe the OS
@@ -1134,6 +1160,7 @@
     *{'Toggle to normal mode'} = sub() { $::expert = 0 };
     *{'Toggle to expert mode'} = sub() { $::expert = 1 };
     *{'Clear all'} = \&Clear_all;
+    *{'Refresh'} = \&Refresh;
     *{'Auto allocate'} = \&Auto_allocate;
     *{'Mount point'} = \&Mount_point;
     *{'Modify RAID'} = \&ModifyRAID;

Reply via email to