Android filesystem and inodes

I have recently learned about Unix inodes and their purpose. In particular, I learned that an.inode is unique across a filesystem.

My question is: if a user inserts a Micro SD card into their Android device, does that card become part of the existing filesystem or does it become a separate filesystem?

or, to put it another way: can inodes be duplicated across the internal and external storages?

Many thanks, P


Micro SD cards usually use FAT32, a file system which store no inodes. The Linux kernel is creating a random inode number that is different from other ones when a new file is accessed.

On a FAT32 file system, a pathname is enough to uniquely identify a file, unlike with other file systems where a file can have any number of pathnames including none at all.

These FAT32 fake inode numbers are dropped:

  • when the file system is unmounted
  • when the OS reboots
  • when the fixed size cache where they are stored is full

Should you want a reliable way to identify files on FAT32, don't use their inodes.

I would suggest to use a hash of their pathname, combined with their size if you want to be really sure to avoid collision.

It's a separate filesystem. So yes, a file on the internal storage can have the same inode number as a file on the external storage, even though they are distinct files.

In case your real question is how to uniquely identify a file, you need both the inode number and the device id number. Both can be retrieved with the *stat() family syscalls, specifically the st_dev and st_ino fields of the stat struct.

Need Your Help

How to load a merged JS file containing several modules with requireJs?

javascript merge requirejs

That's something I've struggled with for more than a year now, I don't get how we are supposed to load a JS file that contains several AMD modules at once to avoid making as many HTTP requests as t...

C++ Check if Key Exists using Map within a Map

c++ c++11 map

I have a map defined as map<string, map<string,int> > grandMap; and I need to check if the internal map has a key term. If so, count it. Here's what I tried already:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.