Linuxでディスク上にあるファイルにI/Oを行いたいときはどうしたらいいだろうか。例えばC言語であればfopenでファイルを開いて、freadやfwriteを呼び出せばいい。なんて簡単なんだ。よかったよかった。
ではfreadやfwriteの裏側では何が起きているのだろうか。
Linuxのファイルへの書き込みは、大まかには下記のような流れで行われる。
| { | |
| "Version": 0, | |
| "Subject": "82b3f010-0a27-558d-8156-86fd5e38e370", | |
| "Matches": [ | |
| { | |
| "MatchID": "b82b8081-a7dc-4546-88f2-6bf029f56ea4", | |
| "MapID": "/Game/Maps/Ascent/Ascent", | |
| "SeasonID": "52e9749a-429b-7060-99fe-4595426a0cf7", | |
| "MatchStartTime": 1622563016671, | |
| "TierAfterUpdate": 11, |
| { | |
| "Version": 0, | |
| "Subject": "1e98d5ed-2c63-5573-a564-110ddef7853f", | |
| "Matches": [ | |
| { | |
| "MatchID": "de97a5cc-71d8-4eee-996d-e3033aa1570b", | |
| "MapID": "/Game/Maps/Duality/Duality", | |
| "SeasonID": "52e9749a-429b-7060-99fe-4595426a0cf7", | |
| "MatchStartTime": 1622640608267, | |
| "TierAfterUpdate": 8, |
| { | |
| "actId": "52e9749a-429b-7060-99fe-4595426a0cf7", | |
| "players": [ | |
| { | |
| "puuid": "g9cZTfOfUVyWUBSYakyi3-tPkAhB57H-JAPtWH5efZRPke0QGUl2c9zif4vdL1YhVuztrQgG8EWSOw", | |
| "gameName": "GXR Georggyyy", | |
| "tagLine": "Cute", | |
| "leaderboardRank": 1, | |
| "rankedRating": 913, | |
| "numberOfWins": 69, |
| { | |
| "version": "release-02.09", | |
| "characters": [ | |
| { | |
| "name": "ブリーチ", | |
| "id": "5F8D3A7F-467B-97F3-062C-13ACF203C006", | |
| "assetName": "Default__Breach_PrimaryAsset_C" | |
| }, | |
| { | |
| "name": "レイズ", |
| package main | |
| type User struct { | |
| AccessToken string `json:"access_token"` | |
| ClientPlatform struct { | |
| PlatformChipset string `json:"platformChipset"` | |
| PlatformOS string `json:"platformOS"` | |
| PlatformOSVersion string `json:"platformOSVersion"` | |
| PlatformType string `json:"platformType"` | |
| } `json:"client_platform"` |
| source ~/.zplug/init.zsh | |
| zplug 'zplug/zplug', hook-build:'zplug --self-manage' | |
| zplug "mafredri/zsh-async" | |
| # Theme | |
| zplug "sindresorhus/pure" | |
| # Utils | |
| zplug "zsh-users/zsh-history-substring-search" |
| def is_valid(s): | |
| stack = [] | |
| for c in s: | |
| if c == '(' or c == '[': | |
| stack.append(c) | |
| elif c == ')': | |
| if not stack or stack[-1] != '(': | |
| return False | |
| stack.pop() |
| source ~/.zplug/init.zsh | |
| zplug 'zplug/zplug', hook-build:'zplug --self-manage' | |
| zplug "mafredri/zsh-async" | |
| # Theme | |
| zplug "sindresorhus/pure" | |
| # Utils | |
| zplug "zsh-users/zsh-history-substring-search" |
| if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING)) | |
| { | |
| count = f->_IO_buf_end - f->_IO_write_ptr; | |
| if (count >= n) | |
| { | |
| const char *p; | |
| for (p = s + n; p > s; ) | |
| { | |
| if (*--p == '\n') | |
| { |