了解 Ubuntu 中不同对象的相同 inode 编号 [英] To understand the same inode numbers for different objects in Ubuntu

查看:33
本文介绍了了解 Ubuntu 中不同对象的相同 inode 编号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么/cdrom 的 inode 编号与 Ubuntu 中的 /sys/devices/platform/power 相同?

Why does /cdrom has the same inode -number than /sys/devices/platform/power in Ubuntu?

以下在我的 Ubuntu 中具有相同的 inode 编号

The following have the same inode number in my Ubuntu

./media/BACKUP_1/MISC
./cdrom
./sys/devices/platform/power

我通过在根目录下运行以下命令来获取它们

I get them by running the following at root

find . -inum 12 2> /dev/null

<小时>

回复莱夫勒的回答

我跑

stat cdrom

我明白

  File: `cdrom' -> `media/cdrom'
  Size: 11              Blocks: 0          IO Block: 4096   symbolic link
Device: 801h/2049d      Inode: 12          Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2009-08-03 04:25:35.000000000 +0300
Modify: 2009-08-03 04:19:05.000000000 +0300
Change: 2009-08-03 04:19:05.000000000 +0300

这些信息告诉你什么?

回复莱夫勒的编辑

通常,您可以剖析设备编号为主要和次要设备'ls -l' 打印的数字用于设备.

Often, you can dissect the device number into a major and minor device number which is what 'ls -l' prints for a device.

这个命令 ls -l cdrom 给了我这个

This command ls -l cdrom gives me this

lrwxrwxrwx 1 root root 11 2009-08-03 04:19 cdrom -> media/cdrom 

如何从中看出主次设备号?

推荐答案

这些设备可能位于不同的文件系统上 - 文件系统和 inode 编号的组合才是唯一的.

The devices are probably on different file systems - and it is the combination of the file system and the inode number that is unique.

如果您使用 stat() 系统调用,相关字段是 st_inost_dev(和 st_rdevcode> 标识特殊设备).

If you use the stat() system call, the relevant fields are the st_ino and st_dev (and st_rdev identifies special devices).

问题被扩展了 - 询问可以从中收集哪些信息:

The question was extended - asking what information can be gleaned from:

  File: `cdrom' -> `media/cdrom'
  Size: 11              Blocks: 0          IO Block: 4096   symbolic link
Device: 801h/2049d      Inode: 12          Links: 1

从这里可以收集到很多东西.关键是这个符号链接在文件系统上,设备号(st_rdev)为0x0801(或2049),inode号为12.通常,你可以将设备号分解为'ls -l' 为设备打印的主要和次要设备号.很有可能(但我没有正式验证过)主设备号是 8,次设备号是 1(基于十六进制表示 0x0801).

There are many things that can be gleaned from this. The key ones are that this symbolic link is on the file system with device number (st_rdev) of 0x0801 (or 2049), and the inode number is 12. Often, you can dissect the device number into a major and minor device number which is what 'ls -l' prints for a device. There's a decent chance (but I have not formally verified this) that the major device number is 8 and the minor device is 1 (based on the hex representation 0x0801).

问题再次延长:

这个命令 ls -l cdrom 给了我这个

This command ls -l cdrom gives me this

lrwxrwxrwx 1 root root 11 2009-08-03 04:19 cdrom -> media/cdrom

如何从中看出主次设备号?

How can you see the major and minor device number from this?

简短的回答是你不能".其中之一的输出可能会提供适当的信息:

The short answer is "you can't". The output from one of these might be appropriately informative:

ls -l media/cdrom
ls -lL cdrom

我建议,上一个问题中显示的设备(stat 命令的输出)具有主要设备 8 和次要设备 1.您可以通过运行 'ls-l' 在作为 '.' 的文件系统挂载的设备上.您可以使用df ."来查找已安装设备的名称 - 可能还有其他机制也可以使用.

The device shown in the previous question (the output from the stat command) has, I suggested, major device 8 and minor device 1. You'd find that by running 'ls -l' on the device that is mounted as the file system for '.'. You might use 'df .' to find the name of the mounted device - there are probably other mechanisms that would work too.

这篇关于了解 Ubuntu 中不同对象的相同 inode 编号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆