代码: 全选
# losetup -a
/dev/loop0: [2053]:13 (/media/username/UUID/disk)
代码: 全选
# losetup -a
/dev/loop0: [2053]:13 (/media/username/UUID/disk)
代码: 全选
[ tmp ] # fdisk -l /home/vickycq/Apps/img/bananian-1604.img
Disk /home/vickycq/Apps/img/bananian-1604.img: 1.8 GiB, 1899999744 bytes, 3710937 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x0ccea0b3
Device Boot Start End Sectors Size Id Type
/home/vickycq/Apps/img/bananian-1604.img1 2048 43007 40960 20M 83 Linux
/home/vickycq/Apps/img/bananian-1604.img2 43008 3710936 3667929 1.8G 83 Linux
[ tmp ] # py
Python 2.7.12+ (default, Sep 1 2016, 20:27:38)
[GCC 6.2.0 20160822] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 43008*512
22020096
>>>
[ tmp ] # mount -o offset=22020096 /home/vickycq/Apps/img/bananian-1604.img /mnt
[ tmp ] # losetup -a
/dev/loop0: [2052]:655787 (/home/vickycq/Apps/img/bananian-1604.img), offset 22020096
[ tmp ] # stat -c "%d %i" /home/vickycq/Apps/img/bananian-1604.img
2052 655787
代码: 全选
printf("%s: [%04d]:%" PRIu64 " (%s)",
loopcxt_get_device(lc), (int) dev, ino, fname);
if (loopcxt_get_offset(lc, &x) == 0 && x)
printf(_(", offset %ju"), x);
代码是怎么搜出来的啊vickycq 写了:util-linux-2.28.2/sys-utils/losetup.c代码: 全选
[ tmp ] # fdisk -l /home/vickycq/Apps/img/bananian-1604.img Disk /home/vickycq/Apps/img/bananian-1604.img: 1.8 GiB, 1899999744 bytes, 3710937 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x0ccea0b3 Device Boot Start End Sectors Size Id Type /home/vickycq/Apps/img/bananian-1604.img1 2048 43007 40960 20M 83 Linux /home/vickycq/Apps/img/bananian-1604.img2 43008 3710936 3667929 1.8G 83 Linux [ tmp ] # py Python 2.7.12+ (default, Sep 1 2016, 20:27:38) [GCC 6.2.0 20160822] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> 43008*512 22020096 >>> [ tmp ] # mount -o offset=22020096 /home/vickycq/Apps/img/bananian-1604.img /mnt [ tmp ] # losetup -a /dev/loop0: [2052]:655787 (/home/vickycq/Apps/img/bananian-1604.img), offset 22020096 [ tmp ] # stat -c "%d %i" /home/vickycq/Apps/img/bananian-1604.img 2052 655787
代码: 全选
printf("%s: [%04d]:%" PRIu64 " (%s)", loopcxt_get_device(lc), (int) dev, ino, fname); if (loopcxt_get_offset(lc, &x) == 0 && x) printf(_(", offset %ju"), x);
代码: 全选
grep '\"' losetup.c |grep '\:' |grep '\['| grep '\]' |grep '(' |grep ')'
代码: 全选
$ egrep '\S*: \[' -n -r
losetup.c:125: printf("%s: []: (%s)",
losetup.c:137: printf("%s: [%04d]:%" PRIu64 " (%s)",