losetup -a输出的那些数字是什么意思?

其它类软件,非上述版软件
回复
头像
vickycq
帖子: 4507
注册时间: 2011-03-20 13:12
系统: Debian
来自: 山东省寿光县
联系:

Re: losetup -a输出的那些数字是什么意思?

#2

帖子 vickycq » 2016-10-04 15:23

代码: 全选

[ 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
util-linux-2.28.2/sys-utils/losetup.c

代码: 全选

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);
Debian 中文论坛 - forums.debiancn.org
欢迎所有 Debian GNU/Linux 用户
科学之子
帖子: 2284
注册时间: 2013-05-26 6:58
系统: Debian 9

Re: losetup -a输出的那些数字是什么意思?

#3

帖子 科学之子 » 2016-10-04 18:19

vickycq 写了:

代码: 全选

[ 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
util-linux-2.28.2/sys-utils/losetup.c

代码: 全选

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);
代码是怎么搜出来的啊 :Adore

代码: 全选

 grep  '\"' losetup.c |grep '\:' |grep '\['| grep '\]' |grep '(' |grep ')'
当时只想到这种方式

后来仔细看了看正则表达式的介绍
http://www.runoob.com/regexp/regexp-syntax.html

代码: 全选

$ egrep '\S*: \['  -n -r
losetup.c:125:		printf("%s: []: (%s)",
losetup.c:137:	printf("%s: [%04d]:%" PRIu64 " (%s)",
回复