# Why R's check_permissions uses (mode & "400") \< as.octmode("400")

Original title: You probably don't care about Unix File Mode and octmode bitwise comparison

> Hacker News story 50753784 · language: en · submitted 2026-12-03
> Web version: https://zeli.app/story/50753784
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 4 · by [sebg](<https://news.ycombinator.com/user?id=sebg>) · 💬 0
[original](<https://delicate-pegasus-aac583.netlify.app/posts/octmode.html>) · [HN discussion](<https://news.ycombinator.com/item?id=50753784>)

## Summary

Colin Fay digs into a cryptic line in R's source code that checks Unix file permissions. He explains octal notation, why read/write/execute map to 4/2/1, and how bitwise AND isolates the owner-read bit. The trick catches files with insufficient permissions even when special bits like the sticky bit inflate the numeric mode, something a simple comparison would miss.

## Key quote

> So basically `(mode & "400")` is a way to do some triage, so that every perm below 400 will be converted to 0, and the others to 400.

---

## Cite

- Page: https://zeli.app/story/50753784
- Date: 2026-12-03
- Source: delicate-pegasus-aac583.netlify.app (https://delicate-pegasus-aac583.netlify.app/posts/octmode.html)
- Hacker News: https://news.ycombinator.com/item?id=50753784

## Other languages

- ja: https://zeli.app/ja/story/50753784 · markdown: https://zeli.app/ja/story/50753784.md
- ko: https://zeli.app/ko/story/50753784 · markdown: https://zeli.app/ko/story/50753784.md
- de: https://zeli.app/de/story/50753784 · markdown: https://zeli.app/de/story/50753784.md
- es: https://zeli.app/es/story/50753784 · markdown: https://zeli.app/es/story/50753784.md
- ru: https://zeli.app/ru/story/50753784 · markdown: https://zeli.app/ru/story/50753784.md
