REVOKE(2)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’… REVOKE(2) β€” revoke file access

okay bestie, welcome to revoke(2), from the System Calls Manual (section 2, we're in syscall territory now πŸ‘‘). This is the page where you learn how to yank somebody's access to a file out from under them, and honestly? it's giving main character energy. Let's get into it. πŸ¦‹


🌈 LIBRARY

Standard C Library (libc, -lc). yeah. the classics. πŸ’–

✨ SYNOPSIS

#include <unistd.h>

int
revoke(const char *path);

πŸŽ€ DESCRIPTION

so the revoke() system call invalidates all current open file descriptors in the system for the file named by path. all of them. everywhere. not just yours. πŸ’€

After that, any subsequent operations on any of those descriptors just… fail. except β€” and this is the cute part β€” a read() from a character device file that's been revoked returns a count of zero (that's end-of-file, bestie 🌸), and a close() system call will still succeed. Also: if the file is a special file for a device which is open, the device close function gets called as if all open references to the file had been closed, using a special close method which does not block. noted. 🫢

Now the important bits, no cap:

  • Access to a file may be revoked only by its owner or the super user. everybody else, get out of the group chat. πŸ™ˆ
  • revoke() is currently supported only for character special device files.
  • It's normally used to prepare a terminal device for a new login session, preventing any access by a previous user of the terminal. like wiping the whiteboard before the next person walks in. iconic. ✨

⭐ RETURN VALUES

The revoke() function returns the value 0 if successful. otherwise it returns -1, and the global variable errno is set to indicate the error. standard king behavior. πŸ‘‘

πŸ”₯ ERRORS

Access to the named file is revoked unless one of the following happens β€” in which case, nope, no revoking today:

  • [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 1024 characters. (girl, shorten it 😭)
  • [ENOENT] β€” The named file or a component of the path name does not exist.
  • [EACCES] β€” Search permission is denied for a component of the path prefix.
  • [ELOOP] β€” Too many symbolic links were encountered in translating the pathname.
  • [EFAULT] β€” The path argument points outside the process's allocated address space.
  • [EINVAL] β€” The implementation does not support the revoke() operation on the named file.
  • [EPERM] β€” The caller is neither the owner of the file nor the super user. 🚫

πŸ¦‹ SEE ALSO

revoke(1), close(2) β€” go read those too, iykyk πŸ’œ

🌸 HISTORY

The revoke() system call first appeared in 4.3BSD-Reno. vintage. we love a legend with lore. πŸŽ€

πŸ’€ BUGS

The non-blocking close method is only correctly implemented for terminal devices. so like… mind the gap, bestie. ⚠️


fr fr, this is a destructive one β€” you're torching every open fd for that file system-wide. read the ERRORS list twice before you ship. πŸ”₯

that's the whole page, mwah πŸ’‹ β€” this Debian build is dated October 24, 2025, so go forth and revoke responsibly, queen πŸ‘‘βœ¨

πŸ“¦ where this page comes from
  • freebsd 15.1: base 15.1
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms