Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

384
Vistas
If .. is a hard link, and hard links are indistinguishable from each other, how can chdir(..) go up a directory?

If a process has /var as its cwd, and makes the syscall chdir("..") how does the cwd becomes / and not /var/.. ? I tried reading linux's source but there are to many macros for me to understand what's happening...

Edit: I know that / and /var/.. both point to the same inode, but there are different directory entries stored in different directories, with different names. My question is: how does the linux kernel decides that ("/", 2) -> ("var", 11) -> ("..", 2) should become ("/", 2) ?

(With dirents written as (name, inode))

Context: I'm currently writing the vfs of my kernel, and I don't know what is the "cleanest" solution. My current solution is to check, each time I'm accessing a child dirent, if it has the same pointer to in-memory inode as its parent.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

In unix, the kernel keeps track of both the current and the root directories of all processes. They are just inode references, either in an actual filesystem or in memory.

The chdir system call just walks the path argument, starting either from the process' root directory if it starts with / or from the process' current directory as the current inode.

In the case of .., if the current inode is the process' root directory, the inode associated with .. will not change (hence a chrooted process cannot escape out of its subtree), otherwise the inode associated with the entry (the parent directory) becomes the current inode.

When it gets to the final component or the path, the kernel makes the final inode the current directory of the process.

If the process' current directory was removed from the filesystem, it is lingering as a RAM only directory and its . and .. entries have the same inode.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda