Why can't files be manipulated by inode?

前端 未结 5 1352
Happy的楠姐
Happy的楠姐 2020-12-09 08:34

Why is it that you cannot access a file when you only know its inode, without searching for a file that links to that inode? A hard link to the file contains nothing but a n

5条回答
  •  遥遥无期
    2020-12-09 09:37

    Surely if you've already looked up a file via a path, you shouldn't have to do it again and again?

    stat(f,&s); i=open(f,O_MODE);
    

    involves two trawls through a directory structure. This wastes CPU cycles with unnecessary string operations. Yes, the well designed fs cache will hind most of this inefficiency from a casual end-user, but repeating work for no reason is ugly if not plain silly.

提交回复
热议问题