Prof. O livro de Remzi Arpaci-Dusseau Sistemas operacionais: três peças fáceis tem um aparte sobre a criação de arquivos:
As an example, think about what data structures must be updated when a file is created; assume, for this example, that the user creates a new file
/foo/bar.txt
and that the file is one block long (4KB). The file is new, and thus needs a new inode; thus, both the inode bitmap and the newly allocated inode will be written to disk. The file also has data in it and thus it too must be allocated; the data bitmap and a data block will thus (eventually) be written to disk. Hence, at least four writes to the current cylinder group will take place (recall that these writes may be buffered in memory for a while before they take place). But this is not all! In particular, when creating a new file, you must also place the file in the file-system hierarchy, i.e., the directory must be updated. Specifically, the parent directory foo must be updated to add the entry forbar.txt
; this update may fit in an existing data block offoo
or require a new block to be allocated (with associated data bitmap). The inode offoo
must also be updated, both to reflect the new length of the directory as well as to update time fields (such as last-modified-time). Overall, it is a lot of work just to create a new file! Perhaps next time you do so, you should be more thankful, or at least surprised that it all works so well.
Comparando os dois, especulo que os autores incluíram a atualização do bloco de dados com acesso ao atributo de arquivo (mesmo que explicitamente digam que o que eles querem dizer com atributos de arquivo é o "inode", não parece razoável considerar a localização dos dados como um atributo de arquivo). De qualquer forma, parece que eles subestimaram os acessos ao disco: precisa de pelo menos 6 da descrição do Prof. Arpaci-Dusseau:
- bitmap de inode
- inode
- bitmap de dados
- dados do arquivo
- dados do diretório
- atributos de diretório