UNDELETE(2)

✨ UNDELETE(2) ✨

okay bestie, welcome to the System Calls Manual πŸ’– this is undelete, a 2nd-section system call, and honestly? she's a niche queen. let's get into it 🫢


🌸 NAME 🌸

undelete β€” the whole mission is: attempt to recover a deleted file πŸ¦‹


πŸŽ€ LIBRARY πŸŽ€

Standard C Library (libc, -lc) β€” yeah she lives in libc, no cap πŸ’…


✨ SYNOPSIS ✨

#include <unistd.h>

int
undelete(const char *path);

look at her. one path. one int. so clean. so demure. 🧚


πŸ’œ DESCRIPTION πŸ’œ

so the undelete() system call attempts to recover the deleted file named by path. πŸ’–

and here's the tea, bestie: currently, this only works when the named object is a whiteout in a union file system. what happens is the system call removes that whiteout, which makes any objects in a lower layer of the union stack become visible once more. πŸ‘‘ like... the file was hiding behind a lil "nothing to see here" sign and you just yanked the sign away. iconic.

eventually, the undelete() functionality may be expanded to other file systems that are able to recover deleted files β€” for example the log-structured file system. πŸ‘€ so watch this space, but for rn? whiteouts only. periodt.


🌈 RETURN VALUES 🌈

  • if it works: undelete() returns the value 0. slay. πŸŽ‰
  • if it doesn't: the value -1 is returned, and the global variable errno gets set to indicate the error. 😭

πŸ”₯ ERRORS πŸ”₯

the undelete() call succeeds unless one of these lil guys happens:

  • [ENOTDIR] β€” a component of the path prefix is not a directory. πŸ’€
  • [ENAMETOOLONG] β€” a component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. bestie that's a lot of letters, pls chill 😭
  • [EEXIST] β€” the path does not reference a whiteout. (rude, but okay)
  • [ENOENT] β€” the named whiteout does not exist. πŸ™ˆ
  • [EACCES] β€” search permission is denied for a component of the path prefix.
  • [EACCES] β€” write permission is denied on the directory containing the name to be undeleted.
  • [ELOOP] β€” too many symbolic links were encountered in translating the pathname. πŸŒ€
  • [EPERM] β€” the directory containing the name is marked sticky, and the containing directory is not owned by the effective user ID. not your directory, not your business 🚫
  • [EINVAL] β€” the last component of the path is '..'. no going up, ma'am πŸ›‘
  • [EIO] β€” an I/O error occurred while updating the directory entry.
  • [EINTEGRITY] β€” corrupted data was detected while reading from the file system. πŸ’€πŸ’€
  • [EROFS] β€” the name resides on a read-only file system. frozen. can't touch. ❄️
  • [EFAULT] β€” the path argument points outside the process's allocated address space. that pointer is literally in the void, bestie 🌌

πŸ¦‹ SEE ALSO πŸ¦‹

go read those, iykyk πŸ“š


⭐ HISTORY ⭐

the undelete() system call first appeared in 4.4BSD-Lite. a true vintage icon πŸ•°οΈβœ¨


okay that's the whole page, mwah πŸ’‹ this one came from Debian, dated March 30, 2020, and it's filed under UNDELETE(2). go recover something (a whiteout, specifically, because that's literally the only thing this does rn) πŸ«ΆπŸ’–πŸŽ€

πŸ“¦ where this page comes from