# 系統程式設計 - `ioctl(2)`
[TOC]
## 課程影片
### 系統程式設計 2018 W4 - 1
{%youtube qzGI69UoH4A %}
## 冷知識
### `ioctl` 出現的地方
順帶一提,如果想知道 `ioctl()` 真的用在哪邊的話,從控制 GPIO 到 I2C、SPI 傳輸 都可以。可以參考 2018 年 ELCE 的 *How to Avoid Writing Device Drivers for Embedded Linux* 演講:
{%youtube QIO2pJqMxjE %}
### 「...乾脆放棄 Everything is a file,直接開始 `ioctl`」
Benno Rice 在 LCA2020 的 [*What UNIX Cost Us*](https://youtu.be/9-IWMbJXoLM) 演講,裡面有一段揶揄這個 Unix 的 *Everything is a file* 哲學只是把「不像檔案檔案操作的操作推卸給 `ioctl()`」(07:37 的部分)(但是要從頭開始看才好笑)(反正才 7 分鐘):
> *... at that point, developer of this gave up on everything being a file, and just make you write down a big long structure and `ioctl()` it.*