zoukankan      html  css  js  c++  java
  • Linux filesystem detection

    16 down vote accepted

    The reason you can't find it is because, for the most part, it's not in the kernel -- it's in the userspace mount utility, which is in the util-linux package. If you don't give it a filesystem type, or if you give it a type of "any", mount merely goes through the list of all of the filesystems the kernel knows about, and tries each one in order until one of them mounts successfully (or returns an error if none of them do).

    How does it find out what filesystem types the kernel knows about? It reads the /proc/filesystems file, which walks the file_systems linked list in fs/filesystems.c. When a filesystem driver is loaded, it calls register_filesystem in that same file to add itself to that list. For example, there's a call to register_filesystem in init_ext2_fs in fs/ext2/super.cinit_ext2_fs is the module-init function for the ext2 module.

    Some filesystems are noisy and print errors to the kernel debug log when someone tries to mount a device with the wrong filesystem, which is why, for instance, you might see errors about "invalid XFS filesystem" when successfully mounting an ext4 filesystem, if mount happened to try xfs first.

    shareimprove this answer
     
    2  
    And the way the driver knows if it's valid is that most file systems have a "magic number" near the beginning of the partition that it looks for. – Keith Apr 16 '11 at 4:49
        
    Thank you, great answer! – sloc Apr 16 '11 at 11:03
  • 相关阅读:
    Deployment descriptor
    实体、list 、xml之间的转化
    关于C# 汉字转拼音问题
    NPoco学习笔记(1)
    SQL(二)
    SQL(一)
    sobel算子及cvSobel
    图像的平滑处理
    erase的用法
    int main(int argc, char* argv[ ])
  • 原文地址:https://www.cnblogs.com/hustxujinkang/p/5072397.html
Copyright © 2011-2022 走看看