From 79043f9ae3d8d25858a4d058276859202d35888e Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Thu, 4 Oct 2018 21:17:00 -0500 Subject: [PATCH 01/17] Update buildroot with new kernel for DVD support Previously, exporting an ISO larger than 2GB would silently truncate the file. On some systems, the file could still mount but others would detect a corrupt filesystem or mount but fail later. Now the max ISO size is about 80GB. --- .gitlab-ci.yml | 2 +- buildroot | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 956a2e4..fe98dcf 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -36,4 +36,4 @@ make-image: cache: key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG" paths: - - buildroot/output/ + - buildroot/output/ diff --git a/buildroot b/buildroot index 419f13d..65fe62b 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 419f13d68596750ddd36ba5700493765da02ecd2 +Subproject commit 65fe62bd0c0eaf2ab67835949f15a885ace1b2e1 From 0483946cee55f1511402cf94917a877eb9cee2b4 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Fri, 5 Oct 2018 11:11:08 -0500 Subject: [PATCH 02/17] Switch to 'update.zip' for updates This avoids some updates only needing an updated rootfs, while others require a kernel and initramfs update as well. Now, the user just needs to extract this update.zip file to the root of their SD card. --- .gitlab-ci.yml | 2 +- Makefile | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index fe98dcf..11622fd 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -30,7 +30,7 @@ make-image: name: "sdimage-$CI_COMMIT_SHA" paths: - sdcard.img.zip - - rootfs.squashfs + - update.zip - build.log when: always cache: diff --git a/Makefile b/Makefile index ded9990..868664f 100644 --- a/Makefile +++ b/Makefile @@ -40,8 +40,9 @@ else endif git submodule > buildroot/output/.cache-version zip -j sdcard.img.zip buildroot/output/images/sdcard.img - cp buildroot/output/images/rootfs.squashfs . - + zip -j update.zip buildroot/output/images/zImage \ + buildroot/output/images/rootfs.squashfs \ + buildroot/output/images/initramfs.cpio.lzo .PHONY: update-config update-config: cd "$(CURDIR)/buildroot" && cp "configs/piso_defconfig" ".config" From 46bfc0fb3a8fe32b4d3b432ed0a9b507cc446ea6 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Wed, 10 Oct 2018 16:15:19 -0500 Subject: [PATCH 03/17] Update to kernel with READ TRACK INFO support --- buildroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot b/buildroot index 65fe62b..304f65d 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 65fe62bd0c0eaf2ab67835949f15a885ace1b2e1 +Subproject commit 304f65de2aea318bc2be0b38d26be4337153d209 From 9324ee4820d20fbd95b4b2102500d983063e5f56 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Wed, 10 Oct 2018 16:27:51 -0500 Subject: [PATCH 04/17] Update buildroot to have 'piso' hostname (fixes #50) --- buildroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot b/buildroot index 304f65d..fe2eeb4 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 304f65de2aea318bc2be0b38d26be4337153d209 +Subproject commit fe2eeb46c8e2676ff8787df1f16c7fa52295fbd9 From 71b5845a5bf634d09aef945eb9330cbe6e017d96 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Wed, 10 Oct 2018 17:06:12 -0500 Subject: [PATCH 05/17] Fix bug with READ TRACk INFO --- buildroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot b/buildroot index fe2eeb4..48312f5 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit fe2eeb46c8e2676ff8787df1f16c7fa52295fbd9 +Subproject commit 48312f57c6f99c6ef66e340f39baf3258647c98b From 3fa0af1cc6fb8ca85b6ff589bdd75284f73f504c Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Wed, 10 Oct 2018 22:09:00 -0500 Subject: [PATCH 06/17] Increase USB MaxPower to 500mA --- pISO/src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pISO/src/main.rs b/pISO/src/main.rs index 4ad03a2..4f0f613 100644 --- a/pISO/src/main.rs +++ b/pISO/src/main.rs @@ -115,7 +115,7 @@ fn run(manager: &mut displaymanager::DisplayManager) -> error::Result<()> { manufacturer: "Adam Schwalm & James Tate", product: "pISO", - max_power: "250", + max_power: "500", configuration: "Config 1", }, )?)); From e8dc56b4fc35ce7b76c705dcc13f3959318f18bd Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Thu, 11 Oct 2018 20:31:45 -0500 Subject: [PATCH 07/17] Do not show 'plugged in' drives over network (fixes #49) --- pISO/src/vdrive.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/pISO/src/vdrive.rs b/pISO/src/vdrive.rs index 8975e79..7bf17f0 100644 --- a/pISO/src/vdrive.rs +++ b/pISO/src/vdrive.rs @@ -240,6 +240,7 @@ impl VirtualDrive { } for part in info.part_mount_paths.iter() { utils::run_check_output("umount", &[&part])?; + fs::remove_dir_all(&part)?; } utils::run_check_output("losetup", &["-d", &info.loopback_path.to_string_lossy()])?; } From 3c4381f99fa0f28cda0f3473a6c8ab0832e81c79 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Thu, 11 Oct 2018 21:17:37 -0500 Subject: [PATCH 08/17] Add version menu (fixes #36) --- buildroot | 2 +- pISO/VERSION | 1 + pISO/src/action.rs | 3 + pISO/src/options.rs | 7 +++ pISO/src/version.rs | 138 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 pISO/VERSION diff --git a/buildroot b/buildroot index 48312f5..66fdfd3 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 48312f57c6f99c6ef66e340f39baf3258647c98b +Subproject commit 66fdfd3fc90e978e3cdce32ce318eb6a45e1f178 diff --git a/pISO/VERSION b/pISO/VERSION new file mode 100644 index 0000000..0408c30 --- /dev/null +++ b/pISO/VERSION @@ -0,0 +1 @@ +v1.2.0 \ No newline at end of file diff --git a/pISO/src/action.rs b/pISO/src/action.rs index efb49aa..8313470 100644 --- a/pISO/src/action.rs +++ b/pISO/src/action.rs @@ -36,4 +36,7 @@ pub enum Action { ToggleDriveNonRemovable(String), FlipDisplay, + + OpenVersion, + CloseVersion } diff --git a/pISO/src/options.rs b/pISO/src/options.rs index 7361367..9902ebb 100644 --- a/pISO/src/options.rs +++ b/pISO/src/options.rs @@ -10,6 +10,7 @@ use input; use lvm; use render; use state; +use version; pub struct Options { window: WindowId, @@ -18,6 +19,7 @@ pub struct Options { removable: buttons::vdrivelist::DriveList, delete: buttons::vdrivelist::DriveList, snapshot: buttons::vdrivelist::DriveList, + version: version::VersionMenu } impl Options { @@ -68,6 +70,8 @@ impl Options { config.clone(), )?; + let version = version::VersionMenu::new(disp)?; + Ok(Options { window: our_window, open: false, @@ -75,6 +79,7 @@ impl Options { removable: removable, delete: delete, snapshot: snapshot, + version: version }) } } @@ -115,6 +120,7 @@ impl Widget for Options { &mut self.removable as &mut Widget, &mut self.snapshot as &mut Widget, &mut self.delete as &mut Widget, + &mut self.version as &mut Widget ] } else { vec![] @@ -128,6 +134,7 @@ impl Widget for Options { &self.removable as &Widget, &self.snapshot as &Widget, &self.delete as &Widget, + &self.version as &Widget ] } else { vec![] diff --git a/pISO/src/version.rs b/pISO/src/version.rs index 82c15af..bbb8083 100644 --- a/pISO/src/version.rs +++ b/pISO/src/version.rs @@ -1,5 +1,13 @@ +use action; +use bitmap; +use controller; +use displaymanager::{DisplayManager, Position, Widget, Window, WindowId}; use error; +use font; +use input; use utils; +use render; +use state; #[derive(Debug, Eq, PartialEq)] pub enum PiVersion { @@ -38,3 +46,133 @@ pub fn read_version() -> error::Result { _ => Ok(PiVersion::Unknown), } } + +static PISO_VERSION: &'static str = include_str!("../VERSION"); + +enum VersionState { + Unselected, + Selected(OpenVersionMenu), +} + +pub struct VersionMenu { + pub window: WindowId, + state: VersionState +} + +impl VersionMenu { + pub fn new(disp: &mut DisplayManager) -> error::Result { + Ok(VersionMenu { + window: disp.add_child(Position::Normal)?, + state: VersionState::Unselected + }) + } +} + +impl render::Render for VersionMenu { + fn render(&self, _manager: &DisplayManager, window: &Window) -> error::Result { + let mut base = bitmap::Bitmap::new(10, 1); + base.blit(&font::render_text("Version"), (16, 0)); + if window.focus { + base.blit(&bitmap::Bitmap::from_slice(font::ARROW), (0, 0)); + } + Ok(base) + } +} + +impl input::Input for VersionMenu { + fn on_event( + &mut self, + event: &controller::Event, + ) -> error::Result<(bool, Vec)> { + match *event { + controller::Event::Select => Ok((true, vec![action::Action::OpenVersion])), + _ => Ok((false, vec![])), + } + } + + fn do_action( + &mut self, + disp: &mut DisplayManager, + action: &action::Action, + ) -> error::Result<(bool, Vec)> { + match *action { + action::Action::OpenVersion => { + let menu = + OpenVersionMenu::new(disp)?; + disp.shift_focus(&menu); + self.state = VersionState::Selected(menu); + Ok((true, vec![])) + } + action::Action::CloseVersion => { + disp.shift_focus(self); + self.state = VersionState::Unselected; + Ok((true, vec![])) + } + _ => Ok((false, vec![])), + } + } +} + +impl state::State for VersionMenu {} + +impl Widget for VersionMenu { + fn mut_children(&mut self) -> Vec<&mut Widget> { + match self.state { + VersionState::Selected(ref mut widget) => vec![widget], + VersionState::Unselected => vec![], + } + } + + fn children(&self) -> Vec<&Widget> { + match self.state { + VersionState::Selected(ref widget) => vec![widget], + VersionState::Unselected => vec![], + } + } + + fn windowid(&self) -> WindowId { + self.window + } +} + + + +struct OpenVersionMenu { + pub window: WindowId +} + +impl OpenVersionMenu { + fn new(disp: &mut DisplayManager) -> error::Result { + Ok(OpenVersionMenu { + window: disp.add_child(Position::Fixed(0, 0))?, + }) + } +} + +impl render::Render for OpenVersionMenu { + fn render(&self, _manager: &DisplayManager, _window: &Window) -> error::Result { + let mut base = bitmap::Bitmap::new(display::DISPLAY_WIDTH, display::DISPLAY_HEIGHT); + base.blit(&font::render_text(format!("OS Version: {}", PISO_VERSION)), (6, 0)); + Ok(base) + } +} + +impl input::Input for OpenVersionMenu { + fn on_event( + &mut self, + event: &controller::Event, + ) -> error::Result<(bool, Vec)> { + match *event { + controller::Event::Select => Ok((true, vec![action::Action::CloseVersion])), + _ => Ok((false, vec![])), + } + } +} + +impl state::State for OpenVersionMenu {} + +impl Widget for OpenVersionMenu { + fn windowid(&self) -> WindowId { + self.window + } +} From a852ddf09236eba588e45718be278b77f2d78340 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Sat, 13 Oct 2018 11:39:21 -0500 Subject: [PATCH 09/17] Use separate smb shares for each partition (fixes #42) --- pISO/src/action.rs | 5 +++- pISO/src/options.rs | 8 +++--- pISO/src/piso.rs | 53 +++++++++++++++++++++++++++++++-------- pISO/src/vdrive.rs | 15 ++++++++--- pISO/src/version.rs | 12 ++++----- pISO/src/wifi.rs | 61 ++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 123 insertions(+), 31 deletions(-) diff --git a/pISO/src/action.rs b/pISO/src/action.rs index 8313470..3ff77c3 100644 --- a/pISO/src/action.rs +++ b/pISO/src/action.rs @@ -38,5 +38,8 @@ pub enum Action { FlipDisplay, OpenVersion, - CloseVersion + CloseVersion, + + SmbSharePartition(String), + SmbRemoveShare(String), } diff --git a/pISO/src/options.rs b/pISO/src/options.rs index 9902ebb..597cf91 100644 --- a/pISO/src/options.rs +++ b/pISO/src/options.rs @@ -19,7 +19,7 @@ pub struct Options { removable: buttons::vdrivelist::DriveList, delete: buttons::vdrivelist::DriveList, snapshot: buttons::vdrivelist::DriveList, - version: version::VersionMenu + version: version::VersionMenu, } impl Options { @@ -79,7 +79,7 @@ impl Options { removable: removable, delete: delete, snapshot: snapshot, - version: version + version: version, }) } } @@ -120,7 +120,7 @@ impl Widget for Options { &mut self.removable as &mut Widget, &mut self.snapshot as &mut Widget, &mut self.delete as &mut Widget, - &mut self.version as &mut Widget + &mut self.version as &mut Widget, ] } else { vec![] @@ -134,7 +134,7 @@ impl Widget for Options { &self.removable as &Widget, &self.snapshot as &Widget, &self.delete as &Widget, - &self.version as &Widget + &self.version as &Widget, ] } else { vec![] diff --git a/pISO/src/piso.rs b/pISO/src/piso.rs index a252d00..925fa99 100644 --- a/pISO/src/piso.rs +++ b/pISO/src/piso.rs @@ -107,18 +107,45 @@ impl PIso { Ok(drives) } - fn add_drive( - &mut self, - disp: &mut DisplayManager, + fn add_drive<'a, 'b>( + &'a mut self, + disp: &'b mut DisplayManager, volume: lvm::LogicalVolume, - ) -> Result<&vdrive::VirtualDrive> { - let vdrive = vdrive::VirtualDrive::new(disp, self.usb.clone(), volume, &self.config)?; + ) -> Result<&'a mut vdrive::VirtualDrive> { + let mut vdrive = vdrive::VirtualDrive::new(disp, self.usb.clone(), volume, &self.config)?; + vdrive.mount_internal(disp)?; self.drives.push(vdrive); Ok(self.drives - .last() + .last_mut() .expect("vdrive was somehow empty after push")) } + + fn share_drive(drive: &mut vdrive::VirtualDrive, remove: bool) -> Result> { + match drive.state { + vdrive::MountState::Unmounted | vdrive::MountState::External(_) => { + if remove { + Ok(vec![]) + } else { + Err("Cannot share drive when not mounted internal".into()) + } + } + vdrive::MountState::Internal(ref info) => Ok(info.part_mount_paths + .iter() + .map(|path| { + let name = path.file_name() + .expect("Partition has no name") + .to_string_lossy() + .into_owned(); + if remove { + action::Action::SmbRemoveShare(name) + } else { + action::Action::SmbSharePartition(name) + } + }) + .collect()), + } + } } impl render::Render for PIso { @@ -145,23 +172,27 @@ impl input::Input for PIso { Ok((true, vec![])) } action::Action::CreateDrive(ref volume) => { - self.add_drive(disp, volume.clone())?; - Ok((true, vec![])) + let drive = self.add_drive(disp, volume.clone())?; + let actions = PIso::share_drive(drive, false)?; + Ok((true, actions)) } action::Action::SnapshotDrive(ref name) => { let report = self.vg.snapshot_volume(name)?; - self.add_drive(disp, report)?; - Ok((true, vec![])) + let drive = self.add_drive(disp, report)?; + let actions = PIso::share_drive(drive, false)?; + Ok((true, actions)) } action::Action::DeleteDrive(ref name) => { + let mut actions = vec![]; if let Some(ref mut drive) = self.drives.iter_mut().find(|drive| drive.name() == name) { + actions = PIso::share_drive(drive, true)?; drive.unmount()?; } self.drives.retain(|drive| drive.name() != name); self.vg.delete_volume(&name)?; - Ok((true, vec![])) + Ok((true, actions)) } _ => Ok((false, vec![])), } diff --git a/pISO/src/vdrive.rs b/pISO/src/vdrive.rs index 7bf17f0..451bbe8 100644 --- a/pISO/src/vdrive.rs +++ b/pISO/src/vdrive.rs @@ -152,7 +152,10 @@ impl VirtualDrive { ).into()) } - pub fn mount_internal(&mut self, disp: &mut DisplayManager) -> Result<()> { + pub fn mount_internal<'a, 'b>( + &'a mut self, + disp: &'b mut DisplayManager, + ) -> Result<&'a MountInfo> { match self.state { MountState::Unmounted => { let volume_path = &self.volume.path.to_string_lossy(); @@ -222,9 +225,12 @@ impl VirtualDrive { isos: isos, loopback_path: loopback_path.to_path_buf(), }); - Ok(()) + match &self.state { + &MountState::Internal(ref info) => Ok(info), + _ => unreachable!(), + } } - MountState::Internal(_) => Ok(()), + MountState::Internal(ref state) => Ok(state), MountState::External(_) => { Err("Attempt to mount_internal while mounted external".into()) } @@ -262,7 +268,8 @@ impl VirtualDrive { } MountState::External(_) => { self.unmount_external()?; - self.mount_internal(disp) + self.mount_internal(disp)?; + Ok(()) } } } diff --git a/pISO/src/version.rs b/pISO/src/version.rs index bbb8083..5f45a6e 100644 --- a/pISO/src/version.rs +++ b/pISO/src/version.rs @@ -1,6 +1,7 @@ use action; use bitmap; use controller; +use display; use displaymanager::{DisplayManager, Position, Widget, Window, WindowId}; use error; use font; @@ -56,14 +57,14 @@ enum VersionState { pub struct VersionMenu { pub window: WindowId, - state: VersionState + state: VersionState, } impl VersionMenu { pub fn new(disp: &mut DisplayManager) -> error::Result { Ok(VersionMenu { window: disp.add_child(Position::Normal)?, - state: VersionState::Unselected + state: VersionState::Unselected, }) } } @@ -97,8 +98,7 @@ impl input::Input for VersionMenu { ) -> error::Result<(bool, Vec)> { match *action { action::Action::OpenVersion => { - let menu = - OpenVersionMenu::new(disp)?; + let menu = OpenVersionMenu::new(disp)?; disp.shift_focus(&menu); self.state = VersionState::Selected(menu); Ok((true, vec![])) @@ -135,10 +135,8 @@ impl Widget for VersionMenu { } } - - struct OpenVersionMenu { - pub window: WindowId + pub window: WindowId, } impl OpenVersionMenu { diff --git a/pISO/src/wifi.rs b/pISO/src/wifi.rs index 162add9..e8bea2d 100644 --- a/pISO/src/wifi.rs +++ b/pISO/src/wifi.rs @@ -22,7 +22,6 @@ const HOSTAPD_TMP_CONF: &'static str = "/tmp/hostapd.conf"; const WPA_SUPPLICANT_CONF: &'static str = "/etc/wpa_supplicant.conf"; const WPA_SUPPLICANT_TMP_CONF: &'static str = "/tmp/wpa_supplicant.conf"; const SMB_CONF: &'static str = "/etc/samba/smb.conf"; -const SMB_TMP_CONF: &'static str = "/tmp/smb.conf"; const PURE_FTPD_CONF: &'static str = "/etc/pure-ftpd.conf"; #[derive(PartialEq)] @@ -46,6 +45,10 @@ impl WifiManager { })) } + fn is_enabled(&self) -> bool { + self.state != WifiState::Uninitialized + } + fn enable_wifi(&mut self) -> error::Result<()> { if self.state != WifiState::Uninitialized { return Ok(()); @@ -87,13 +90,55 @@ impl WifiManager { &[&self.config.user.name, &self.config.user.password], )?; - fs::copy(SMB_CONF, SMB_TMP_CONF)?; - utils::run_check_output("smbd", &["-D", "-s", SMB_TMP_CONF])?; - utils::run_check_output("nmbd", &["-D", "-s", SMB_TMP_CONF])?; + // Setup usershare folder + fs::create_dir_all("/var/lib/samba/usershares")?; + utils::run_check_output("chmod", &["1770", "/var/lib/samba/usershares"])?; + + utils::run_check_output("smbd", &["-D", "-s", SMB_CONF])?; + utils::run_check_output("nmbd", &["-D", "-s", SMB_CONF])?; utils::run_check_output("pure-ftpd", &[PURE_FTPD_CONF])?; self.state = WifiState::Inactive; + + for entry in fs::read_dir("/mnt")? { + let entry = entry?; + let path = entry.path(); + let name = path.file_name() + .expect("Partition has no name") + .to_string_lossy() + .into_owned(); + self.share_mounted_partition(&name)?; + } + + Ok(()) + } + + fn share_mounted_partition(&mut self, name: &str) -> error::Result<()> { + if !self.is_enabled() { + return Ok(()); + } + + let path = "/user-mnt/".to_owned() + name; + utils::run_check_output( + "net", + &[ + "usershare", + "add", + name, + &path, + "", + &format!("piso\\{}:F", &self.config.user.name), + ], + )?; + Ok(()) + } + + fn remove_shared_partition(&mut self, name: &str) -> error::Result<()> { + if !self.is_enabled() { + return Ok(()); + } + utils::run_check_output("net", &["usershare", "delete", &name])?; Ok(()) } @@ -262,6 +307,14 @@ impl input::Input for WifiMenu { disp.shift_focus(self); Ok((true, vec![])) } + action::Action::SmbSharePartition(ref name) => { + self.manager.lock()?.share_mounted_partition(name)?; + Ok((true, vec![])) + } + action::Action::SmbRemoveShare(ref name) => { + self.manager.lock()?.remove_shared_partition(name)?; + Ok((true, vec![])) + } _ => Ok((false, vec![])), } } From da2cd72efbbac5f90428ae2bb30ac2ff5194d609 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Mon, 22 Oct 2018 19:48:34 -0500 Subject: [PATCH 10/17] Update buildroot for more accurate cd emulation --- buildroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot b/buildroot index 66fdfd3..0c3a44e 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 66fdfd3fc90e978e3cdce32ce318eb6a45e1f178 +Subproject commit 0c3a44ebc566a38cf2e0405d53ee3fc93e11b742 From d6bd9478cdb467466ad9a2e42bf489da8dc5a5ed Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Mon, 22 Oct 2018 23:13:13 -0500 Subject: [PATCH 11/17] Fix bug where discs would not mount is MacOS (fixes #32) This was caused by MacOS issuing a READ DVD STRUCTURE command to determine the type of disc being read. When we failed to respond to this, the OS starts to attempt to read with CD READ requests instead of standard READ requests. We don't support CD READ currently. Now we respond to the first request correctly, so MacOS does normal READs and things work correctly. --- buildroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildroot b/buildroot index 0c3a44e..f1e55aa 160000 --- a/buildroot +++ b/buildroot @@ -1 +1 @@ -Subproject commit 0c3a44ebc566a38cf2e0405d53ee3fc93e11b742 +Subproject commit f1e55aa0b6d679f7aceb1986311709821e5ec568 From 24c687d8eaf3afb8e9ee63cee574bea5ad4c1788 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Tue, 23 Oct 2018 22:11:35 -0500 Subject: [PATCH 12/17] Add support for sorting drives by name (fixes #59) --- pISO/src/config.rs | 3 +++ pISO/src/piso.rs | 31 ++++++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/pISO/src/config.rs b/pISO/src/config.rs index 0a19ef1..8436816 100644 --- a/pISO/src/config.rs +++ b/pISO/src/config.rs @@ -19,6 +19,8 @@ pub struct UiConfig { #[serde(deserialize_with = "from_millis")] pub button_long_press: time::Duration, + + pub sort_drives: Option, } #[derive(Clone, Debug, Deserialize)] @@ -77,6 +79,7 @@ mod tests { default_size=50 min_button_press=300 button_long_press=2000 + sort_drives=true [system] auto_fstrim=true diff --git a/pISO/src/piso.rs b/pISO/src/piso.rs index 925fa99..28ba53a 100644 --- a/pISO/src/piso.rs +++ b/pISO/src/piso.rs @@ -203,10 +203,22 @@ impl state::State for PIso {} impl Widget for PIso { fn mut_children(&mut self) -> Vec<&mut Widget> { - let mut children = self.drives - .iter_mut() + let mut ordered_children = self.drives + .iter_mut() + .collect::>(); + + match self.config.ui.sort_drives { + Some(true) => ordered_children.sort_by(|drive1, drive2| { + drive1.volume.name.cmp(&drive2.volume.name) + }), + _ => () + } + + let mut children = ordered_children + .into_iter() .map(|vdrive| vdrive as &mut Widget) .collect::>(); + children.push(&mut self.newdrive as &mut Widget); if self.version.has_wifi() { children.push(&mut self.wifi as &mut Widget); @@ -217,10 +229,23 @@ impl Widget for PIso { } fn children(&self) -> Vec<&Widget> { - let mut children = self.drives + let mut ordered_children = self.drives .iter() + .collect::>(); + + match self.config.ui.sort_drives { + Some(true) => ordered_children.sort_by(|drive1, drive2| { + utils::translate_drive_name(&drive1.volume.name, &self.config).cmp( + &utils::translate_drive_name(&drive2.volume.name, &self.config)) + }), + _ => () + } + + let mut children = ordered_children + .into_iter() .map(|vdrive| vdrive as &Widget) .collect::>(); + children.push(&self.newdrive as &Widget); if self.version.has_wifi() { children.push(&self.wifi as &Widget); From 0ace29cac275d73200bdbee3025e902fe6593c4d Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Wed, 24 Oct 2018 18:33:40 -0500 Subject: [PATCH 13/17] Allow step_size and default_size to be floats (fixes #57) --- pISO/src/config.rs | 6 +++--- pISO/src/newdrive.rs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pISO/src/config.rs b/pISO/src/config.rs index 8436816..4e12338 100644 --- a/pISO/src/config.rs +++ b/pISO/src/config.rs @@ -11,8 +11,8 @@ where #[derive(Clone, Debug, Deserialize)] pub struct UiConfig { - pub size_step: u32, - pub default_size: u32, + pub size_step: f32, + pub default_size: f32, #[serde(deserialize_with = "from_millis")] pub min_button_press: time::Duration, @@ -116,7 +116,7 @@ mod tests { fn load_with_no_wifi_client() { let toml_str = r#" [ui] - size_step=5 + size_step=4.2 default_size=50 min_button_press=300 button_long_press=2000 diff --git a/pISO/src/newdrive.rs b/pISO/src/newdrive.rs index 6e7bbef..891b6dd 100644 --- a/pISO/src/newdrive.rs +++ b/pISO/src/newdrive.rs @@ -123,7 +123,7 @@ enum DriveSizeState { struct DriveSize { pub window: WindowId, - pub current_percent: u32, + pub current_percent: f32, pub usb: Arc>, vg: lvm::VolumeGroup, state: DriveSizeState, @@ -149,7 +149,7 @@ impl DriveSize { fn current_size(&self) -> u64 { let bytes = self.vg.report().expect("Failed to get vg report").vg_size as f32 - * (self.current_percent as f32 / 100.0); + * (self.current_percent / 100.0); ((bytes as u64 + 512 - 1) / 512) * 512 } } From e4ddbcba2650989067ba849db0d57783a82e00a7 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Wed, 24 Oct 2018 18:51:34 -0500 Subject: [PATCH 14/17] Prevent underflow of new drive percent (fixes #74) --- pISO/src/newdrive.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pISO/src/newdrive.rs b/pISO/src/newdrive.rs index 891b6dd..f924061 100644 --- a/pISO/src/newdrive.rs +++ b/pISO/src/newdrive.rs @@ -192,7 +192,9 @@ impl input::Input for DriveSize { Ok((true, vec![])) } action::Action::DecDriveSize => { - self.current_percent -= self.config.ui.size_step; + if self.current_percent - self.config.ui.size_step > 0.0 { + self.current_percent -= self.config.ui.size_step; + } Ok((true, vec![])) } action::Action::OpenFormatMenu => { From 0531d72dcb461b12fba3a008080ad67d0598a3ab Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Tue, 30 Oct 2018 20:37:26 -0500 Subject: [PATCH 15/17] Fix bug where non W Raspberry Pi Zeros would hang after driver creation (fixes #66) --- pISO/src/piso.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pISO/src/piso.rs b/pISO/src/piso.rs index 28ba53a..0ac8198 100644 --- a/pISO/src/piso.rs +++ b/pISO/src/piso.rs @@ -122,6 +122,9 @@ impl PIso { } fn share_drive(drive: &mut vdrive::VirtualDrive, remove: bool) -> Result> { + if !version::read_version()?.has_wifi() { + return Ok(vec![]); + } match drive.state { vdrive::MountState::Unmounted | vdrive::MountState::External(_) => { if remove { From a4f9a52e78f9cd98d5983e92d3b2f11069d6db1e Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Tue, 30 Oct 2018 20:37:46 -0500 Subject: [PATCH 16/17] Update VERSION file --- pISO/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pISO/VERSION b/pISO/VERSION index 0408c30..8b3a022 100644 --- a/pISO/VERSION +++ b/pISO/VERSION @@ -1 +1 @@ -v1.2.0 \ No newline at end of file +v1.3.0 \ No newline at end of file From 2a56c4545c92a4e93d0d68ede9c6ab2def11a9f5 Mon Sep 17 00:00:00 2001 From: Adam Schwalm Date: Tue, 30 Oct 2018 21:04:24 -0500 Subject: [PATCH 17/17] Fix bug where usage could be too precise --- pISO/src/stats.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pISO/src/stats.rs b/pISO/src/stats.rs index 15a0adb..f1adc38 100644 --- a/pISO/src/stats.rs +++ b/pISO/src/stats.rs @@ -28,7 +28,7 @@ impl render::Render for Stats { fn render(&self, _manager: &DisplayManager, _window: &Window) -> error::Result { let mut base = bitmap::Bitmap::new(0, 0); let percent_free = 100.0 - self.vg.pool()?.data_percent; - let contents = font::render_text(format!("{}% Free", percent_free)); + let contents = font::render_text(format!("{}% Free", percent_free as u64)); base.blit(&contents, (0, 0)); Ok(base.rotate(bitmap::Direction::Left)) }