Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call lsblk to detect MICROBIT devices #22

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

conchyliculture
Copy link

By default on debian mount won't display labels, you need mount -l
To get a more specified (and hopefully universal) string for mounted block devices, it is preferable to run lsblk (which is in util-linux package)

@virtualabs
Copy link
Owner

Well, I am using Debian and have no problem with the current version of Btlejack. Can you give more insight about the error you may have encountered ?

@conchyliculture
Copy link
Author

The current code searches for a mounted partition with the name MICROBIT.
The problem is on my debian (buster), mount doesn't display the labels by default:

$ mount --version
mount from util-linux 2.32.1 (libmount 2.32.1: selinux, smack, btrfs, assert, debug)

From the manual:

       The following command lists all mounted filesystems (of type type):

              mount [-l] [-t type]

       The option -l adds labels to this listing.  See below.

I don't have a microbit device with me right now to test. So if I make a silly file with just a VFAT partition with a name:

# truncate -s 100M img ; sgdisk -og  img ; sgdisk -n 1:2048:20480 img ; losetup --show -fP img
/dev/loop0
# mkfs.vfat -n MICROBIT /dev/loop0p1 ; mkdir /mnt/testlabel ; mount /dev/loop0p1 /mnt/testlabel

With mount:

# mount | grep testlabel
/dev/loop0p1 on /mnt/testlabel type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro)

with mount -l :

# mount -l | grep testlabel
/dev/loop0p1 on /mnt/testlabel type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro) [MICROBIT]

For other projects, I found that lsblk has nicer options for output parsing. But maybe we should follow what the mount manual says:

   Listing the mounts
       The listing mode is maintained for backward compatibility only.

       For more robust and customizable output use findmnt(8), especially in your scripts.   Note  that  control
       characters in the mountpoint name are replaced with '?'.

@nviennot
Copy link
Contributor

lsblk is not present by default on MacOS. So I vote for no.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants