粘滞位对文件有什么作用?(FreeBSD)
What does the sticky bit do on files?(FreeBSD)
我知道目录上的粘滞位只允许粘滞目录中包含的文件的所有者删除文件。
但我也可以 chmod 1777
一个文件,ls -l
cmd 显示该文件确实设置了粘滞位。
没有。
A special file mode, called the sticky bit (mode S_ISTXT), is used to
indicate special treatment for directories. It is ignored for regular
files. See chmod(2) or the file for an explanation of file
modes.
Erik Bennett 链接了粘滞位的 Wikipedia article on the history - 其最初目的是提示内核尝试保持文件热交换,以提高性能。不过,现代操作系统已放弃此功能。
When set, it instructed the operating system to retain the text segment of the program in swap space after the process exited. This speeds up subsequent executions by allowing the kernel to make a single operation of moving the program from swap to real memory.
One notable problem with "stickied" programs was replacing the executable (for instance, during patching); to do so required removing the sticky bit from the executable, executing the program and exiting to flush the cache, replacing the binary executable, and then restoring the sticky bit.
Currently, this behavior is only operative in HP-UX and UnixWare. Solaris appears to have abandoned this in 2005. The 4.4-Lite release of BSD retained the old sticky bit behavior, but it has been subsequently dropped from OpenBSD (as of release 3.7) and FreeBSD (as of release 2.2.1). No version of Linux has ever supported this traditional behavior.
我知道目录上的粘滞位只允许粘滞目录中包含的文件的所有者删除文件。
但我也可以 chmod 1777
一个文件,ls -l
cmd 显示该文件确实设置了粘滞位。
没有。
A special file mode, called the sticky bit (mode S_ISTXT), is used to indicate special treatment for directories. It is ignored for regular files. See chmod(2) or the file for an explanation of file modes.
Erik Bennett 链接了粘滞位的 Wikipedia article on the history - 其最初目的是提示内核尝试保持文件热交换,以提高性能。不过,现代操作系统已放弃此功能。
When set, it instructed the operating system to retain the text segment of the program in swap space after the process exited. This speeds up subsequent executions by allowing the kernel to make a single operation of moving the program from swap to real memory.
One notable problem with "stickied" programs was replacing the executable (for instance, during patching); to do so required removing the sticky bit from the executable, executing the program and exiting to flush the cache, replacing the binary executable, and then restoring the sticky bit.
Currently, this behavior is only operative in HP-UX and UnixWare. Solaris appears to have abandoned this in 2005. The 4.4-Lite release of BSD retained the old sticky bit behavior, but it has been subsequently dropped from OpenBSD (as of release 3.7) and FreeBSD (as of release 2.2.1). No version of Linux has ever supported this traditional behavior.