{"id":1535,"date":"2024-11-30T18:30:06","date_gmt":"2024-11-30T09:30:06","guid":{"rendered":"https:\/\/www.yanagichiaki.jp\/?p=1535"},"modified":"2024-12-24T16:40:02","modified_gmt":"2024-12-24T07:40:02","slug":"simplified-ext2-on-fuse","status":"publish","type":"post","link":"https:\/\/yanagichiaki.jp\/index.php\/2024\/11\/30\/simplified-ext2-on-fuse\/","title":{"rendered":"Simplified EXT2 On FUSE"},"content":{"rendered":"\n<p class=\"is-style-big_icon_point\">\u30cf\u30eb\u30d3\u30f3\u5de5\u696d\u5927\u5b66\uff08\u6df1\u5733\uff09\u2022 2024 \u2022 \u30aa\u30da\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u30b7\u30b9\u30c6\u30e0 Lab \u2022 \u306b\u304a\u3051\u308b\u89e3\u6c7a\u7b56 \u2022 HITSZ \u64cd\u4f5c\u7cfb\u7edf\u5b9e\u9a8c 2024 \u57fa\u4e8eFUSE\u7684\u9752\u6625\u7248EXT2\u6587\u4ef6\u7cfb\u7edf<\/p>\n\n\n\n<p class=\"is-style-icon_info\">\u5fa1\u8cea\u554f\u304c\u5fa1\u5ea7\u3044\u307e\u3057\u305f\u3089\u3001\u3053\u306e\u30da\u30fc\u30b8\u306e\u4e0b\u90e8\u306b\u3042\u308b\u30b3\u30e1\u30f3\u30c8\u6b04\u3092\u5fa1\u5229\u7528\u304f\u3060\u3055\u3044\u3002<br><span class=\"swl-marker mark_yellow\">\u4ef0\u305b\u4e8b\u6709\u4e4b\u5019\u30cf\u30cf<\/span>\u3001<span class=\"swl-marker mark_blue\">\u6b64\u4e01\u4e4b\u4e0b\u30cb\u30a2\u30eb\u610f\u898b\u4e4b\u6b04\u30f2\u7528\u30f0\u7d66\u30d8<\/span>\u3002<\/p>\n\n\n\n<p class=\"is-style-big_icon_hatena\">\u3053\u306e\u90e8\u5206\u306f\u3001<a href=\"https:\/\/www.yanagichiaki.jp\/index.php\/2024\/11\/17\/xv6-oslab24-hitsz-answers\/\">xv6-oslab24-hitsz-answers<\/a>\u304b\u3089\u5206\u96e2\u3055\u308c\u305fLab 5\u3002<br>Lab 1 ~ 4\u3092\u898b\u305f\u3044\u65b9\u306f\u4e0b\u306e\u30dc\u30bf\u30f3\u3092\u62bc\u3057\u3066\u4e0b\u3055\u3044\u3002<\/p>\n\n\n\n<div class=\"swell-block-button blue_ is-style-btn_solid\"><a href=\"https:\/\/www.yanagichiaki.jp\/index.php\/2024\/11\/17\/xv6-oslab24-hitsz-answers\/\" class=\"swell-block-button__link\" data-has-icon=\"1\"><svg class=\"__icon\" height=\"1em\" width=\"1em\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" aria-hidden=\"true\" viewBox=\"0 0 48 48\"><path d=\"M24 45C12.4 45 3 35.6 3 24S12.4 3 24 3s21 9.4 21 21-9.4 21-21 21zm0-39C14.1 6 6 14.1 6 24s8.1 18 18 18 18-8.1 18-18S33.9 6 24 6z\"><\/path><path d=\"m34.3 22.9-8.8-8.8c-.6-.6-1.5-.6-2.1 0s-.6 1.5 0 2.1l6.3 6.3H14.8c-.8 0-1.5.7-1.5 1.5s.7 1.5 1.5 1.5h14.8l-6.3 6.3c-.6.6-.6 1.5 0 2.1s1.5.6 2.1 0l8.8-8.8c.7-.6.7-1.6.1-2.2z\"><\/path><\/svg><span>Lab 1~4 <\/span><\/a><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u521d\u671f\u74b0\u5883\u8a2d\u5b9a\u306b\u3064\u3044\u3066<\/h2>\n\n\n\n<p>\u6700\u521d\u306f\u3001\u6b21\u306e\u547d\u4ee4\u3092\u5165\u529b\u3057\u3066\u4e0b\u3055\u3044<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>bash\ncd ~\ngit clone https:\/\/gitee.com\/ftutorials\/user-land-filesystem.git\ncd user-land-filesystem\nchmod +x .\/setenv.sh\nchmod +x .\/driver\/ddriver.sh\n.\/setenv.sh\n#&#91;\u6307\u793a\u3092\u5f93\u3063\u3066\u3001\u74b0\u5883\u3092\u914d\u7f6e]\nsource ~\/.bashrc\nddriver\n#&#91;ddriver interface\u304c\u51fa\u305f]<\/code><\/pre>\n\n\n\n<p>\u305d\u306e\u3042\u3068\u3001demo\u306e<code>main.c<\/code>\u3092\u88dc\u5b8c\u3002demo\u3067\u6b21\u306e\u3082\u306e\u3092\u5165\u529b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir build\ncmake -B . -S ..\ncd build<\/code><\/pre>\n\n\n\n<p>\u3053\u306e\u6642\u3001executable\u30d5\u30a1\u30a4\u30eb(<code>demo<\/code>)\u304c\u51fa\u306a\u3044\u5834\u5408\u306f<code>make<\/code>\u3092\u5b9f\u884c\u3067\u30b3\u30fc\u30c9\u306e\u30a8\u30e9\u30fc\u3092\u4e00\u3064\u305a\u3064\u8a02\u6b63\u3067\u3044\u3044\u3002<\/p>\n\n\n\n<p>chiakiFS\u3082\u540c\u69d8\u3001executable\u30d5\u30a1\u30a4\u30eb(<code>chiakiFS<\/code>)\u304c\u51fa\u306a\u3044\u5834\u5408\u306f<code>make<\/code>\u3092\u5b9f\u884c\u3067\u30b3\u30fc\u30c9\u306e\u30a8\u30e9\u30fc\u3092\u4e00\u3064\u305a\u3064\u8a02\u6b63\u3067\u3044\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">A Demo File System driven by ddriver<\/h2>\n\n\n<div class=\"swell-block-balloon\"><div class=\"c-balloon -bln-left\" data-col=\"green\"><div class=\"c-balloon__body -thinking -border-on\"><div class=\"c-balloon__text\">\n<p><strong><span class=\"swl-fz u-fz-xl\">ddriver\u306e\u7d39\u4ecb<\/span><\/strong><\/p>\n<span class=\"c-balloon__shapes\"><span class=\"c-balloon__before\"><\/span><span class=\"c-balloon__after\"><\/span><\/span><\/div><\/div><\/div><\/div>\n\n\n<figure class=\"wp-block-table is-all-centered--va\"><table><thead style=\"--thead-color--bg:var(--color_deep01);--thead-color--txt:var(--swl-text_color--white)\"><tr><th>Interface Function<\/th><th>Description<\/th><\/tr><\/thead><tbody><tr><td>int <strong>ddriver_open<\/strong><br>(char* path)<\/td><td>\u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9 <code>path<\/code> \u306b\u57fa\u3065\u3044\u3066\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u3092\u958b\u304d\u3001\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf <code>fd<\/code> \u3092\u8fd4\u3057\u307e\u3059\u3002<code>path<\/code> \u306f\u56fa\u5b9a\u3067 <code>~\/ddriver<\/code> \u306e\u7d76\u5bfe\u30d1\u30b9\u3092\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/td><\/tr><tr><td>int <strong>ddriver_close<\/strong><br>(int fd)<\/td><td>\u958b\u304b\u308c\u305f\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u3092\u9589\u3058\u307e\u3059\u3002<\/td><\/tr><tr><td>int <strong>ddriver_seek<\/strong><br>(int fd, off_t offset, int whence)<\/td><td>\u57fa\u6e96\u3068\u306a\u308b <code>whence<\/code> \u3068\u30aa\u30d5\u30bb\u30c3\u30c8 <code>offset<\/code> \u306b\u57fa\u3065\u3044\u3066\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u306e\u30c7\u30a3\u30b9\u30af\u30d8\u30c3\u30c9\u3092\u79fb\u52d5\u3057\u307e\u3059\u3002<code>whence<\/code> \u306e\u57fa\u6e96\u306f\u901a\u5e38 <code>SEEK_SET<\/code>\uff08\u3064\u307e\u308a 0\uff09\u306b\u56fa\u5b9a\u3055\u308c\u3001\u30aa\u30d5\u30bb\u30c3\u30c8 <code>offset<\/code> \u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/td><\/tr><tr><td>int <strong>ddriver_read<\/strong><br>(int fd, char* buf, size_t size)<\/td><td>I\/O \u30b5\u30a4\u30ba\u306b\u5f93\u3063\u3066\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u304b\u3089\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<code>size<\/code> \u306f I\/O \u30b5\u30a4\u30ba\u306b\u56fa\u5b9a\u3057\u3066\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3002<\/td><\/tr><tr><td>int <strong>ddriver_write<\/strong><br>(int fd, char* buf, size_t size)<\/td><td>I\/O \u30b5\u30a4\u30ba\u306b\u5f93\u3063\u3066\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u306b\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002<code>size<\/code> \u306f I\/O \u30b5\u30a4\u30ba\u306b\u56fa\u5b9a\u3057\u3066\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u3002<\/td><\/tr><tr><td>int <strong>ddriver_ioctl<\/strong><br>(int fd, unsigned long cmd, void* ret)<\/td><td>\u6307\u5b9a\u3055\u308c\u305f\u30b3\u30de\u30f3\u30c9 <code>cmd<\/code> \u306b\u57fa\u3065\u3044\u3066\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u306e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<br><code>cmd<\/code> \u304c <code>IOC_REQ_DEVICE_SIZE<\/code> \u306e\u5834\u5408\u3001<code>void *ret<\/code> \u306b\u306f\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u306e\u7dcf\u30b5\u30a4\u30ba\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<br><code>cmd<\/code> \u304c <code>IOC_REQ_DEVICE_IO_SZ<\/code> \u306e\u5834\u5408\u3001<code>void *ret<\/code> \u306b\u306f\u4eee\u60f3\u30c7\u30a3\u30b9\u30af\u306e I\/O \u30b5\u30a4\u30ba\u304c\u8fd4\u3055\u308c\u307e\u3059\u3002<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">1. \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u8a2d\u5b9a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>int     sz_io;      \/* \u30c7\u30a3\u30b9\u30afIO\u30b5\u30a4\u30ba\uff08\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09 *\/\nint     sz_disk;    \/* \u30c7\u30a3\u30b9\u30af\u5bb9\u91cf\uff08\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09 *\/\nint     sz_blks;    \/* \u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\uff08\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09 *\/<\/code><\/pre>\n\n\n\n<p>\u307e\u305a\u306f\u3001\u3053\u306e\uff13\u3064\u306e\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8a2d\u5b9a\u3002<\/p>\n\n\n\n<p>\u3053\u306e\u90e8\u5206\u306e\u30b3\u30fc\u30c9\u306f\u3001<code>super<\/code> \u69cb\u9020\u4f53\u306b\u5fc5\u8981\u306a\u60c5\u5831\u3092\u8a2d\u5b9a\u3057\u3066\u3001\u30b7\u30df\u30e5\u30ec\u30fc\u30b7\u30e7\u30f3\u3055\u308c\u305f\u30c7\u30a3\u30b9\u30af\u306e\u8a73\u7d30\uff08IO\u30b5\u30a4\u30ba\u3001\u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\u3001\u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\uff09\u3092\u53d6\u5f97\u3059\u308b\u51e6\u7406\u3067\u3059\u3002\u305d\u308c\u305e\u308c\u306e\u884c\u3092\u8a73\u7d30\u306b\u8aac\u660e\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ddriver_ioctl(super.driver_fd, IOC_REQ_DEVICE_IO_SZ, &amp;super.sz_io);\nddriver_ioctl(super.driver_fd, IOC_REQ_DEVICE_SIZE, &amp;super.sz_disk);\nsuper.sz_blks = 2 * super.sz_io;<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>ddriver_ioctl<\/code> \u306f\u3001\u30c7\u30d0\u30a4\u30b9\u30c9\u30e9\u30a4\u30d0\u306b\u5bfe\u3057\u3066\u7279\u5b9a\u306e\u5236\u5fa1\u64cd\u4f5c\u3092\u884c\u3046\u305f\u3081\u306e\u95a2\u6570\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>IOC_REQ_DEVICE_IO_SZ<\/code> \u306f\u300c\u30c7\u30d0\u30a4\u30b9\u306e I\/O \u30b5\u30a4\u30ba\u3092\u8981\u6c42\u3059\u308b\u300d\u3068\u3044\u3046\u64cd\u4f5c\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>super.driver_fd<\/code> \u306f\u30c7\u30d0\u30a4\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf\u3067\u3001\u3069\u306e\u30c7\u30d0\u30a4\u30b9\u306b\u5bfe\u3057\u3066\u64cd\u4f5c\u3092\u884c\u3046\u304b\u3092\u793a\u3057\u307e\u3059\u3002<\/li>\n\n\n\n<li><code>&amp;super.sz_io<\/code> \u306f\u3001\u53d6\u5f97\u3057\u305f I\/O \u30b5\u30a4\u30ba\uff081\u56de\u306e\u30c7\u30fc\u30bf\u8ee2\u9001\u306e\u5358\u4f4d\u30b5\u30a4\u30ba\uff09\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306e\u30dd\u30a4\u30f3\u30bf\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>IOC_REQ_DEVICE_SIZE<\/code> \u306f\u300c\u30c7\u30d0\u30a4\u30b9\u306e\u7dcf\u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\u3092\u8981\u6c42\u3059\u308b\u300d\u3068\u3044\u3046\u64cd\u4f5c\u30b3\u30fc\u30c9\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>&amp;super.sz_disk<\/code> \u306f\u3001\u53d6\u5f97\u3057\u305f\u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\uff08\u7dcf\u5bb9\u91cf\u3001\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306e\u30dd\u30a4\u30f3\u30bf\u3067\u3059\u3002<\/li>\n\n\n\n<li><code>super.sz_blks<\/code>\u306f\u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u306e\u30b5\u30a4\u30ba\u3002<\/li>\n\n\n\n<li>\u3053\u306e\u90e8\u5206\u3067\u306f\u30011\u30d6\u30ed\u30c3\u30af\u304c I\/O \u30b5\u30a4\u30ba\u306e2\u500d\u3067\u3042\u308b\u3068\u4eee\u5b9a\u3057\u3066\u3044\u307e\u3059\u3002\u5f93\u3063\u3066\u3001<code>super.sz_io<\/code> \u30922\u500d\u3057\u305f\u5024\u3092 <code>super.sz_blks<\/code> \u306b\u4ee3\u5165\u3057\u3066\u3044\u307e\u3059\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. \u7279\u5b9a\u306a\u30c7\u30a3\u30b9\u30af\u30aa\u30d5\u30bb\u30c3\u30c8\u3078\u79fb\u52d5<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>off_t disk_offset = 500 * super.sz_blks;\nddriver_seek(super.driver_fd, disk_offset, SEEK_SET);<\/code><\/pre>\n\n\n\n<p>\u3053\u3053\u3067\u306f\u3001\u30c7\u30a3\u30b9\u30af\u4e0a\u306e500\u756a\u76ee\u306e\u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8a08\u7b97\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u30d6\u30ed\u30c3\u30af\u306e\u30b5\u30a4\u30ba\u306f <code>super.sz_blks<\/code>\u3067\u3059\u306e\u3067\u3001500\u756a\u76ee\u306e\u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u306f <code>500 * super.sz_blks<\/code> \u306b\u306a\u308a\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001<code>ddriver_seek<\/code> \u3092\u4f7f\u3063\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf <code>super.driver_fd<\/code> \u306e\u4f4d\u7f6e\u3092\u305d\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u306b\u79fb\u52d5\u3057\u307e\u3059\u3002<code>SEEK_SET<\/code> \u306f\u30d5\u30a1\u30a4\u30eb\u306e\u5148\u982d\u304b\u3089\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u6307\u5b9a\u3059\u308b\u610f\u5473\u3067\u3059\u3002<\/p>\n\n\n\n<p>3. \u30c7\u30a3\u30b9\u30af\u30d6\u30ed\u30c3\u30af\u3092\u8aad\u8fbc<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. \u30c7\u30a3\u30b9\u30af\u30d6\u30ed\u30c3\u30af\u3092\u8aad\u307f\u53d6\u308b<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>char block&#91;super.sz_io];\nddriver_read(super.driver_fd, block, super.sz_io);<\/code><\/pre>\n\n\n\n<p><code>ddriver_read<\/code> \u306f\u3001\u6307\u5b9a\u3057\u305f\u30b5\u30a4\u30ba\u306e\u30c7\u30fc\u30bf\u3092\u30c7\u30a3\u30b9\u30af\u304b\u3089\u8aad\u307f\u53d6\u308b\u305f\u3081\u306b\u4f7f\u7528\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001<code>block<\/code> \u3068\u3044\u3046\u30d0\u30c3\u30d5\u30a1\u306b\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u6e96\u5099\u3092\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30d0\u30c3\u30d5\u30a1\u306e\u30b5\u30a4\u30ba\u306f\u3001\u30c7\u30a3\u30b9\u30af\u306e I\/O \u30b5\u30a4\u30ba <code>super.sz_io<\/code> \u306b\u57fa\u3065\u3044\u3066\u3044\u307e\u3059\u3002<code>ddriver_read<\/code> \u306f\u3001<code>super.driver_fd<\/code> \u304b\u3089 <code>super.sz_io<\/code> \u30d0\u30a4\u30c8\u3092\u8aad\u307f\u53d6\u308a\u3001\u305d\u306e\u5185\u5bb9\u3092 <code>block<\/code> \u914d\u5217\u306b\u683c\u7d0d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. \u5148\u306e\u30d6\u30ed\u30c3\u30af\u304b\u3089<code>demo_dentry<\/code>\u3092\u53d6\u5f97<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>struct demo_dentry entry;\nmemcpy(&amp;entry, block, sizeof(struct demo_dentry));<\/code><\/pre>\n\n\n\n<p>\u3053\u3053\u3067\u306f\u3001\u8aad\u307f\u53d6\u3063\u305f\u30c7\u30a3\u30b9\u30af\u30d6\u30ed\u30c3\u30af\u306e\u30c7\u30fc\u30bf\u3092 <code>demo_dentry<\/code> \u69cb\u9020\u4f53\u306b\u30b3\u30d4\u30fc\u3057\u3066\u3044\u307e\u3059\u3002\u5177\u4f53\u7684\u306b\u306f\u3001<code>block<\/code> \u306e\u5148\u982d\u304b\u3089 <code>sizeof(struct demo_dentry)<\/code> \u30d0\u30a4\u30c8\u3092 <code>entry<\/code> \u3068\u3044\u3046\u69cb\u9020\u4f53\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<code>demo_dentry<\/code> \u306f\u30d5\u30a1\u30a4\u30eb\u540d\uff08<code>fname<\/code>\uff09\u3092\u683c\u7d0d\u3059\u308b\u69cb\u9020\u4f53\u3067\u3001\u3053\u308c\u3092\u4f7f\u3063\u3066\u30c7\u30a3\u30b9\u30af\u30d6\u30ed\u30c3\u30af\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u540d\u306a\u3069\u306e\u60c5\u5831\u3092\u62bd\u51fa\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u30d5\u30a1\u30a4\u30eb\u540d<strong>\u3092\u8a2d\u5b9a\u3059\u308b<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>strncpy(filename, entry.fname, sizeof(filename) - 1);\nfilename&#91;sizeof(filename) - 1] = '\\0';<\/code><\/pre>\n\n\n\n<p><code>entry.fname<\/code> \u306b\u306f\u3001\u30c7\u30a3\u30b9\u30af\u30d6\u30ed\u30c3\u30af\u304b\u3089\u8aad\u307f\u53d6\u3063\u305f\u30d5\u30a1\u30a4\u30eb\u540d\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092 <code>filename<\/code> \u914d\u5217\u306b\u30b3\u30d4\u30fc\u3059\u308b\u305f\u3081\u306b <code>strncpy<\/code> \u3092\u4f7f\u3044\u307e\u3059\u3002<code>sizeof(filename) - 1<\/code> \u306f\u3001\u914d\u5217\u306e\u672b\u5c3e\u306b <code>\\0<\/code> \u3092\u8ffd\u52a0\u3059\u308b\u305f\u3081\u306e\u4f59\u5730\u3092\u6b8b\u3059\u305f\u3081\u3067\u3059\u3002\u6700\u5f8c\u306b\u3001<code>filename<\/code> \u914d\u5217\u306e\u672b\u5c3e\u306b <code>\\0<\/code> \u3092\u624b\u52d5\u3067\u8ffd\u52a0\u3059\u308b\u3053\u3068\u3067\u3001\u6587\u5b57\u5217\u3068\u3057\u3066\u6b63\u3057\u304f\u7d42\u4e86\u3059\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u8868\u793a\u3059\u308b\u305f\u3081\u306e\u5c5e\u6027\u8a2d\u5b9a<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>stbuf-&gt;st_mode = DEMO_DEFAULT_PERM | S_IFREG;<\/code><\/pre>\n\n\n\n<p><code>st_mode<\/code> \u306f\u30d5\u30a1\u30a4\u30eb\u306e\u5c5e\u6027\u3092\u8868\u3059\u30d5\u30a3\u30fc\u30eb\u30c9\u3067\u3001\u30d5\u30a1\u30a4\u30eb\u306e\u30bf\u30a4\u30d7\u3068\u30a2\u30af\u30bb\u30b9\u6a29\u9650\u3092\u793a\u3057\u307e\u3059\u3002<br><code>DEMO_DEFAULT_PERM<\/code> \u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30a2\u30af\u30bb\u30b9\u6a29\u9650\uff080777:<span class=\"swl-marker mark_blue\">-rwxrwxrwx<\/span>\uff09\u3067\u3001\u8aad\u307f\u66f8\u304d\u5b9f\u884c\u6a29\u9650\u3092\u5168\u3066\u306e\u30e6\u30fc\u30b6\u306b\u4e0e\u3048\u3066\u3044\u307e\u3059\u3002<br><code>S_IFREG<\/code> \u306f\u3001\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u3092\u793a\u3059\u5b9a\u6570\u3067\u3059\u3002\u3053\u308c\u306b\u3088\u308a\u3001<code>st_mode<\/code> \u304c\u300c\u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u300d\u306e\u5c5e\u6027\u3092\u6301\u3064\u3088\u3046\u306b\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-text-color has-swl-deep-01-color has-alpha-channel-opacity has-swl-deep-01-background-color has-background is-style-wide\"\/>\n\n\n\n<p>\u3053\u306e\u90e8\u5206\u306f\u3001\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u30b3\u30fc\u30c9\u88dc\u5b8c\u3067\u3044\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">#define _XOPEN_SOURCE 700\n\n#define FUSE_USE_VERSION 26\n#include \"stdio.h\"\n#include \"fuse.h\"\n#include \"..\/include\/ddriver.h\"\n#include &lt;linux\/fs.h>\n#include \"pwd.h\"\n#include \"unistd.h\"\n#include \"string.h\"\n\n#define DEMO_DEFAULT_PERM        0777\n\n\n\/* \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af *\/\nstruct demo_super\n{\n    int     driver_fd;  \/* \u30b7\u30df\u30e5\u30ec\u30fc\u30c8\u3055\u308c\u305f\u30c7\u30a3\u30b9\u30af\u306e\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf *\/\n\n    int     sz_io;      \/* \u30c7\u30a3\u30b9\u30afIO\u30b5\u30a4\u30ba\uff08\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09 *\/\n    int     sz_disk;    \/* \u30c7\u30a3\u30b9\u30af\u5bb9\u91cf\uff08\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09 *\/\n    int     sz_blks;    \/* \u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\uff08\u5358\u4f4d\uff1a\u30d0\u30a4\u30c8\uff09 *\/\n};\n\n\/* \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea *\/\nstruct demo_dentry\n{\n    char    fname&#91;128];\n}; \n\nstruct demo_super super;\n\n#define DEVICE_NAME \"ddriver\"\n\n\/* \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30de\u30a6\u30f3\u30c8 *\/\nstatic void* demo_mount(struct fuse_conn_info * conn_info){\n    \/\/ \u30c9\u30e9\u30a4\u30d0\u3092\u958b\u304f\n    char device_path&#91;128] = {0};\n    sprintf(device_path, \"%s\/\" DEVICE_NAME, getpwuid(getuid())->pw_dir);\n    super.driver_fd = ddriver_open(device_path);\n\n    printf(\"super.driver_fd: %d\\n\", super.driver_fd);\n\n\n    \/* super\u60c5\u5831\u3092\u8a2d\u5b9a *\/\n    ddriver_ioctl(super.driver_fd, IOC_REQ_DEVICE_IO_SZ, &amp;super.sz_io); \/* TODO *\/;\n    ddriver_ioctl(super.driver_fd, IOC_REQ_DEVICE_SIZE, &amp;super.sz_disk); \/* TODO *\/;\n    super.sz_blks = 2 * super.sz_io; \/* TODO *\/; \n\n    return 0;\n}\n\n\/* \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30a2\u30f3\u30de\u30a6\u30f3\u30c8 *\/\nstatic void demo_umount(void* p){\n    \/\/ \u30c9\u30e9\u30a4\u30d0\u3092\u9589\u3058\u308b\n    ddriver_close(super.driver_fd);\n}\n\n\/* \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u8aad\u307f\u53d6\u308a *\/\nstatic int demo_readdir(const char* path, void* buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info* fi)\n{\n    \/\/ \u3053\u306e\u90e8\u5206\u3067\u306f\u3001\u5f15\u6570\u306e\u8a73\u7d30\u3092\u6c17\u306b\u305b\u305a\u3001\u305d\u3057\u3066\u4f7f\u308f\u306a\u3044\u3002demo_readdir\u5185\u3067\u8a2d\u5b9a\u3057\u305f\u30d1\u30e9\u30e1\u30fc\u30bf\u3060\u3051\u3092\u4f7f\u7528\u3057\u3066\u304f\u3060\u3055\u3044\n\n    char filename&#91;128]; \/\/ \u8a2d\u5b9a\u3059\u3079\u304d\u30d5\u30a1\u30a4\u30eb\u540d\n\n    \/* \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u60c5\u5831\u306b\u57fa\u3065\u304d\u3001500\u756a\u76ee\u306e\u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u304b\u3089dentry\u3092\u8aad\u307f\u8fbc\u3080\u3002ls\u306f\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3060\u3051\u3092\u8868\u793a\u3057\u307e\u3059 *\/\n\n    \/* TODO: \u30c7\u30a3\u30b9\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8a08\u7b97\u3057\u3001\u305d\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u306b\u57fa\u3065\u3044\u3066ddriver_seek\u3067\u30c7\u30a3\u30b9\u30af\u30d8\u30c3\u30c9\u3092\u30aa\u30d5\u30bb\u30c3\u30c8\u306b\u79fb\u52d5 *\/\n    off_t disk_offset = 500 * super.sz_blks;\n    ddriver_seek(super.driver_fd, disk_offset, SEEK_SET);\n    \/* TODO: ddriver_read\u3092\u4f7f\u3063\u3066\u30c7\u30a3\u30b9\u30af\u30d6\u30ed\u30c3\u30af\u3092\u30e1\u30e2\u30ea\u306b\u8aad\u307f\u8fbc\u3080\uff08512\u30d0\u30a4\u30c8\uff09 *\/\n    char block&#91;super.sz_io];\n    ddriver_read(super.driver_fd, block, super.sz_io);\n    \/* TODO: memcpy\u3092\u4f7f\u3063\u3066\u3001\u5148\u307b\u3069\u306e512\u30d0\u30a4\u30c8\u306e\u524dsizeof(demo_dentry)\u30d0\u30a4\u30c8\u3092demo_dentry\u69cb\u9020\u4f53\u306b\u30b3\u30d4\u30fc *\/\n    struct demo_dentry entry;\n    memcpy(&amp;entry, block, sizeof(struct demo_dentry));\n    \/* TODO: filename\u3092\u8a2d\u5b9a *\/\n    strncpy(filename, entry.fname, sizeof(filename) - 1);\n    filename&#91;sizeof(filename) - 1] = '\\0';\n    \/\/ \u3053\u306e\u90e8\u5206\u3067\u306ffiller\u3092\u6c17\u306b\u3057\u306a\u3044\u3067\u304f\u3060\u3055\u3044\u3002filler\u306f\u3059\u3067\u306b\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u3001filename\u3092\u8a2d\u5b9a\u3059\u308b\u3060\u3051\u3067OK\u3067\u3059\n    return filler(buf, filename, NULL, 0);\n}\n\n\/* \u30d5\u30a1\u30a4\u30eb\u306e\u5c5e\u6027\u3092\u8868\u793a *\/\nstatic int demo_getattr(const char* path, struct stat *stbuf)\n{\n    if(strcmp(path, \"\/\") == 0)\n        stbuf->st_mode = DEMO_DEFAULT_PERM | S_IFDIR;            \/\/ \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30d5\u30a1\u30a4\u30eb\n    else\n        \/* TODO: \u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u8868\u793a *\/\n        stbuf->st_mode = DEMO_DEFAULT_PERM | S_IFREG;            \/\/ \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u8868\u793a\n    return 0;\n}\n\n\/* \u8981\u6c42\u306b\u57fa\u3065\u304d\u3001ls\u64cd\u4f5c\u3092\u5b8c\u4e86\u3059\u308b\u305f\u3081\u306b\u306f\u6700\u521d\u306e4\u3064\u306e\u30d5\u30c3\u30af\u95a2\u6570\u3092\u5b9f\u88c5\u3059\u308b\u3060\u3051\u3067\u3088\u3044 *\/\nstatic struct fuse_operations ops = {\n\t.init = demo_mount,\t\t\t\t\t\t          \/* \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30de\u30a6\u30f3\u30c8 *\/\t\t\n\t.destroy = demo_umount,\t\t\t\t\t\t\t  \/* \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30a2\u30f3\u30de\u30a6\u30f3\u30c8 *\/\n\t.getattr = demo_getattr,\t\t\t\t\t\t  \/* \u30d5\u30a1\u30a4\u30eb\u5c5e\u6027\u306e\u53d6\u5f97 *\/\n\t.readdir = demo_readdir,\t\t\t\t\t\t  \/* dentry\u306e\u8a2d\u5b9a *\/\n};\n\nint main(int argc, char *argv&#91;])\n{\n    int ret = 0;\n    struct fuse_args args = FUSE_ARGS_INIT(argc, argv);\n    ret = fuse_main(args.argc, args.argv, &amp;ops, NULL);\n    fuse_opt_free_args(&amp;args);\n    return ret;\n}\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">chiakiFS : A simplified EXT2 file system on FUSE<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u57fa\u672cOn-Disk\u30ec\u30a4\u30a2\u30a6\u30c8<\/h3>\n\n\n\n<p>On-Disk\u69cb\u9020\u306f\u3001type.h\u3067\u5b9a\u7fa9\u3055\u308c\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/******************************************************************************\n* SECTION: FS Specific Structure - Disk structure (\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u56fa\u6709\u69cb\u9020 - \u30c7\u30a3\u30b9\u30af\u69cb\u9020)\n*******************************************************************************\/\nstruct chiakiFS_super_d \/\/ 40B\n{\n    uint32_t           magic_num;                \/\/ \u30de\u30b8\u30c3\u30af\u30ca\u30f3\u30d0\u30fc\n    uint32_t           sz_usage;                 \/\/ \u4f7f\u7528\u30b5\u30a4\u30ba\n\n    uint32_t           max_ino;                  \/\/ \u6700\u5927inode\u6570\n    uint32_t           map_inode_blks;           \/\/ inode\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    uint32_t           map_inode_offset;         \/\/ inode\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    uint32_t           inode_offset;             \/\/ inode\u30aa\u30d5\u30bb\u30c3\u30c8\n    uint32_t           max_data;                 \/\/ \u6700\u5927\u30c7\u30fc\u30bf\u6570\n    uint32_t           map_data_blks;            \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    uint32_t           map_data_offset;          \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    uint32_t           data_offset;              \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\n};\n\nstruct chiakiFS_inode_d \/\/ 164B\n{\n    uint32_t           ino;                     \/\/ inode\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9, 4B\n    uint32_t           size;                    \/\/ \u30d5\u30a1\u30a4\u30eb\u4f7f\u7528\u9818\u57df\u30b5\u30a4\u30ba, 4B\n    char               target_path&#91;CHIAKIFS_MAX_FILE_NAME]; \/\/ \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u6642\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9, 128*1B\n    uint32_t           dir_cnt;                 \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8, 4B\n    uint32_t           link_cnt;                \/\/ \u30ea\u30f3\u30af\u6570, 4B\n    CHIAKIFS_FILE_TYPE ftype;                   \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7, 4B\n    int                dblk&#91;CHIAKIFS_DATA_PER_FILE]; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u756a\u53f7, 4*4B\n};  \n\nstruct chiakiFS_dentry_d \/\/ 136B\n{\n    char               fname&#91;CHIAKIFS_MAX_FILE_NAME]; \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\n    CHIAKIFS_FILE_TYPE ftype;                     \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\n    uint32_t           ino;                       \/\/ \u6307\u5b9a\u3055\u308c\u305finode\u756a\u53f7\n};<\/code><\/pre>\n\n\n\n<p>\u5404Inode\u306b\u306f\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u6307\u30594\u3064\u306e\u30dd\u30a4\u30f3\u30bf\u304c\u5272\u308a\u5f53\u3066\u3089\u308c\u307e\u3059\u3002\u3053\u306e\u3068\u304d\u3001chiakiFS_inode_d\u306e\u30b5\u30a4\u30ba\u306f164B\u3067\u3042\u308a\u3001\u5404\u30d5\u30a1\u30a4\u30eb\u304c\u5fc5\u8981\u3068\u3059\u308b\u6700\u5927\u30b5\u30a4\u30ba\u306f$4\\times 1024 + 164 =4260$ B\u3068\u306a\u308a\u307e\u3059\u3002\u307e\u305f\u30011\u3064\u306e\u7d22\u5f15\u30d6\u30ed\u30c3\u30af\u306b\u306f$1024\/164=6.2$\u3001\u5373\u30616\u3064\u306e\u7d22\u5f15\u30ce\u30fc\u30c9\u304c\u683c\u7d0d\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u5168\u4f53\u306e\u30b5\u30a4\u30ba\u306f4MB\u3067\u3001\u5404\u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u306e\u30b5\u30a4\u30ba\u306f1024B\u3067\u3059\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u5408\u8a08\u30674K\u500b\u306e\u30d6\u30ed\u30c3\u30af\u304c\u5b58\u5728\u3057\u307e\u3059\u3002\u3053\u306e\u3046\u3061\u3001\u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u3001\u7d22\u5f15\u30ce\u30fc\u30c9\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u304c\u305d\u308c\u305e\u308c1\u3064\u306e\u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u3092\u5360\u6709\u3057\u307e\u3059\u3002\u6b8b\u308a\u306e\u30b9\u30da\u30fc\u30b9\u306f\u30d5\u30a1\u30a4\u30eb\u306e\u4fdd\u5b58\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002\u307e\u305f\u3001\u5404\u7d22\u5f15\u30d6\u30ed\u30c3\u30af\u306b\u306f40B\u306e\u672a\u4f7f\u7528\u9818\u57df\u304c\u3042\u308b\u305f\u3081\u3001\u3053\u306e\u30b9\u30da\u30fc\u30b9\u3092\u5404\u7d22\u5f15\u30ce\u30fc\u30c9\u306b\u5747\u7b49\u306b\u5272\u308a\u5f53\u3066\u307e\u3059\u3002\u3053\u306e\u7d50\u679c\u3001\u5404\u7d22\u5f15\u30ce\u30fc\u30c9\u306e\u30b5\u30a4\u30ba\u306f171B\u3068\u307f\u306a\u3055\u308c\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306b\u306f\u6700\u5927\u3067$(4M-3K)\/4267=982.24$\u3001\u3059\u306a\u308f\u3061982\u500b\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u53ce\u5bb9\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3057\u305f\u304c\u3063\u3066\u3001\u7d22\u5f15\u30ce\u30fc\u30c9\u306e\u4fdd\u5b58\u306b\u306f$982\\div 6=163.67$\u3001\u3059\u306a\u308f\u3061164\u500b\u306e\u7d22\u5f15\u30d6\u30ed\u30c3\u30af\u304c\u5fc5\u8981\u3067\u3059\u3002\u3053\u306e\u3068\u304d\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u6570\u306f$4096-1-1-1-164=3929$\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-browser_mac\"><img decoding=\"async\" width=\"2510\" height=\"1432\" src=\"https:\/\/www.yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1.png\" alt=\"\" class=\"wp-image-1562\" srcset=\"https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1.png 2510w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1-300x171.png 300w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1-1024x584.png 1024w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1-768x438.png 768w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1-1536x876.png 1536w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSLayout-1-2048x1168.png 2048w\" sizes=\"(max-width: 2510px) 100vw, 2510px\" \/><\/figure>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u5177\u4f53\u7684\u306aOn-Disk\u8a2d\u8a08\u6848\u306e\u6982\u7565\u56f3\u3067\u3059\u3002\u3053\u308c\u306b\u306f\u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306a\u3069\u306e\u5185\u90e8\u69cb\u9020\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002\u3057\u304b\u3057\u3001\u3053\u3053\u3067\u5f37\u8abf\u3057\u305f\u3044\u306e\u306f\u3001\u5b9f\u969b\u306e\u30b3\u30fc\u30c9\u5b9f\u88c5\u306b\u304a\u3044\u3066\u306f\u3001\u30c7\u30a3\u30b9\u30af\u306bDentry\u3092\u66f8\u304d\u8fbc\u3080\u65b9\u5411\u304c\u9006\u3067\u3042\u308b\u3068\u3044\u3046\u70b9\u3067\u3059\u3002\u3064\u307e\u308a\u3001\u4e0b\u56f3\u3067\u306f\u6700\u521d\u306b\u6709\u52b9\u306aDentry\uff08Dentry4\uff09\u304c\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af0\u306b\u66f8\u304d\u8fbc\u307e\u308c\u3001\u305d\u306e\u5f8cDentry3\u306a\u3069\u304c\u66f8\u304d\u8fbc\u307e\u308c\u307e\u3059\u3002\u305d\u306e\u305f\u3081\u3001\u3053\u306e\u56f3\u306e\u30c7\u30a3\u30b9\u30af\u30ec\u30a4\u30a2\u30a6\u30c8\u306f\u5b9f\u969b\u306e\u5b9f\u88c5\u3068\u306f\u82e5\u5e72\u7570\u306a\u308a\u307e\u3059\u3002\u66f4\u306b\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u30de\u30a6\u30f3\u30c8\u3059\u308b\u3068\u3001\u3053\u306e4MB\u306e\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306f\u4eee\u60f3\u30a2\u30c9\u30ec\u30b9\u4e0a\u3067\u30b9\u30bf\u30c3\u30af\u9818\u57df\u306b\u5272\u308a\u5f53\u3066\u3089\u308c\u3001\u4e0b\u65b9\u5411\u306b\u6210\u9577\u3057\u3002\u3057\u305f\u304c\u3063\u3066\u3001\u3053\u306e\u56f3\u306f\u3042\u304f\u307e\u3067\u53c2\u8003\u7528\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-browser_mac\"><img decoding=\"async\" width=\"1746\" height=\"1966\" src=\"https:\/\/www.yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSOnDisk.png\" alt=\"\" class=\"wp-image-1563\" srcset=\"https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSOnDisk.png 1746w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSOnDisk-266x300.png 266w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSOnDisk-909x1024.png 909w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSOnDisk-768x865.png 768w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSOnDisk-1364x1536.png 1364w\" sizes=\"(max-width: 1746px) 100vw, 1746px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u57fa\u672cIn-Mem\u30ec\u30a4\u30a2\u30a6\u30c8<\/h3>\n\n\n\n<p>\u30c7\u30a3\u30b9\u30af\u306e\u5185\u5bb9\u3092\u30e1\u30e2\u30ea\u306b\u8aad\u307f\u8fbc\u3093\u3060\u5f8c\u3001\u5177\u4f53\u7684\u306ainode\u3001dentry\u3001\u304a\u3088\u3073\u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u69cb\u9020\u306b\u3044\u304f\u3064\u304b\u306e\u5909\u66f4\u304c\u751f\u3058\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u5b9a\u7fa9\u3068In-Mem\u69cb\u9020\u56f3\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/******************************************************************************\n* SECTION: FS Specific Structure - In memory structure (\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u56fa\u6709\u69cb\u9020 - \u30e1\u30e2\u30ea\u5185\u69cb\u9020)\n*******************************************************************************\/\n\n\nstruct chiakiFS_inode\n{\n    int                     ino;                           \/\/ inode\u756a\u53f7\n    int                     size;                          \/\/ \u30d5\u30a1\u30a4\u30eb\u4f7f\u7528\u9818\u57df\u30b5\u30a4\u30ba\n    char                    target_path&#91;CHIAKIFS_MAX_FILE_NAME]; \/\/ \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u6642\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\n    int                     dir_cnt;                       \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\n    uint32_t                link_cnt;                      \/\/ \u30ea\u30f3\u30af\u6570\n    struct chiakiFS_dentry* dentry;                        \/\/ \u3053\u306einode\u3078\u306edentry\u3078\u306e\u30dd\u30a4\u30f3\u30bf\n    struct chiakiFS_dentry* dentrys;                       \/\/ \u5168\u3066\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\n    uint8_t*                data&#91;CHIAKIFS_DATA_PER_FILE];  \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\n    int                     dblk&#91;CHIAKIFS_DATA_PER_FILE];   \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u756a\u53f7\n};\n\nstruct chiakiFS_dentry\n{\n    char                    fname&#91;CHIAKIFS_MAX_FILE_NAME];\/\/ \u30d5\u30a1\u30a4\u30eb\u540d\n    struct chiakiFS_dentry* parent;                       \/\/ \u89aainode\u306edentry\n    struct chiakiFS_dentry* brother;                      \/\/ \u5144\u5f1fdentry\n    int                     ino;                          \/\/ inode\u756a\u53f7\n    struct chiakiFS_inode*  inode;                        \/\/ inode\u3078\u306e\u30dd\u30a4\u30f3\u30bf\n    CHIAKIFS_FILE_TYPE      ftype;                        \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\n};\n\nstruct chiakiFS_super\n{\n    int                driver_fd;                    \/\/ \u30c9\u30e9\u30a4\u30d0\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf\n\n    int                sz_io;                        \/\/ IO\u30b5\u30a4\u30ba\n    int                sz_disk;                      \/\/ \u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\n    int                sz_blk;                       \/\/ \u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\n    int                sz_usage;                     \/\/ \u4f7f\u7528\u30b5\u30a4\u30ba\n\n    int                max_ino;                      \/\/ \u6700\u5927inode\u6570\n    uint8_t*           map_inode;                    \/\/ inode\u30de\u30c3\u30d7\n    int                map_inode_blks;               \/\/ inode\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    int                map_inode_offset;             \/\/ inode\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    int                inode_offset;                 \/\/ inode\u30aa\u30d5\u30bb\u30c3\u30c8\n\n    int                max_data;                     \/\/ \u6700\u5927\u30c7\u30fc\u30bf\u6570\n    uint8_t*           map_data;                     \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\n    int                map_data_blks;                \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    int                map_data_offset;              \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    int                data_offset;                  \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\n\n    boolean            is_mounted;                   \/\/ \u30de\u30a6\u30f3\u30c8\u72b6\u614b\n\n    struct chiakiFS_dentry* root_dentry;             \/\/ \u30eb\u30fc\u30c8dentry\u3078\u306e\u30dd\u30a4\u30f3\u30bf\n};<\/code><\/pre>\n\n\n\n<p>In-Mem\u8868\u73fe\u3067\u306f\u3001\u30a2\u30c9\u30ec\u30b9\u306f\u8868\u793a\u3055\u308c\u307e\u305b\u3093\u3002\u56f3\u306b\u793a\u3055\u308c\u3066\u3044\u308b\u5404\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u5185\u90e8\u69cb\u9020\u306f\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u5185\u306b\u305d\u306e\u3088\u3046\u306a\u69cb\u9020\u304c\u5b58\u5728\u3059\u308b\u3053\u3068\u3092\u53cd\u6620\u3057\u3066\u3044\u308b\u3060\u3051\u3067\u3001\u30a2\u30c9\u30ec\u30b9\u3084\u9806\u5e8f\u306b\u95a2\u9023\u3059\u308b\u60c5\u5831\u306f\u53cd\u6620\u3057\u3066\u3044\u307e\u305b\u3093\u3002\u30dd\u30a4\u30f3\u30bf\u306e\u7a2e\u985e\u306f\u8272\u3067\u533a\u5225\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u7834\u7dda\u306f\u30cc\u30eb\u30dd\u30a4\u30f3\u30bf\u3092\u8868\u3057\u307e\u3059\u3002\u6700\u4e0b\u90e8\u306e\u7834\u7dda\u306f\u7701\u7565\u8a18\u53f7\u3067\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-browser_mac\"><img decoding=\"async\" width=\"1354\" height=\"2012\" src=\"https:\/\/www.yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSInMem.png\" alt=\"\" class=\"wp-image-1573\" srcset=\"https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSInMem.png 1354w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSInMem-202x300.png 202w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSInMem-689x1024.png 689w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSInMem-768x1141.png 768w, https:\/\/yanagichiaki.jp\/wp-content\/uploads\/2024\/11\/chiakiFSInMem-1034x1536.png 1034w\" sizes=\"(max-width: 1354px) 100vw, 1354px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">\u30de\u30af\u30ed\u5b9a\u7fa9<\/h3>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u5b9f\u73fe\u3059\u308b\u305f\u3081\u306b\u306f\u3001\u3044\u304f\u3064\u304b\u306e\u7279\u6b8a\u306a\u5b9a\u6570\u3084\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u3066\u518d\u5229\u7528\u3057\u3084\u3059\u304f\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">\/******************************************************************************\n* SECTION: Macro (\u30de\u30af\u30ed\u5b9a\u7fa9\u30bb\u30af\u30b7\u30e7\u30f3)\n*******************************************************************************\/\n#define TRUE                    1       \n#define FALSE                   0       \n#define UINT32_BITS             32      \n#define UINT8_BITS              8       \n\n#define CHIAKIFS_SUPER_OFS           0           \/\/ \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\n#define CHIAKIFS_ROOT_INO            0           \/\/ \u30eb\u30fc\u30c8inode\u756a\u53f7\n\n\/\/ Layout\u7528\u30de\u30af\u30ed\n#define CHIAKIFS_SUPER_BLKS          1           \/\/ \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_MAP_INODE_BLKS      1           \/\/ inode\u30de\u30c3\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_MAP_DATA_BLKS       1           \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_INODE_PER_BLOCK     6           \/\/ \u30d6\u30ed\u30c3\u30af\u3054\u3068\u306einode\u6570 (Layout)\n#define CHIAKIFS_INODE_BLKS          164         \/\/ inode\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_DATA_BLKS           3929        \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u6570\n\n#define CHIAKIFS_MAX_FILE_NAME       128         \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u306e\u6700\u5927\u9577\u3055\n#define CHIAKIFS_INODE_PER_FILE      1           \/\/ \u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306einode\u6570 (Layout)\n#define CHIAKIFS_DATA_PER_FILE       4           \/\/ \u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306e\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u6570 (Layout)\n#define CHIAKIFS_DEFAULT_PERM        0777        \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3 -rwxrwxrwx\n\n#define CHIAKIFS_IOC_MAGIC           'S'         \/\/ IOCTL\u306e\u30de\u30b8\u30c3\u30af\n#define CHIAKIFS_IOC_SEEK            _IO(CHIAKIFS_IOC_MAGIC, 0)  \/\/ IOCTL SEEK\n\n\/\/ \u30d0\u30c3\u30d5\u30a1\u306e\u30d5\u30e9\u30b0\u5b9a\u7fa9\n#define CHIAKIFS_FLAG_BUF_DIRTY      0x1         \/\/ \u30d0\u30c3\u30d5\u30a1\u304c\u30c0\u30fc\u30c6\u30a3\u72b6\u614b\n#define CHIAKIFS_FLAG_BUF_OCCUPY     0x2         \/\/ \u30d0\u30c3\u30d5\u30a1\u304c\u4f7f\u7528\u4e2d\n\n\/******************************************************************************\n* SECTION: Macro Function (\u30de\u30af\u30ed\u95a2\u6570\u30bb\u30af\u30b7\u30e7\u30f3)\n*******************************************************************************\/\n#define CHIAKIFS_IO_SZ()                     (chiakiFS_super.sz_io)                 \/\/ IO\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_DISK_SZ()                   (chiakiFS_super.sz_disk)               \/\/ \u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_BLK_SZ()                    (chiakiFS_super.sz_blk)                \/\/ \u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_DRIVER()                    (chiakiFS_super.driver_fd)             \/\/ \u30c9\u30e9\u30a4\u30d0\u53d6\u5f97\n#define CHIAKIFS_DENTRY_PER_DATABLK()        (CHIAKIFS_BLK_SZ()\/sizeof(struct chiakiFS_dentry))  \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3054\u3068\u306edentry\u6570\n\n#define CHIAKIFS_ROUND_DOWN(value, round)    ((value) % (round) == 0 ? (value) : ((value) \/ (round)) * (round))\n#define CHIAKIFS_ROUND_UP(value, round)      ((value) % (round) == 0 ? (value) : ((value) \/ (round) + 1) * (round))\n\n#define CHIAKIFS_BLKS_SZ(blks)               ((blks) * CHIAKIFS_BLK_SZ())           \/\/ \u30d6\u30ed\u30c3\u30af\u6570\u304b\u3089\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_ASSIGN_FNAME(pchiakiFS_dentry, _fname) \\\n    do { \\\n        strncpy((pchiakiFS_dentry)->fname, (_fname), CHIAKIFS_MAX_FILE_NAME - 1); \\\n        (pchiakiFS_dentry)->fname&#91;CHIAKIFS_MAX_FILE_NAME - 1] = '\\0'; \\\n    } while(0)\n \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5272\u308a\u5f53\u3066\n#define CHIAKIFS_INO_OFS(ino)                (chiakiFS_super.inode_offset \\\n     + (ino \/ CHIAKIFS_INODE_PER_BLOCK) * CHIAKIFS_BLK_SZ() \\\n     + (ino % CHIAKIFS_INODE_PER_BLOCK) * sizeof(struct chiakiFS_inode_d))                          \/\/ inode\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97\n\n#define CHIAKIFS_DATA_OFS(dno)               (chiakiFS_super.data_offset + CHIAKIFS_BLKS_SZ(dno))   \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97\n\n\/\/ inode\u306e\u30bf\u30a4\u30d7\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30de\u30af\u30ed\n#define CHIAKIFS_IS_DIR(pinode)              (pinode->dentry->ftype == CHIAKIFS_DIR)\n#define CHIAKIFS_IS_REG(pinode)              (pinode->dentry->ftype == CHIAKIFS_REG_FILE)\n#define CHIAKIFS_IS_SYM_LINK(pinode)         (pinode->dentry->ftype == CHIAKIFS_SYM_LINK)<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u30de\u30af\u30ed\u5b9a\u6570<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u8ad6\u7406\u5024\u306e\u5b9a\u7fa9<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>TRUE<\/code>: \u8ad6\u7406\u5024 <code>1<\/code> \u3092\u5b9a\u7fa9<\/li>\n\n\n\n<li><code>FALSE<\/code>: \u8ad6\u7406\u5024 <code>0<\/code> \u3092\u5b9a\u7fa9<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d3\u30c3\u30c8\u6570\u306e\u5b9a\u7fa9<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>UINT32_BITS<\/code>: 32\u30d3\u30c3\u30c8\u6574\u6570\u306e\u30d3\u30c3\u30c8\u6570 (<code>32<\/code>)<\/li>\n\n\n\n<li><code>UINT8_BITS<\/code>: 8\u30d3\u30c3\u30c8\u6574\u6570\u306e\u30d3\u30c3\u30c8\u6570 (<code>8<\/code>)<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3068\u521d\u671f\u8a2d\u5b9a<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_SUPER_OFS<\/code>: \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\uff08<code>0<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_ROOT_INO<\/code>: \u30eb\u30fc\u30c8inode\u756a\u53f7\uff08<code>0<\/code>\uff09<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30ec\u30a4\u30a2\u30a6\u30c8\u7528\u5b9a\u7fa9<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_SUPER_BLKS<\/code>: \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u30d6\u30ed\u30c3\u30af\u6570\uff08<code>1<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_MAP_INODE_BLKS<\/code>: inode\u30de\u30c3\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u6570\uff08<code>1<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_MAP_DATA_BLKS<\/code>: \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u6570\uff08<code>1<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_INODE_PER_BLOCK<\/code>: \u30d6\u30ed\u30c3\u30af\u3054\u3068\u306einode\u6570\uff08<code>6<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_INODE_BLKS<\/code>: inode\u306e\u30d6\u30ed\u30c3\u30af\u6570\uff08<code>164<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_DATA_BLKS<\/code>: \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u6570\uff08<code>3929<\/code>\uff09<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306b\u95a2\u9023\u3059\u308b\u30d1\u30e9\u30e1\u30fc\u30bf<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_MAX_FILE_NAME<\/code>: \u30d5\u30a1\u30a4\u30eb\u540d\u306e\u6700\u5927\u9577\u3055\uff08<code>128<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_INODE_PER_FILE<\/code>: \u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306einode\u6570\uff08<code>1<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_DATA_PER_FILE<\/code>: \u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306e\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u6570\uff08<code>4<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_DEFAULT_PERM<\/code>: \u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\uff08<code>0777<\/code>\uff09<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>IOCTL\u95a2\u9023\u306e\u5b9a\u7fa9<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_IOC_MAGIC<\/code>: IOCTL\u306e\u30de\u30b8\u30c3\u30af\u756a\u53f7\uff08<code>'S'<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_IOC_SEEK<\/code>: IOCTL\u3067\u306eSEEK\u64cd\u4f5c\u3092\u5b9a\u7fa9\u3059\u308b\u305f\u3081\u306e\u30de\u30af\u30ed<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d0\u30c3\u30d5\u30a1\u30d5\u30e9\u30b0\u306e\u5b9a\u7fa9<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_FLAG_BUF_DIRTY<\/code>: \u30d0\u30c3\u30d5\u30a1\u304c\u30c0\u30fc\u30c6\u30a3\u72b6\u614b\u3067\u3042\u308b\u3053\u3068\u3092\u793a\u3059\u30d5\u30e9\u30b0\uff08<code>0x1<\/code>\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_FLAG_BUF_OCCUPY<\/code>: \u30d0\u30c3\u30d5\u30a1\u304c\u4f7f\u7528\u4e2d\u3067\u3042\u308b\u3053\u3068\u3092\u793a\u3059\u30d5\u30e9\u30b0\uff08<code>0x2<\/code>\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30de\u30af\u30ed\u95a2\u6570<\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u57fa\u672c\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306e\u30de\u30af\u30ed<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_IO_SZ()<\/code>: IO\u30b5\u30a4\u30ba\u306e\u53d6\u5f97<\/li>\n\n\n\n<li><code>CHIAKIFS_DISK_SZ()<\/code>: \u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\u306e\u53d6\u5f97<\/li>\n\n\n\n<li><code>CHIAKIFS_BLK_SZ()<\/code>: \u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\u306e\u53d6\u5f97<\/li>\n\n\n\n<li><code>CHIAKIFS_DRIVER()<\/code>: \u30c9\u30e9\u30a4\u30d0\u306e\u53d6\u5f97<\/li>\n\n\n\n<li><code>CHIAKIFS_DENTRY_PER_DATABLK()<\/code>: \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3042\u305f\u308a\u306edentry\u6570\u306e\u53d6\u5f97<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u4e38\u3081<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_ROUND_DOWN(value, round)<\/code>: <code>value<\/code> \u3092 <code>round<\/code> \u306e\u500d\u6570\u306b\u4e38\u3081\u308b\uff08\u5207\u4e0b\uff09<\/li>\n\n\n\n<li><code>CHIAKIFS_ROUND_UP(value, round)<\/code>: <code>value<\/code> \u3092 <code>round<\/code> \u306e\u500d\u6570\u306b\u4e38\u3081\u308b\uff08\u5207\u4e0a\uff09<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d6\u30ed\u30c3\u30af\u6570\u304b\u3089\u30b5\u30a4\u30ba\u3092\u8a08\u7b97\u3059\u308b\u30de\u30af\u30ed<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_BLKS_SZ(blks)<\/code>: \u6307\u5b9a\u3055\u308c\u305f\u30d6\u30ed\u30c3\u30af\u6570 (<code>blks<\/code>) \u304b\u3089\u30b5\u30a4\u30ba\u3092\u8a08\u7b97<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5272\u308a\u5f53\u3066<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_ASSIGN_FNAME(pchiakiFS_dentry, _fname)<\/code>: \u6307\u5b9a\u3055\u308c\u305f <code>fname<\/code> \u3092 <code>pchiakiFS_dentry<\/code> \u306b\u5272\u308a\u5f53\u3066\uff08\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u30b3\u30d4\u30fc\uff09<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_INO_OFS(ino)<\/code>: \u6307\u5b9a\u3055\u308c\u305finode\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8a08\u7b97<\/li>\n\n\n\n<li><code>CHIAKIFS_DATA_OFS(dno)<\/code>: \u6307\u5b9a\u3055\u308c\u305f\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8a08\u7b97<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>inode\u306e\u30bf\u30a4\u30d7\u30c1\u30a7\u30c3\u30af<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>CHIAKIFS_IS_DIR(pinode)<\/code>: <code>pinode<\/code> \u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li><code>CHIAKIFS_IS_REG(pinode)<\/code>: <code>pinode<\/code> \u304c\u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af<\/li>\n\n\n\n<li><code>CHIAKIFS_IS_SYM_LINK(pinode)<\/code>: <code>pinode<\/code> \u304c\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u304b\u3069\u3046\u304b\u3092\u30c1\u30a7\u30c3\u30af<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">\u30a8\u30e9\u30fc\u5b9a\u6570<\/h4>\n\n\n\n<p>\u3053\u3053\u306f\u3001\u5e7e\u3064\u306e\u30a8\u30e9\u30fc\u5b9a\u6570\u3092\u5b9a\u7fa9\u3057\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\u306e\u30de\u30af\u30ed\u5b9a\u7fa9\n#define CHIAKIFS_ERROR_NONE          0           \/\/ \u30a8\u30e9\u30fc\u306a\u3057\n#define CHIAKIFS_ERROR_ACCESS        EACCES      \/\/ \u30a2\u30af\u30bb\u30b9\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_SEEK          ESPIPE      \/\/ \u30b7\u30fc\u30af\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_ISDIR         EISDIR      \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_NOSPACE       ENOSPC      \/\/ \u30b9\u30da\u30fc\u30b9\u4e0d\u8db3\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_EXISTS        EEXIST      \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_NOTFOUND      ENOENT      \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_UNSUPPORTED   ENXIO       \/\/ \u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u306a\u3044\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_IO            EIO         \/\/ \u5165\u51fa\u529b\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_INVAL         EINVAL      \/\/ \u7121\u52b9\u306a\u5f15\u6570\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_NOTDIR        ENOTDIR     \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306f\u306a\u3044\u30a8\u30e9\u30fc<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Low Level \u95a2\u6570\u30c7\u30b6\u30a4\u30f3<\/h3>\n\n\n\n<p>Low Level\u95a2\u6570\u4e00\u89a7\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">\/******************************************************************************\n* SECTION: chiakiFS_utils.c\n*******************************************************************************\/\nchar* \t\t\t\t      chiakiFS_get_fname(const char* path);\nint \t\t\t\t      chiakiFS_calc_lvl(const char * path);\nint \t\t\t\t      chiakiFS_driver_read(int offset, uint8_t *out_content, int size);\nint \t\t\t   \t      chiakiFS_driver_write(int offset, uint8_t *in_content, int size);\n\n\nint \t\t\t  \t      chiakiFS_mount(struct custom_options options);\nint \t\t\t  \t      chiakiFS_umount();\n\nint \t\t\t  \t      chiakiFS_alloc_dentry(struct chiakiFS_inode * inode, struct chiakiFS_dentry * dentry, int W);\nint \t\t\t  \t      chiakiFS_drop_dentry(struct chiakiFS_inode * inode, struct chiakiFS_dentry * dentry);\nstruct chiakiFS_inode*    chiakiFS_alloc_inode(struct chiakiFS_dentry * dentry);\nint \t\t\t\t      chiakiFS_sync_inode(struct chiakiFS_inode * inode);\nint \t\t\t\t      chiakiFS_drop_inode(struct chiakiFS_inode * inode);\nstruct chiakiFS_inode*    chiakiFS_read_inode(struct chiakiFS_dentry * dentry, int ino);\nstruct chiakiFS_dentry*   chiakiFS_get_dentry(struct chiakiFS_inode * inode, int dir);\n\nstruct chiakiFS_dentry*   chiakiFS_lookup(const char * path, boolean * is_find, boolean* is_root);<\/code><\/pre>\n\n\n\n<p>\u4fbf\u5229\u306e\u305f\u3081\u3001new_dentry\u3092types.h\u3067inline\u95a2\u6570\u3068\u3057\u3066\u5b9f\u88c5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ \u65b0\u3057\u3044dentry\u3092\u4f5c\u6210\u3059\u308b\u95a2\u6570\nstatic inline struct chiakiFS_dentry* new_dentry(char * fname, CHIAKIFS_FILE_TYPE ftype) {\n    struct chiakiFS_dentry * dentry = (struct chiakiFS_dentry *)malloc(sizeof(struct chiakiFS_dentry));\n    memset(dentry, 0, sizeof(struct chiakiFS_dentry));\n    CHIAKIFS_ASSIGN_FNAME(dentry, fname);\n    dentry-&gt;ftype   = ftype;\n    dentry-&gt;ino     = -1;\n    dentry-&gt;inode   = NULL;\n    dentry-&gt;parent  = NULL;\n    dentry-&gt;brother = NULL;\n    return dentry;                                        \n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_get_fname<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9\u304b\u3089\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u62bd\u51fa\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\n *\n * @param path\n * @return char*\n *\/\nchar *chiakiFS_get_fname(const char *path)\n{\n    char ch = '\/';\n    char *q = strrchr(path, ch);\n    if (q == NULL)\n        return (char *)path;\n    else\n        return q + 1;\n}<\/code><\/pre>\n\n\n\n<p><code>strrchr<\/code> \u95a2\u6570\u3092\u4f7f\u7528\u3057\u3066\u3001\u30d1\u30b9\u306e\u4e2d\u3067\u6700\u5f8c\u306e <code>'\/'<\/code> \u306e\u4f4d\u7f6e\u3092\u63a2\u3057\u307e\u3059\u3002\u305d\u306e\u4f4d\u7f6e\u306b 1 \u3092\u52a0\u3048\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5148\u982d\u6587\u5b57\u306e\u30dd\u30a4\u30f3\u30bf\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u5c1a\u3001\u30d1\u30b9\u306e\u4e2d\u3067\u6700\u5f8c\u306e <code>'\/'<\/code>\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\uff08\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30d1\u30b9\uff09\u3001\u30d1\u30b9\u3092\u305d\u306e\u307e\u307ereturn.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_calc_lvl<\/h4>\n\n\n\n<p>\u30d1\u30b9\u306e\u6df1\u3055\u3092\u8a08\u7b97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d1\u30b9\u306e\u6df1\u3055\u3092\u8a08\u7b97\n * exm: \/av\/c\/d\/f\n * -&gt; lvl = 4\n * @param path\n * @return int\n *\/\nint chiakiFS_calc_lvl(const char *path)\n{\n    \/\/ char* path_cpy = (char *)malloc(strlen(path));\n    \/\/ strcpy(path_cpy, path);\n    char *str = path;\n    int lvl = 0;\n    if (strcmp(path, \"\/\") == 0)\n    {\n        return lvl;\n    }\n    while (*str != NULL)\n    {\n        if (*str == '\/')\n        {\n            lvl++;\n        }\n        str++;\n    }\n    return lvl;\n}<\/code><\/pre>\n\n\n\n<p>\u6587\u5b57\u5217\u306e\u5148\u982d\u304b\u3089\u672b\u5c3e\u307e\u3067\u3092\u8d70\u67fb\u3057\u307e\u3059\u3002\u6bce\u56de <code>'\/'<\/code> \u3092\u898b\u3064\u3051\u308b\u305f\u3073\u306b\u968e\u5c64\u3092 1 \u5897\u52a0\u3055\u305b\u307e\u3059\u3002\u3082\u3057\u30d1\u30b9\u304c\u30eb\u30fc\u30c8\u30d1\u30b9 <code>'\/'<\/code> \u3067\u3042\u308c\u3070\u3001\u968e\u5c64\u306f 0 \u3067\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_driver_read<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30aa\u30d5\u30bb\u30c3\u30c8\u4f4d\u7f6e\u304b\u3089\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308a\u3001\u6307\u5b9a\u3055\u308c\u305f\u30b5\u30a4\u30ba\u306e\u30c7\u30fc\u30bf\u3092\u51fa\u529b\u30d0\u30c3\u30d5\u30a1\u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief ddriver\u8aad\u8fbc\n *\n * @param offset \u30aa\u30d5\u30bb\u30c3\u30c8\uff08\u8aad\u307f\u8fbc\u307f\u958b\u59cb\u4f4d\u7f6e\uff09\n * @param out_content \u8aad\u307f\u8fbc\u3093\u3060\u5185\u5bb9\u3092\u683c\u7d0d\u3059\u308b\u30d0\u30c3\u30d5\u30a1\n * @param size \u8aad\u307f\u8fbc\u3080\u30c7\u30fc\u30bf\u306e\u30b5\u30a4\u30ba\n * @return int \u6210\u529f\u6642\u306f0\uff08CHIAKIFS_ERROR_NONE\uff09\u3092\u8fd4\u3059\n *\/\nint chiakiFS_driver_read(int offset, uint8_t *out_content, int size)\n{\n    int offset_aligned = CHIAKIFS_ROUND_DOWN(offset, CHIAKIFS_BLK_SZ());    \/\/ \u30ed\u30b8\u30ab\u30eb\u30d6\u30ed\u30c3\u30af\u306b\u30a2\u30e9\u30a4\u30f3\n    int bias = offset - offset_aligned;                                     \/\/ \u30a2\u30e9\u30a4\u30f3\u3055\u308c\u305f\u30aa\u30d5\u30bb\u30c3\u30c8\u3068\u306e\u5dee\u5206\n    int size_aligned = CHIAKIFS_ROUND_UP((size + bias), CHIAKIFS_BLK_SZ()); \/\/ \u8aad\u307f\u8fbc\u3080\u30b5\u30a4\u30ba\u3092\u30d6\u30ed\u30c3\u30af\u5358\u4f4d\u306b\u30a2\u30e9\u30a4\u30f3\n    uint8_t *temp_content = (uint8_t *)malloc(size_aligned);                \/\/ \u4e00\u6642\u7684\u306b\u30c7\u30fc\u30bf\u3092\u683c\u7d0d\u3059\u308b\u305f\u3081\u306e\u30d0\u30c3\u30d5\u30a1\u3092\u78ba\u4fdd\n    uint8_t *cur = temp_content;                                            \/\/ \u73fe\u5728\u306e\u8aad\u307f\u8fbc\u307f\u4f4d\u7f6e\u3092\u6307\u3059\u30dd\u30a4\u30f3\u30bf\n    \/\/ lseek(CHIAKIFS_DRIVER(), offset_aligned, SEEK_SET);\n    ddriver_seek(CHIAKIFS_DRIVER(), offset_aligned, SEEK_SET); \/\/ \u8aad\u307f\u8fbc\u307f\u4f4d\u7f6e\u3092\u8a2d\u5b9a\n    while (size_aligned != 0)\n    {\n        \/\/ read(CHIAKIFS_DRIVER(), cur, CHIAKIFS_IO_SZ());\n        ddriver_read(CHIAKIFS_DRIVER(), cur, CHIAKIFS_IO_SZ()); \/\/ \u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\n        cur += CHIAKIFS_IO_SZ();                                \/\/ \u30dd\u30a4\u30f3\u30bf\u3092\u6b21\u306e\u8aad\u307f\u8fbc\u307f\u4f4d\u7f6e\u306b\u9032\u3081\u308b\n        size_aligned -= CHIAKIFS_IO_SZ();                       \/\/ \u6b8b\u308a\u306e\u30b5\u30a4\u30ba\u3092\u6e1b\u3089\u3059\n    }\n    memcpy(out_content, temp_content + bias, size); \/\/ \u5fc5\u8981\u306a\u90e8\u5206\u3060\u3051\u3092out_content\u306b\u30b3\u30d4\u30fc\n    free(temp_content);                             \/\/ \u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u306e\u89e3\u653e\n    return CHIAKIFS_ERROR_NONE;                     \/\/ \u30a8\u30e9\u30fc\u306a\u3057\u3092\u8fd4\u3059\n}<\/code><\/pre>\n\n\n\n<p>\u8aad\u307f\u53d6\u308a\u958b\u59cb\u4f4d\u7f6e\u3068\u30b5\u30a4\u30ba\u3092\u8abf\u6574\u3057\u3001\u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\u306b\u5408\u308f\u305b\u3066\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3092\u53d6\u308a\u3002\u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u3092\u5272\u5f53\u3001I\/O \u30d6\u30ed\u30c3\u30af\u5358\u4f4d\u3067\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\u8abf\u6574\u524d\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8003\u3048\u3067\u3001\u5b9f\u969b\u306b\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u90e8\u5206\u306e\u307f\u3092\u51fa\u529b\u30d0\u30c3\u30d5\u30a1\uff08<code>out_content<\/code>\uff09\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002\u3093\u3067\u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u3092\u89e3\u653e\u3067\u3044\u3044\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_driver_write<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30aa\u30d5\u30bb\u30c3\u30c8\u4f4d\u7f6e\u304b\u3089\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief ddriver\u66f8\u8fbc\n *\n * @param offset \u30aa\u30d5\u30bb\u30c3\u30c8\uff08\u66f8\u304d\u8fbc\u307f\u958b\u59cb\u4f4d\u7f6e\uff09\n * @param in_content \u66f8\u304d\u8fbc\u3080\u5185\u5bb9\u304c\u683c\u7d0d\u3055\u308c\u305f\u30d0\u30c3\u30d5\u30a1\n * @param size \u66f8\u304d\u8fbc\u3080\u30c7\u30fc\u30bf\u306e\u30b5\u30a4\u30ba\n * @return int \u6210\u529f\u6642\u306f\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9CHIAKIFS_ERROR_NONE\u3092\u8fd4\u3059\n *\/\nint chiakiFS_driver_write(int offset, uint8_t *in_content, int size)\n{\n    int offset_aligned = CHIAKIFS_ROUND_DOWN(offset, CHIAKIFS_BLK_SZ());\n    int bias = offset - offset_aligned;\n    int size_aligned = CHIAKIFS_ROUND_UP((size + bias), CHIAKIFS_BLK_SZ());\n    uint8_t *temp_content = (uint8_t *)malloc(size_aligned);\n    uint8_t *cur = temp_content;\n    chiakiFS_driver_read(offset_aligned, temp_content, size_aligned); \/\/ \u65e2\u5b58\u30c7\u30fc\u30bf\u3092temp_content\u306b\u8aad\u307f\u8fbc\u3080\n    memcpy(temp_content + bias, in_content, size);                    \/\/ \u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u5fc5\u8981\u306a\u4f4d\u7f6e\u306b\u30b3\u30d4\u30fc\n\n    \/\/ lseek(CHIAKIFS_DRIVER(), offset_aligned, SEEK_SET);\n    ddriver_seek(CHIAKIFS_DRIVER(), offset_aligned, SEEK_SET); \/\/ \u66f8\u304d\u8fbc\u307f\u4f4d\u7f6e\u3092\u8a2d\u5b9a\n    while (size_aligned != 0)\n    {\n        \/\/ write(CHIAKIFS_DRIVER(), cur, CHIAKIFS_IO_SZ());\n        ddriver_write(CHIAKIFS_DRIVER(), cur, CHIAKIFS_IO_SZ()); \/\/ \u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\n        cur += CHIAKIFS_IO_SZ();                                 \/\/ \u30dd\u30a4\u30f3\u30bf\u3092\u6b21\u306e\u66f8\u304d\u8fbc\u307f\u4f4d\u7f6e\u306b\u9032\u3081\u308b\n        size_aligned -= CHIAKIFS_IO_SZ();                        \/\/ \u6b8b\u308a\u306e\u30b5\u30a4\u30ba\u3092\u6e1b\u3089\u3059\n    }\n\n    free(temp_content); \/\/ \u30d0\u30c3\u30d5\u30a1\u89e3\u653e\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p>chiakiFS_driver_read\u3068\u540c\u3058\u3001\u66f8\u304d\u8fbc\u307f\u958b\u59cb\u4f4d\u7f6e\u3068\u30b5\u30a4\u30ba\u3092\u8abf\u6574\u3057\u3001\u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\u306b\u5408\u308f\u305b\u3066\u30a2\u30e9\u30a4\u30e1\u30f3\u30c8\u3092\u53d6\u308a\u307e\u3059\u3002\u73fe\u5728\u306e\u30c7\u30fc\u30bf\u304b\u3089\u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u306b\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8003\u3048\u3067\u3001\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u3092\u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u306e\u9069\u5207\u306a\u4f4d\u7f6e\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002\u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u306e\u30c7\u30fc\u30bf\u3092\u30c7\u30d0\u30a4\u30b9\u306b\u66f8\u304d\u623b\u3057\u307e\u3059\u3002\u3093\u3067\u4e00\u6642\u30d0\u30c3\u30d5\u30a1\u3092\u89e3\u653e\u3067\u3044\u3044\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_alloc_dentry<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3055\u308c\u305f inode \u306e\u305f\u3081\u306b dentry \u3092\u5272\u308a\u5f53\u3066\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u308a\u5f53\u3066\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief inode\u306bdentry\u3092\u5206\u914d\u3059\u308b\n *\n * @param inode \u5206\u914d\u5148\u306einode\u69cb\u9020\u4f53\n * @param dentry \u5206\u914d\u3059\u308bdentry\u69cb\u9020\u4f53\n * @param W \u66f8\u304d\u8fbc\u307f\u304c\u5fc5\u8981\u304b\u3092\u793a\u3059\u30d5\u30e9\u30b0\n * @return int \u66f4\u65b0\u3055\u308c\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30ab\u30a6\u30f3\u30c8\n *\/\nint chiakiFS_alloc_dentry(struct chiakiFS_inode *inode, struct chiakiFS_dentry *dentry, boolean W)\n{\n    if (inode-&gt;dentrys == NULL)\n    {\n        inode-&gt;dentrys = dentry; \/\/ dentrys\u304cNULL\u306e\u5834\u5408\u3001\u65b0\u3057\u3044dentry\u3092\u8a2d\u5b9a\n    }\n    else\n    {\n        dentry-&gt;brother = inode-&gt;dentrys; \/\/ \u65e2\u5b58\u306edentry\u306e\u524d\u306b\u65b0\u3057\u3044dentry\u3092\u633f\u5165\n        inode-&gt;dentrys = dentry;\n    }\n    inode-&gt;dir_cnt++; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u6570\u3092\u5897\u52a0\n\n    int cur_blk = inode-&gt;dir_cnt \/ CHIAKIFS_DENTRY_PER_DATABLK(); \/\/ \u73fe\u5728\u306e\u30d6\u30ed\u30c3\u30af\u4f4d\u7f6e\u3092\u8a08\u7b97\n    if (W)\n    { \/\/ \u66f8\u304d\u8fbc\u307f\u304c\u5fc5\u8981\u304b\u78ba\u8a8d\n        if (inode-&gt;dir_cnt % CHIAKIFS_DENTRY_PER_DATABLK() == 1)\n        {\n            int byte_cursor = 0;\n            int bit_cursor = 0;\n            int dno_cursor = 0;\n            boolean is_find_free_blk = FALSE;\n            for (byte_cursor = 0; byte_cursor &lt; CHIAKIFS_BLKS_SZ(chiakiFS_super.map_data_blks); byte_cursor++)\n            {\n                for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++)\n                {\n                    if ((chiakiFS_super.map_data&#91;byte_cursor] &amp; (0x1 &lt;&lt; bit_cursor)) == 0)\n                    {\n                        \/* \u73fe\u5728\u306edno_cursor\u4f4d\u7f6e\u304c\u7a7a\u304d *\/\n                        chiakiFS_super.map_data&#91;byte_cursor] |= (0x1 &lt;&lt; bit_cursor); \/\/ \u8a72\u5f53\u30d3\u30c3\u30c8\u30921\u306b\u8a2d\u5b9a\n\n                        inode-&gt;dblk&#91;cur_blk] = dno_cursor; \/\/ inode\u306b\u30d6\u30ed\u30c3\u30af\u756a\u53f7\u3092\u8a2d\u5b9a\n                        is_find_free_blk = TRUE;          \/\/ \u7a7a\u304d\u30d6\u30ed\u30c3\u30af\u304c\u898b\u3064\u304b\u3063\u305f\u3068\u30d5\u30e9\u30b0\u3092\u7acb\u3066\u308b\n                        break;\n                    }\n                    dno_cursor++; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u756a\u53f7\u3092\u9032\u3081\u308b\n                }\n                if (is_find_free_blk)\n                {\n                    break; \/\/ \u7a7a\u304d\u30d6\u30ed\u30c3\u30af\u304c\u898b\u3064\u304b\u3063\u305f\u3089\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\n                }\n            }\n            \/\/ \u7a7a\u304d\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\n            if (!is_find_free_blk || dno_cursor == chiakiFS_super.max_data)\n                return -CHIAKIFS_ERROR_NOSPACE;\n        }\n    }\n    return inode-&gt;dir_cnt; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\u3092\u8fd4\u3059\n}<\/code><\/pre>\n\n\n\n<p>dentry \u3092 inode \u306e dentry \u30ea\u30b9\u30c8\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u6570\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002\u66f8\u304d\u8fbc\u307f\u30d5\u30e9\u30b0 <code>W<\/code> \u304c\u8a2d\u5b9a\u3055\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u5fc5\u8981\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u65b0\u3057\u3044\u30d6\u30ed\u30c3\u30af\u304c\u5fc5\u8981\u306a\u5834\u5408\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u304b\u3089\u7a7a\u304d\u30d6\u30ed\u30c3\u30af\u3092\u691c\u7d22\u3057\u3001\u5272\u5f53\u3002\u5272\u308a\u5f53\u3066\u305f\u30d6\u30ed\u30c3\u30af\u756a\u53f7\u3092 inode \u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_drop_dentry<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3055\u308c\u305f inode \u304b\u3089\u7279\u5b9a\u306e dentry \u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief inode\u306edentrys\u304b\u3089dentry\u3092\u53d6\u308a\u9664\u304f\n *\n * @param inode \u5bfe\u8c61\u306einode\u69cb\u9020\u4f53\n * @param dentry \u524a\u9664\u3059\u308bdentry\u69cb\u9020\u4f53\n * @return int \u6210\u529f\u6642\u306f\u66f4\u65b0\u3055\u308c\u305f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\u3092\u8fd4\u3057\u3001\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306f\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\u3092\u8fd4\u3059\n *\/\nint chiakiFS_drop_dentry(struct chiakiFS_inode *inode, struct chiakiFS_dentry *dentry)\n{\n    boolean is_find = FALSE;\n    struct chiakiFS_dentry *prev_dentry = NULL;             \/\/ \u524d\u306edentry\u3092\u6307\u3059\u30dd\u30a4\u30f3\u30bf\n    struct chiakiFS_dentry *dentry_cursor = inode-&gt;dentrys; \/\/ \u73fe\u5728\u306edentry\u3092\u6307\u3059\u30dd\u30a4\u30f3\u30bf\n\n    while (dentry_cursor)\n    { \/\/ dentry\u30ea\u30b9\u30c8\u3092\u5de1\u56de\n        if (dentry_cursor == dentry)\n        {\n            if (prev_dentry == NULL)\n            {\n                \/\/ \u524a\u9664\u5bfe\u8c61\u306edentry\u304c\u30ea\u30b9\u30c8\u306e\u6700\u521d\u306e\u5834\u5408\n                inode-&gt;dentrys = dentry_cursor-&gt;brother;\n            }\n            else\n            {\n                prev_dentry-&gt;brother = dentry_cursor-&gt;brother; \/\/ \u30ea\u30b9\u30c8\u306e\u30ea\u30f3\u30af\u3092\u66f4\u65b0\n            }\n            is_find = TRUE;\n            break;\n        }\n        prev_dentry = dentry_cursor;\n        dentry_cursor = dentry_cursor-&gt;brother; \/\/ \u6b21\u306edentry\u306b\u9032\u3080\n    }\n\n    if (!is_find)\n    {\n        return -CHIAKIFS_ERROR_NOTFOUND; \/\/ dentry\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    }\n    inode-&gt;dir_cnt--; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30ab\u30a6\u30f3\u30c8\u3092\u6e1b\u3089\u3059\n    return inode-&gt;dir_cnt;\n}<\/code><\/pre>\n\n\n\n<p>inode \u306e dentry \u30ea\u30b9\u30c8\u3092\u8d70\u67fb\u3057\u3001\u76ee\u7684\u306e dentry \u3092\u898b\u3064\u3051\u307e\u3059\u3002\u30ea\u30b9\u30c8\u304b\u3089\u305d\u306e dentry \u3092\u524a\u9664\u3057\u3001dentry \u30ea\u30b9\u30c8\u3092\u518d\u30ea\u30f3\u30af\u3057\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u6570\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002\u76ee\u7684\u306e dentry \u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_alloc_inode<\/h4>\n\n\n\n<p>\u65b0\u3057\u3044 inode \u3092\u5272\u308a\u5f53\u3066\u3001\u95a2\u9023\u3059\u308b\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief inode\u3092\u5206\u914d\uff0c\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u8a2d\u7f6e\n *\n * @param dentry dentry\u2192\u3053\u306einode\n * @return chiakiFS_inode \u6210\u529f\u6642\u306f\u65b0\u3057\u3044inode\u3092\u8fd4\u3057\u3001\u5931\u6557\u6642\u306f\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\u3092\u8fd4\u3059\n *\/\nstruct chiakiFS_inode *chiakiFS_alloc_inode(struct chiakiFS_dentry *dentry)\n{\n    struct chiakiFS_inode *inode;\n    int byte_cursor = 0;\n    int bit_cursor = 0;\n    int ino_cursor = 0;\n    int dblk_cursor = 0;\n    boolean is_find_free_entry = FALSE;\n\n    for (byte_cursor = 0; byte_cursor &lt; CHIAKIFS_BLKS_SZ(chiakiFS_super.map_inode_blks);\n         byte_cursor++)\n    {\n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++)\n        {\n            if ((chiakiFS_super.map_inode&#91;byte_cursor] &amp; (0x1 &lt;&lt; bit_cursor)) == 0)\n            {\n                \/* ino_cursor\u306e\u4f4d\u7f6e\u304c\u7a7a*\/\n                chiakiFS_super.map_inode&#91;byte_cursor] |= (0x1 &lt;&lt; bit_cursor); \/\/ \u7a7a\u304dinode\u3092\u78ba\u4fdd\n                is_find_free_entry = TRUE;\n                break;\n            }\n            ino_cursor++; \/\/ inode\u30ab\u30fc\u30bd\u30eb\u3092\u9032\u3081\u308b\n        }\n        if (is_find_free_entry)\n        {\n            break; \/\/ \u7a7a\u304dinode\u304c\u898b\u3064\u304b\u3063\u305f\u3089\u30eb\u30fc\u30d7\u3092\u629c\u3051\u308b\n        }\n    }\n\n    if (!is_find_free_entry || ino_cursor == chiakiFS_super.max_ino)\n        return (void *)-CHIAKIFS_ERROR_NOSPACE; \/\/ \u7a7a\u304dinode\u304c\u306a\u3044\u5834\u5408\u306f\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n\n    inode = (struct chiakiFS_inode *)malloc(sizeof(struct chiakiFS_inode)); \/\/ inode\u69cb\u9020\u4f53\u306e\u30e1\u30e2\u30ea\u3092\u78ba\u4fdd\n    inode-&gt;ino = ino_cursor;\n    inode-&gt;size = 0;\n    inode-&gt;dir_cnt = 0;\n    inode-&gt;dentrys = 0;\n    \/* dentry\u2192inode *\/\n    dentry-&gt;inode = inode;\n    dentry-&gt;ino = inode-&gt;ino;\n    \/* inode\u2192dentry *\/\n    inode-&gt;dentry = dentry;\n\n    inode-&gt;dir_cnt = 0;\n    inode-&gt;dentrys = NULL;\n    if (CHIAKIFS_IS_DIR(inode))\n        inode -&gt; link_cnt = 2;\n    else\n        inode -&gt; link_cnt = 1;\n    if (CHIAKIFS_IS_REG(inode))\n    { \/\/ \u30ec\u30ae\u30e5\u30e9\u30fc\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\n        for (int i = 0; i &lt; CHIAKIFS_DATA_PER_FILE; i++)\n            inode-&gt;data&#91;i] = (uint8_t *)malloc(CHIAKIFS_BLK_SZ()); \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30e1\u30e2\u30ea\u3092\u78ba\u4fdd\n    }\n\n    return inode; \/\/ \u65b0\u3057\u3044inode\u3092\u8fd4\u3059\n}<\/code><\/pre>\n\n\n\n<p>inode \u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u691c\u7d22\u3057\u3066\u7a7a\u304d inode \u3092\u898b\u3064\u3051\u307e\u3059\u3002\u7a7a\u304d inode \u3092\u898b\u3064\u3051\u305f\u5834\u5408\u3001\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002\u30e1\u30e2\u30ea\u4e0a\u306b\u65b0\u3057\u3044 inode \u69cb\u9020\u4f53\u3092\u5272\u308a\u5f53\u3066\u3001\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306b\u57fa\u3065\u3044\u3066\u521d\u671f\u5316\u3057\u307e\u3059\u3002dentry \u3068 inode \u306e\u9593\u306e\u53c2\u7167\u3092\u8a2d\u5b9a\u3002\u30ea\u30f3\u30af\u6570\u3092\u8a2d\u5b9a\u3002\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u304c\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u5f53\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_sync_inode<\/h4>\n\n\n\n<p>\u30e1\u30e2\u30ea\u4e0a\u306e inode \u3068\u305d\u306e\u95a2\u9023\u30c7\u30fc\u30bf\u3092\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u623b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30e1\u30e2\u30eainode\u3068\u305d\u306e\u4ed8\u5c5e\u69cb\u9020\u3092\u30c7\u30a3\u30b9\u30af\u3078Writeback\n *\n * @param inode \u540c\u671f\u3059\u308binode\n * @return int \u6210\u529f\u6642\u306f\uff10\u3092\u8fd4\u3057\u3001\u5931\u6557\u6642\u306f\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\u3092\u8fd4\u3059\n *\/\nint chiakiFS_sync_inode(struct chiakiFS_inode *inode)\n{\n    struct chiakiFS_inode_d inode_d;       \/\/ \u30c7\u30a3\u30b9\u30af\u306b\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306einode\u69cb\u9020\u4f53\n    struct chiakiFS_dentry *dentry_cursor; \/\/ dentry\u30ea\u30b9\u30c8\u3092\u5de1\u56de\u3059\u308b\u30ab\u30fc\u30bd\u30eb\n    struct chiakiFS_dentry_d dentry_d;     \/\/ \u30c7\u30a3\u30b9\u30af\u306b\u4fdd\u5b58\u3059\u308b\u305f\u3081\u306edentry\u69cb\u9020\u4f53\n    int ino = inode-&gt;ino;\n    inode_d.ino = ino;\n    inode_d.size = inode-&gt;size;\n    memcpy(inode_d.target_path, inode-&gt;target_path, CHIAKIFS_MAX_FILE_NAME); \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u3092\u30b3\u30d4\u30fc\n    inode_d.ftype = inode-&gt;dentry-&gt;ftype;                                    \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u3092\u8a2d\u5b9a\n    inode_d.dir_cnt = inode-&gt;dir_cnt;                                        \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\u3092\u8a2d\u5b9a\n    inode_d.link_cnt = inode-&gt;link_cnt;\n    int offset, offset_END;\n    for (int i = 0; i &lt; CHIAKIFS_DATA_PER_FILE; i++)\n        inode_d.dblk&#91;i] = inode-&gt;dblk&#91;i]; \/\/ \u30d6\u30ed\u30c3\u30af\u756a\u53f7\u3092\u8a2d\u5b9a\n\n    if (chiakiFS_driver_write(CHIAKIFS_INO_OFS(ino), (uint8_t *)&amp;inode_d,\n                              sizeof(struct chiakiFS_inode_d)) != CHIAKIFS_ERROR_NONE)\n    {\n        CHIAKIFS_DBG(\"&#91;%s] io error\\n\", __func__);\n        return -CHIAKIFS_ERROR_IO;\n    }\n    \/* Cycle 1:  INODE \u66f8\u8fbc*\/\n    \/* Cycle 2:  DATA  \u66f8\u8fbc*\/\n    if (CHIAKIFS_IS_DIR(inode))\n    { \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\n        int blk_synced = 0;\n        dentry_cursor = inode-&gt;dentrys; \/\/ dentry\u30ab\u30fc\u30bd\u30eb\u3092\u521d\u671f\u5316\n        \/\/ SYNC\n        while (dentry_cursor &amp;&amp; blk_synced &lt; CHIAKIFS_DATA_PER_FILE)\n        {\n            offset = CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_synced]);         \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8a2d\u5b9a\n            offset_END = CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_synced] + 1); \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\u306e\u7d42\u4e86\u4f4d\u7f6e\u3092\u8a2d\u5b9a\n            while (dentry_cursor != NULL &amp;&amp; offset &lt; offset_END)\n            {\n                memcpy(dentry_d.fname, dentry_cursor-&gt;fname, CHIAKIFS_MAX_FILE_NAME);\n                dentry_d.ftype = dentry_cursor-&gt;ftype;\n                dentry_d.ino = dentry_cursor-&gt;ino;\n                if (chiakiFS_driver_write(offset, (uint8_t *)&amp;dentry_d,\n                                          sizeof(struct chiakiFS_dentry_d)) != CHIAKIFS_ERROR_NONE)\n                {\n                    CHIAKIFS_DBG(\"&#91;%s] io error\\n\", __func__);\n                    return -CHIAKIFS_ERROR_IO;\n                }\n\n                if (dentry_cursor-&gt;inode != NULL)\n                {\n                    chiakiFS_sync_inode(dentry_cursor-&gt;inode); \/\/ \u5b50inode\u3092\u518d\u5e30\u7684\u306b\u540c\u671f\n                }\n\n                dentry_cursor = dentry_cursor-&gt;brother;     \/\/ \u6b21\u306edentry\u306b\u9032\u3080\n                offset += sizeof(struct chiakiFS_dentry_d); \/\/ \u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u9032\u3081\u308b\n            }\n            blk_synced++;\n        }\n    }\n    else if (CHIAKIFS_IS_REG(inode))\n    { \/\/ \u30ec\u30ae\u30e5\u30e9\u30fc\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\n        for (int blk_synced = 0; blk_synced &lt; CHIAKIFS_DATA_PER_FILE; blk_synced++)\n        {\n            if (inode-&gt;dblk&#91;blk_synced] == 0)\n            {\n                break; \/\/ \u3053\u308c\u4ee5\u4e0a\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u306a\u3044\u5834\u5408\u3001\u30eb\u30fc\u30d7\u3092\u7d42\u4e86\n            }\n            if (chiakiFS_driver_write(CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_synced]),\n                                      inode-&gt;data&#91;blk_synced],\n                                      CHIAKIFS_BLK_SZ()) != CHIAKIFS_ERROR_NONE)\n            {\n                CHIAKIFS_DBG(\"&#91;%s] io error\\n\", __func__);\n                return -CHIAKIFS_ERROR_IO;\n            }\n        }\n    }\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p>inode \u60c5\u5831\u3092\u30c7\u30a3\u30b9\u30af\u30b9\u30c8\u30ec\u30fc\u30b8\u7528\u306e\u69cb\u9020\u4f53\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002inode \u3092\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002inode \u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\u3001dentry \u30ea\u30b9\u30c8\u3092\u8d70\u67fb\u3057\u3001\u5404 dentry \u3092\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u8fbc\u307f\u3002\u5b50 inode \u304c\u5b58\u5728\u3059\u308b\u5834\u5408\u3001<code>chiakiFS_sync_inode<\/code> \u3092\u518d\u5e30\u7684\u306b\u547c\u3073\u51fa\u3057\u3002inode \u304c\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u8fbc\u307f\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_drop_inode<\/h4>\n\n\n\n<p>\u30e1\u30e2\u30ea\u4e0a\u306e inode \u3092\u524a\u9664\u3057\u3001\u95a2\u9023\u3059\u308b\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3068\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30e1\u30e2\u30ea\u306einode\u3092\u524a\u9664\u3001\u3060\u304c\u30e1\u30e2\u30ea\u9818\u57df\u3092\u89e3\u653e\u3057\u307e\u305b\u3093\n * Case 1: Reg File\n *\n *                  Inode\n *                \/      \\\n *            Dentry -&gt; Dentry (Reg Dentry)\n *                       |\n *                      Inode  (Reg File)\n *\n *  1) Step 1. Erase Bitmap\n *  2) Step 2. Free Inode                      (Function of chiakiFS_drop_inode)\n * ------------------------------------------------------------------------\n *  3) *Setp 3. Free Dentry belonging to Inode (Outsider)\n * ========================================================================\n * Case 2: Dir\n *                  Inode\n *                \/      \\\n *            Dentry -&gt; Dentry (Dir Dentry)\n *                       |\n *                      Inode  (Dir)\n *                    \/     \\\n *                Dentry -&gt; Dentry\n *\n *   Recursive\n * @param inode\n * @return int\n *\/\nint chiakiFS_drop_inode(struct chiakiFS_inode *inode)\n{\n    struct chiakiFS_dentry *dentry_cursor;\n    struct chiakiFS_dentry *next_dentry;\n    int ino = inode-&gt;ino;\n    int byte_index, bit_index;\n\n    if (inode == chiakiFS_super.root_dentry-&gt;inode)\n    {\n        return CHIAKIFS_ERROR_INVAL; \/\/ \u30eb\u30fc\u30c8inode\u306f\u524a\u9664\u3067\u304d\u306a\u3044\n    }\n\n    if (CHIAKIFS_IS_DIR(inode))\n    {\n        \/\/ \u5b50inode\u3092\u518d\u5e30\u7684\u306b\u524a\u9664\n        dentry_cursor = inode-&gt;dentrys;\n        while (dentry_cursor)\n        {\n            next_dentry = dentry_cursor-&gt;brother;       \/\/ \u6b21\u306edentry\u3092\u4fdd\u5b58\n            chiakiFS_drop_inode(dentry_cursor-&gt;inode);  \/\/ \u5b50inode\u3092\u518d\u5e30\u7684\u306b\u524a\u9664\n            chiakiFS_drop_dentry(inode, dentry_cursor); \/\/ \u89aa\u304b\u3089dentry\u3092\u524a\u9664\n            free(dentry_cursor);                        \/\/ dentry\u3092\u89e3\u653e\n            dentry_cursor = next_dentry;\n        }\n        \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u4f7f\u7528\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\n        for (int blk_cursor = 0; blk_cursor &lt; CHIAKIFS_DATA_PER_FILE; blk_cursor++)\n        {\n            int dblk = inode-&gt;dblk&#91;blk_cursor];\n            if (dblk == 0)\n                continue; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u3082\u3046\u306a\u3044\u5834\u5408\n            \/\/ \u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3067\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u7a7a\u304d\u3068\u3059\u308b\n            byte_index = dblk \/ UINT8_BITS;\n            bit_index = dblk % UINT8_BITS;\n            chiakiFS_super.map_data&#91;byte_index] &amp;= (uint8_t)(~(0x1 &lt;&lt; bit_index));\n            inode-&gt;dblk&#91;blk_cursor] = 0; \/\/ \u30d6\u30ed\u30c3\u30af\u756a\u53f7\u3092\u30af\u30ea\u30a2\n        }\n    }\n    else if (CHIAKIFS_IS_REG(inode) || CHIAKIFS_IS_SYM_LINK(inode))\n    {\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u4f7f\u7528\u3057\u3066\u3044\u308b\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\n        for (int blk_cursor = 0; blk_cursor &lt; CHIAKIFS_DATA_PER_FILE; blk_cursor++)\n        {\n            int dblk = inode-&gt;dblk&#91;blk_cursor];\n            if (dblk == 0)\n                continue; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u3082\u3046\u306a\u3044\u5834\u5408\n            \/\/ \u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3067\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u7a7a\u304d\u3068\u3059\u308b\n            byte_index = dblk \/ UINT8_BITS;\n            bit_index = dblk % UINT8_BITS;\n            chiakiFS_super.map_data&#91;byte_index] &amp;= (uint8_t)(~(0x1 &lt;&lt; bit_index));\n            inode-&gt;dblk&#91;blk_cursor] = 0; \/\/ \u30d6\u30ed\u30c3\u30af\u756a\u53f7\u3092\u30af\u30ea\u30a2\n            if (inode-&gt;data&#91;blk_cursor])\n            {\n                free(inode-&gt;data&#91;blk_cursor]); \/\/ \u30c7\u30fc\u30bf\u30d0\u30c3\u30d5\u30a1\u3092\u89e3\u653e\n                inode-&gt;data&#91;blk_cursor] = NULL;\n            }\n        }\n    }\n\n    \/\/ inode\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3067inode\u3092\u7a7a\u304d\u3068\u3059\u308b\n    byte_index = ino \/ UINT8_BITS;\n    bit_index = ino % UINT8_BITS;\n    chiakiFS_super.map_inode&#91;byte_index] &amp;= (uint8_t)(~(0x1 &lt;&lt; bit_index));\n\n    free(inode);\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p>\u30eb\u30fc\u30c8 inode \u3067\u306a\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3057\u3066\u3001inode \u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308b\u5834\u5408\u3001\u5b50 inode \u3092\u518d\u5e30\u7684\u306b\u524a\u9664\u3057\u3001\u95a2\u9023\u3059\u308b\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\u3057\u307e\u3059\u3002inode \u304c\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u306e\u5834\u5408\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\u3057\u307e\u3059\u3002\u3093\u3067inode \u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u66f4\u65b0\u3057\u3001inode \u69cb\u9020\u4f53\u3092\u89e3\u653e\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_read_inode<\/h4>\n\n\n\n<p>\u30c7\u30a3\u30b9\u30af\u304b\u3089 inode \u3092\u8aad\u307f\u53d6\u308a\u3001\u30e1\u30e2\u30ea\u4e0a\u306b inode \u69cb\u9020\u4f53\u3092\u69cb\u7bc9\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief\n *\n * @param dentry dentry-&gt;ino-&gt;inode\n * @param ino inode\n * @return struct chiakiFS_inode* \u8aad\u307f\u8fbc\u3093\u3060inode\u69cb\u9020\u4f53\u3092\u8fd4\u3059\n *\/\nstruct chiakiFS_inode *chiakiFS_read_inode(struct chiakiFS_dentry *dentry, int ino)\n{\n    struct chiakiFS_inode *inode = (struct chiakiFS_inode *)malloc(sizeof(struct chiakiFS_inode)); \/\/ inode\u69cb\u9020\u4f53\u3092\u30e1\u30e2\u30ea\u306b\u78ba\u4fdd\n    struct chiakiFS_inode_d inode_d;\n    struct chiakiFS_dentry *sub_dentry;\n    struct chiakiFS_dentry_d dentry_d;\n    int blk_cnt = 0, dir_cnt = 0, i, offset, offset_END;\n\n    if (chiakiFS_driver_read(CHIAKIFS_INO_OFS(ino), (uint8_t *)&amp;inode_d,\n                             sizeof(struct chiakiFS_inode_d)) != CHIAKIFS_ERROR_NONE)\n    {\n        CHIAKIFS_DBG(\"&#91;%s] io error\\n\", __func__);\n        return NULL;\n    }\n\n    inode-&gt;dir_cnt = 0;\n    inode-&gt;link_cnt = inode_d.link_cnt;\n    inode-&gt;ino = inode_d.ino;\n    inode-&gt;size = inode_d.size;\n    memcpy(inode-&gt;target_path, inode_d.target_path, CHIAKIFS_MAX_FILE_NAME); \/\/ \u30d1\u30b9\u540d\u3092\u30b3\u30d4\u30fc\n    inode-&gt;dentry = dentry;\n\n    inode-&gt;dentrys = NULL;\n    for (i = 0; i &lt; CHIAKIFS_DATA_PER_FILE; i++)\n        inode-&gt;dblk&#91;i] = inode_d.dblk&#91;i];\n\n    if (CHIAKIFS_IS_DIR(inode))\n    {\n        dir_cnt = inode_d.dir_cnt; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\u3092\u8a2d\u5b9a\n        blk_cnt = 0;               \/\/ \u8aad\u307f\u8fbc\u307e\u308c\u305f\u30d6\u30ed\u30c3\u30af\u6570\n        while (dir_cnt &amp;&amp; blk_cnt &lt; CHIAKIFS_DATA_PER_FILE)\n        {\n            offset = CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_cnt]);\n            offset_END = CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_cnt] + 1);\n            while (offset &lt; offset_END &amp;&amp; dir_cnt &gt; 0)\n            {\n                if (chiakiFS_driver_read(offset,\n                                         (uint8_t *)&amp;dentry_d,\n                                         sizeof(struct chiakiFS_dentry_d)) != CHIAKIFS_ERROR_NONE)\n                {\n                    CHIAKIFS_DBG(\"&#91;%s] io error\\n\", __func__);\n                    return NULL;\n                }\n                sub_dentry = new_dentry(dentry_d.fname, dentry_d.ftype); \/\/ \u65b0\u3057\u3044dentry\u3092\u751f\u6210\n                sub_dentry-&gt;parent = inode-&gt;dentry;\n                sub_dentry-&gt;ino = dentry_d.ino;\n                sub_dentry-&gt;inode = NULL;\n                chiakiFS_alloc_dentry(inode, sub_dentry, FALSE); \/\/ dentry\u3092inode\u306b\u5272\u308a\u5f53\u3066\n                offset += sizeof(struct chiakiFS_dentry_d);\n                dir_cnt--;\n            }\n        }\n    }\n    else if (CHIAKIFS_IS_REG(inode))\n    {\n        for (int blk_cnt = 0; blk_cnt &lt; CHIAKIFS_DATA_PER_FILE; blk_cnt++)\n        {\n            if (inode-&gt;dblk&#91;blk_cnt] == 0)\n            {\n                break; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u3082\u3046\u306a\u3044\u5834\u5408\n            }\n            inode-&gt;data&#91;blk_cnt] = (uint8_t *)malloc(CHIAKIFS_BLK_SZ()); \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u30e1\u30e2\u30ea\u306b\u78ba\u4fdd\n            if (chiakiFS_driver_read(CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_cnt]),\n                                     inode-&gt;data&#91;blk_cnt],\n                                     CHIAKIFS_BLK_SZ()) != CHIAKIFS_ERROR_NONE)\n            {\n                CHIAKIFS_DBG(\"&#91;%s] io error\\n\", __func__);\n                return NULL;\n            }\n        }\n    }\n    return inode; \/\/ \u8aad\u307f\u8fbc\u3093\u3060inode\u3092\u8fd4\u3059\n}<\/code><\/pre>\n\n\n\n<p>\u30c7\u30a3\u30b9\u30af\u304b\u3089 inode \u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308a\u307e\u3059\u3002inode \u69cb\u9020\u4f53\u3092\u521d\u671f\u5316\u3057\u3001\u8aad\u307f\u53d6\u3063\u305f\u30c7\u30fc\u30bf\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002inode \u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u3001\u95a2\u9023\u3059\u308b dentry \u3092\u30e1\u30e2\u30ea\u306b\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002inode \u304c\u901a\u5e38\u306e\u30d5\u30a1\u30a4\u30eb\u3067\u3042\u308c\u3070\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u8aad\u307f\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_get_dentry<\/h4>\n\n\n\n<p>inode \u306e dentry \u30ea\u30b9\u30c8\u304b\u3089\u6307\u5b9a\u3055\u308c\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306e dentry \u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief\u3000inode\u306edentrys\u3067\u6b32\u3057\u3044dentry\u3092\u53d6\u5f97\n *\n * @param inode inode\n * @param dir &#91;0...]\n * @return struct chiakiFS_dentry*\n *\/\nstruct chiakiFS_dentry *chiakiFS_get_dentry(struct chiakiFS_inode *inode, int dir)\n{\n    struct chiakiFS_dentry *dentry_cursor = inode-&gt;dentrys;\n    int cnt = 0;\n    while (dentry_cursor)\n    {\n        if (dir == cnt)\n        {\n            return dentry_cursor;\n        }\n        cnt++;\n        dentry_cursor = dentry_cursor-&gt;brother;\n    }\n    return NULL;\n}<\/code><\/pre>\n\n\n\n<p>inode \u306e dentry \u30ea\u30b9\u30c8\u3092\u8d70\u67fb\u3057\u3002\u6307\u5b9a\u3055\u308c\u305f\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u306b\u9054\u3057\u305f\u3089\u3001\u305d\u306e dentry \u3092\u8fd4\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3051\u308c\u3070 NULL \u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_lookup<\/h4>\n\n\n\n<p>\u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9\u3092\u691c\u7d22\u3057\u3001\u5bfe\u5fdc\u3059\u308b dentry \u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief\n * path: \/qwe\/ad  total_lvl = 2,\n *      1) find \/'s inode       lvl = 1\n *      2) find qwe's dentry\n *      3) find qwe's inode     lvl = 2\n *      4) find ad's dentry\n *\n * path: \/qwe     total_lvl = 1,\n *      1) find \/'s inode       lvl = 1\n *      2) find qwe's dentry\n *\n * @param path\n * @return struct chiakiFS_inode*\n *\/\nstruct chiakiFS_dentry *chiakiFS_lookup(const char *path, boolean *is_find, boolean *is_root)\n{\n    struct chiakiFS_dentry *dentry_cursor = chiakiFS_super.root_dentry; \/\/ \u30eb\u30fc\u30c8dentry\u304b\u3089\u63a2\u7d22\u3092\u958b\u59cb\n    struct chiakiFS_dentry *dentry_ret = NULL;\n    struct chiakiFS_inode *inode;\n    int total_lvl = chiakiFS_calc_lvl(path); \/\/ \u30d1\u30b9\u306e\u968e\u5c64\u6570\u3092\u8a08\u7b97\n    int lvl = 0;\n    boolean is_hit;\n    char *fname = NULL;\n    char *path_cpy = (char *)malloc(strlen(path) + 1); \/\/ \u30d1\u30b9\u306e\u30b3\u30d4\u30fc\u3092\u4f5c\u6210\n    *is_root = FALSE;\n    strcpy(path_cpy, path);\n\n    if (total_lvl == 0)\n    { \/* \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea *\/\n        *is_find = TRUE;\n        *is_root = TRUE;\n        dentry_ret = chiakiFS_super.root_dentry;\n    }\n    fname = strtok(path_cpy, \"\/\"); \/\/ \u30d1\u30b9\u3092\u5206\u5272\u3057\u3066\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\n    while (fname)\n    {\n        lvl++;\n        if (dentry_cursor-&gt;inode == NULL)\n        {                                                           \/* Cache\u4ed5\u7d44\u307f *\/\n            chiakiFS_read_inode(dentry_cursor, dentry_cursor-&gt;ino); \/\/ inode\u3092\u8aad\u307f\u8fbc\u3080\n        }\n\n        inode = dentry_cursor-&gt;inode;\n\n        if (CHIAKIFS_IS_REG(inode) &amp;&amp; lvl &lt; total_lvl)\n        {\n            CHIAKIFS_DBG(\"&#91;%s] not a dir\\n\", __func__); \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306f\u306a\u3044\u5834\u5408\n            dentry_ret = inode-&gt;dentry;\n            break;\n        }\n        if (CHIAKIFS_IS_DIR(inode))\n        {\n            dentry_cursor = inode-&gt;dentrys; \/\/ \u5b50dentry\u306b\u79fb\u52d5\n            is_hit = FALSE;\n\n            while (dentry_cursor)\n            {\n                if (strcmp(dentry_cursor-&gt;fname, fname) == 0)\n                {\n                    is_hit = TRUE; \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u304c\u4e00\u81f4\u3059\u308b\u5834\u5408\n                    break;\n                }\n                dentry_cursor = dentry_cursor-&gt;brother; \/\/ \u6b21\u306edentry\u306b\u9032\u3080\n            }\n\n            if (!is_hit)\n            {\n                *is_find = FALSE;\n                CHIAKIFS_DBG(\"&#91;%s] not found %s\\n\", __func__, fname); \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\n                dentry_ret = inode-&gt;dentry;\n                break;\n            }\n\n            if (is_hit &amp;&amp; lvl == total_lvl)\n            {\n                *is_find = TRUE;\n                dentry_ret = dentry_cursor; \/\/ \u6700\u5f8c\u306e\u30ec\u30d9\u30eb\u3067\u4e00\u81f4\u3057\u305f\u5834\u5408\n                break;\n            }\n        }\n        fname = strtok(NULL, \"\/\"); \/\/ \u6b21\u306e\u968e\u5c64\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u9032\u3080\n    }\n\n    if (dentry_ret-&gt;inode == NULL)\n    {\n        dentry_ret-&gt;inode = chiakiFS_read_inode(dentry_ret, dentry_ret-&gt;ino); \/\/ inode\u3092\u8aad\u307f\u8fbc\u3080\n    }\n\n    return dentry_ret;\n}<\/code><\/pre>\n\n\n\n<p>\u30d1\u30b9\u3092 <code>'\/'<\/code> \u3067\u5206\u5272\u3057\u3001\u5404\u30ec\u30d9\u30eb\u306e\u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089\u59cb\u3081\u3066\u3001\u5404\u30ec\u30d9\u30eb\u3067\u5bfe\u5fdc\u3059\u308b dentry \u3092\u691c\u7d22\u3057\u307e\u3059\u3002dentry \u3092\u898b\u3064\u3051\u305f\u5834\u5408\u3001\u305d\u306e inode \u3092\u8aad\u307f\u8fbc\u3080\u304b\u53d6\u5f97\u3057\u307e\u3059\u3002\u6700\u7d42\u7684\u306b\u898b\u3064\u304b\u3063\u305f dentry \u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_mount<\/h4>\n\n\n\n<p>chiakiFS \u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u30de\u30a6\u30f3\u30c8\u3057\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u521d\u671f\u5316\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief chiakiFS\u3092\u30de\u30a6\u30f3\u30c8\u3057\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u30ec\u30a4\u30a2\u30a6\u30c8\u3092\u8a2d\u5b9a\u3059\u308b\n *\n * Layout\n * | Super | Inode Map | Data Block Map | Inode | Data |\n *\n * IO_SZ = BLK_SZ\n *\n * \u5404Inode\u306f1\u3064\u306eBlk\u3092\u5360\u6709\n * @param options \u30de\u30a6\u30f3\u30c8\u30aa\u30d7\u30b7\u30e7\u30f3\n * @return int \u30a8\u30e9\u30fc\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u8fd4\u3059\n *\/\nint chiakiFS_mount(struct custom_options options)\n{\n    int ret = CHIAKIFS_ERROR_NONE;\n    int driver_fd;\n    struct chiakiFS_super_d chiakiFS_super_d;\n    struct chiakiFS_dentry *root_dentry;\n    struct chiakiFS_inode *root_inode;\n\n    int inode_num;\n    int map_inode_blks;\n\n    int data_num;\n    int map_data_blks;\n\n    int super_blks;\n    boolean is_init = FALSE;\n\n    chiakiFS_super.is_mounted = FALSE;\n\n    \/\/ driver_fd = open(options.device, O_RDWR);\n    driver_fd = ddriver_open(options.device); \/\/ \u30c7\u30d0\u30a4\u30b9\u3092\u958b\u304f\n\n    if (driver_fd &lt; 0)\n    {\n        return driver_fd;\n    }\n\n    chiakiFS_super.driver_fd = driver_fd;\n    ddriver_ioctl(CHIAKIFS_DRIVER(), IOC_REQ_DEVICE_SIZE, &amp;chiakiFS_super.sz_disk); \/\/ \u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\u3092\u53d6\u5f97\n    ddriver_ioctl(CHIAKIFS_DRIVER(), IOC_REQ_DEVICE_IO_SZ, &amp;chiakiFS_super.sz_io);  \/\/ IO\u30b5\u30a4\u30ba\u3092\u53d6\u5f97\n    chiakiFS_super.sz_blk = 2 * chiakiFS_super.sz_io;\n\n    root_dentry = new_dentry(\"\/\", CHIAKIFS_DIR); \/\/ \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30eadentry\u3092\u4f5c\u6210\n\n    if (chiakiFS_driver_read(CHIAKIFS_SUPER_OFS, (uint8_t *)(&amp;chiakiFS_super_d),\n                             sizeof(struct chiakiFS_super_d)) != CHIAKIFS_ERROR_NONE)\n    {\n        return -CHIAKIFS_ERROR_IO;\n    }\n    \/* super\u8aad\u8fbc *\/\n    if (chiakiFS_super_d.magic_num != CHIAKIFS_MAGIC)\n    {   \/* \u30de\u30b8\u30c3\u30af\u30ca\u30f3\u30d0\u30fc\u304c\u4e0d\u4e00\u81f4 *\/\n        \/* Layout *\/\n        super_blks = CHIAKIFS_SUPER_BLKS;\n        map_inode_blks = CHIAKIFS_MAP_INODE_BLKS;\n        map_data_blks = CHIAKIFS_MAP_DATA_BLKS;\n        inode_num = CHIAKIFS_INODE_BLKS * CHIAKIFS_INODE_PER_BLOCK;\n        data_num = CHIAKIFS_DATA_BLKS;\n        \/* Layout *\/\n        chiakiFS_super.max_ino = inode_num;\n        chiakiFS_super.max_data = data_num;\n        chiakiFS_super_d.map_inode_offset = CHIAKIFS_SUPER_OFS + CHIAKIFS_BLKS_SZ(super_blks);\n        chiakiFS_super_d.map_data_offset = chiakiFS_super_d.map_inode_offset + CHIAKIFS_BLKS_SZ(map_inode_blks);\n        chiakiFS_super_d.inode_offset = chiakiFS_super_d.map_data_offset + CHIAKIFS_BLKS_SZ(map_data_blks);\n        chiakiFS_super_d.data_offset = chiakiFS_super_d.inode_offset + CHIAKIFS_BLKS_SZ(CHIAKIFS_INODE_BLKS);\n        chiakiFS_super_d.map_inode_blks = map_inode_blks;\n        chiakiFS_super_d.map_data_blks = map_data_blks;\n        chiakiFS_super_d.sz_usage = 0;\n        CHIAKIFS_DBG(\"inode map blocks: %d\\n\", map_inode_blks);\n        is_init = TRUE;\n    }\n    else\n    {\n        chiakiFS_super.max_ino = chiakiFS_super_d.max_ino;\n        chiakiFS_super.max_data = chiakiFS_super_d.max_data;\n    }\n    chiakiFS_super.sz_usage = chiakiFS_super_d.sz_usage; \/* in-memory \u69cb\u9020 *\/\n\n    chiakiFS_super.map_inode = (uint8_t *)malloc(CHIAKIFS_BLKS_SZ(chiakiFS_super_d.map_inode_blks)); \/\/ inode\u30de\u30c3\u30d7\u306e\u30e1\u30e2\u30ea\u3092\u78ba\u4fdd\n    chiakiFS_super.map_inode_blks = chiakiFS_super_d.map_inode_blks;\n    chiakiFS_super.map_inode_offset = chiakiFS_super_d.map_inode_offset;\n    chiakiFS_super.inode_offset = chiakiFS_super_d.inode_offset;\n    chiakiFS_super.map_data = (uint8_t *)malloc(CHIAKIFS_BLKS_SZ(chiakiFS_super_d.map_data_blks)); \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u306e\u30e1\u30e2\u30ea\u3092\u78ba\u4fdd\n    chiakiFS_super.map_data_blks = chiakiFS_super_d.map_data_blks;\n    chiakiFS_super.map_data_offset = chiakiFS_super_d.map_data_offset;\n    chiakiFS_super.data_offset = chiakiFS_super_d.data_offset;\n\n    if (chiakiFS_driver_read(chiakiFS_super_d.map_inode_offset, (uint8_t *)(chiakiFS_super.map_inode),\n                             CHIAKIFS_BLKS_SZ(chiakiFS_super_d.map_inode_blks)) != CHIAKIFS_ERROR_NONE)\n    {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    if (chiakiFS_driver_read(chiakiFS_super_d.map_data_offset, (uint8_t *)(chiakiFS_super.map_data),\n                             CHIAKIFS_BLKS_SZ(chiakiFS_super_d.map_data_blks)) != CHIAKIFS_ERROR_NONE)\n    {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    if (is_init)\n    { \/* \u30eb\u30fc\u30c8inode\u5272\u5f53 *\/\n        root_inode = chiakiFS_alloc_inode(root_dentry);\n        chiakiFS_sync_inode(root_inode); \/\/ \u30eb\u30fc\u30c8inode\u3092\u540c\u671f\n    }\n\n    root_inode = chiakiFS_read_inode(root_dentry, CHIAKIFS_ROOT_INO); \/\/ \u30eb\u30fc\u30c8inode\u3092\u8aad\u307f\u8fbc\u3080\n    root_dentry-&gt;inode = root_inode;\n    chiakiFS_super.root_dentry = root_dentry;\n    chiakiFS_super.is_mounted = TRUE;\n    printf(\"\\n\\nThis is Inode Map:\\n\");\n    chiakiFS_dump_Imap(); \/\/ I\u30de\u30c3\u30d7\u3092\u30c0\u30f3\u30d7\n    printf(\"\\n\\nThis is Data Map:\\n\");\n    chiakiFS_dump_Dmap(); \/\/ D\u30de\u30c3\u30d7\u3092\u30c0\u30f3\u30d7\n    return ret;\n}<\/code><\/pre>\n\n\n\n<p>\u30c7\u30d0\u30a4\u30b9\u3092\u958b\u304d\u3001\u30c7\u30d0\u30a4\u30b9\u306e\u30b5\u30a4\u30ba\u3068 I\/O \u30b5\u30a4\u30ba\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u30b9\u30fc\u30d1\u30fc \u30d6\u30ed\u30c3\u30af\u3092\u8aad\u307f\u8fbc\u307f\u3001\u30de\u30b8\u30c3\u30af\u30ca\u30f3\u30d0\u30fc\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u30de\u30b8\u30c3\u30af\u30ca\u30f3\u30d0\u30fc\u304c\u4e00\u81f4\u3057\u306a\u3044\u5834\u5408\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u521d\u671f\u5316\u3057\u307e\u3059\u3002\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3068\u30aa\u30d5\u30bb\u30c3\u30c8\u3092\u8a2d\u5b9a\u3057\u3001\u30e1\u30e2\u30ea\u306b\u30ed\u30fc\u30c9\u3057\u307e\u3059\u3002\u30eb\u30fc\u30c8 inode \u3092\u8aad\u307f\u8fbc\u307f\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30eb\u30fc\u30c8 dentry \u3068 inode \u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u30de\u30a6\u30f3\u30c8\u72b6\u614b\u306b\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_umount<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u3057\u3001\u30e1\u30e2\u30ea\u5185\u306e\u30c7\u30fc\u30bf\u3092\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u623b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief chiakiFS\u3092\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u3057\u3001\u5fc5\u8981\u306a\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3059\u308b\n *\n * @return int \u30a8\u30e9\u30fc\u30b9\u30c6\u30fc\u30bf\u30b9\u3092\u8fd4\u3059\n *\/\nint chiakiFS_umount()\n{\n    struct chiakiFS_super_d chiakiFS_super_d;\n\n    if (!chiakiFS_super.is_mounted)\n    {\n        return CHIAKIFS_ERROR_NONE;\n    }\n\n    chiakiFS_sync_inode(chiakiFS_super.root_dentry-&gt;inode); \/* \u30eb\u30fc\u3068\u304b\u3089\u5168\u3066\u3092sync *\/\n\n    chiakiFS_super_d.magic_num = CHIAKIFS_MAGIC;\n    chiakiFS_super_d.map_inode_blks = chiakiFS_super.map_inode_blks;\n    chiakiFS_super_d.map_inode_offset = chiakiFS_super.map_inode_offset;\n    chiakiFS_super_d.inode_offset = chiakiFS_super.inode_offset;\n    chiakiFS_super_d.map_data_blks = chiakiFS_super.map_data_blks;\n    chiakiFS_super_d.map_data_offset = chiakiFS_super.map_data_offset;\n    chiakiFS_super_d.data_offset = chiakiFS_super.data_offset;\n    chiakiFS_super_d.sz_usage = chiakiFS_super.sz_usage;\n    chiakiFS_super_d.max_ino = chiakiFS_super.max_ino;\n    chiakiFS_super_d.max_data = chiakiFS_super.max_data;\n    if (chiakiFS_driver_write(CHIAKIFS_SUPER_OFS, (uint8_t *)&amp;chiakiFS_super_d,\n                              sizeof(struct chiakiFS_super_d)) != CHIAKIFS_ERROR_NONE)\n    {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    if (chiakiFS_driver_write(chiakiFS_super_d.map_inode_offset, (uint8_t *)(chiakiFS_super.map_inode),\n                              CHIAKIFS_BLKS_SZ(chiakiFS_super_d.map_inode_blks)) != CHIAKIFS_ERROR_NONE)\n    {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    if (chiakiFS_driver_write(chiakiFS_super_d.map_data_offset, (uint8_t *)(chiakiFS_super.map_data),\n                              CHIAKIFS_BLKS_SZ(chiakiFS_super_d.map_data_blks)) != CHIAKIFS_ERROR_NONE)\n    {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    free(chiakiFS_super.map_inode);   \/\/ inode\u30de\u30c3\u30d7\u3092\u89e3\u653e\n    free(chiakiFS_super.map_data);    \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u3092\u89e3\u653e\n    ddriver_close(CHIAKIFS_DRIVER()); \/\/ \u30c7\u30d0\u30a4\u30b9\u3092\u9589\u3058\u308b\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u304c\u30de\u30a6\u30f3\u30c8\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002\u30eb\u30fc\u30c8 inode \u304b\u3089\u59cb\u3081\u3066\u3001\u3059\u3079\u3066\u306e inode \u3092\u540c\u671f\u3057\u307e\u3059\u3002\u30b9\u30fc\u30d1\u30fc \u30d6\u30ed\u30c3\u30af\u3068\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u30c7\u30a3\u30b9\u30af\u306b\u66f8\u304d\u623b\u3057\u307e\u3059\u3002\u30e1\u30e2\u30ea\u5185\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u89e3\u653e\u3057\u3001\u30c7\u30d0\u30a4\u30b9\u3092\u9589\u3058\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">FUSE\u306e\u30db\u30c3\u30af\u95a2\u6570\u30c7\u30b6\u30a4\u30f3<\/h3>\n\n\n\n<p>\u6b21\u306f\u3001\u5b9f\u73fe\u3055\u308c\u305fFUSE\u30db\u30c3\u30af\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">\/******************************************************************************\n* SECTION: FUSE\u306e\u8af8\u30aa\u30da\u30ec\u30fc\u30b7\u30e7\u30f3\n*******************************************************************************\/\nstatic struct fuse_operations operations = {\n\t.init    = chiakiFS_init,\t\t\t\t\t \/* FS\u3092\u3000MOUNT *\/\t\t\n\t.destroy = chiakiFS_destroy,\t\t\t\t \/* FS\u3092\u3000UNMOUNT *\/\n\t.mkdir   = chiakiFS_mkdir,\t\t\t\t\t \/* MKDIR *\/\n\t.getattr = chiakiFS_getattr,\t\t\t\t \/* STAT\u3068\u4f3c\u3066\u3044\u308b\u3001\u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u53d6\u5f97 *\/\n\t.readdir = chiakiFS_readdir,\t\t\t\t \/* Dentrys\u6dfb\u4ed8*\/\n\t.mknod   = chiakiFS_mknod,\t\t\t\t\t \/* TOUCH\u306e\u5fc5\u8981\u6210\u5206\u3001\u65b0\u898f\u30d5\u30a1\u30a4\u30eb *\/\n\t.write   = chiakiFS_write,\t\t\t\t\t \/* \u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f *\/\n\t.read    = chiakiFS_read,\t\t\t\t\t \/* \u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u8fbc\u307f *\/\n\t.utimens = chiakiFS_utimens,\t\t\t\t \/* TOUCH\u306ePANIC\u3092\u9632\u3050\u305f\u3081\u3001\u6642\u9593\u3092\u66f4\u65b0 *\/\n\t.truncate= chiakiFS_truncate,\t\t\t\t \/* \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u5909\u66f4 *\/\n\t.unlink  = chiakiFS_unlink,\t\t\t\t\t \/* \u30d5\u30a1\u30a4\u30eb\u524a\u9664 *\/\n\t.rmdir\t = chiakiFS_rmdir,\t\t\t\t\t \/* \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u524a\u9664\u3001 rm -r *\/\n\t.rename  = chiakiFS_rename,\t\t\t\t\t \/* \u30ea\u30cd\u30fc\u30e0\uff0cmv *\/\n    .symlink = chiakiFS_symlink,                 \/* \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af, ln -s*\/\n    .link    = chiakiFS_link,                    \/* \u30cf\u30fc\u30c9\u30ea\u30f3\u30af, link*\/\n    .readlink= chiakiFS_readlink,                \/* \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u89e3\u6790, readlink*\/\n\t.open    = chiakiFS_open,\t\t\t\t\t \/* \u30d5\u30a1\u30a4\u30eb \u30aa\u30fc\u30d7\u30f3 *\/\n\t.opendir = chiakiFS_opendir,\t\t\t\t \/* \u30c7\u30a3\u30ec\u30af\u30c8\u30ea \u30aa\u30fc\u30d7\u30f3 *\/\n\t.access  = chiakiFS_access\t\t\t\t\t \/* \u30a2\u30af\u30bb\u30b9\u3000\u30db\u30c3\u30af *\/\n};<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_init<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30de\u30a6\u30f3\u30c8\u6642\u306b\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief FS\u3092\u3000MOUNT\n * \n * @param conn_info \u63a5\u7d9a\u306e\u78ba\u7acb\u306b\u95a2\u3059\u308b\u3001\u7121\u8996\u3067\u3044\u3044\n * @return void*\n *\/\nvoid* chiakiFS_init(struct fuse_conn_info * conn_info) {\n\t\/* TODO: \u3053\u3053\u3067\u3000MOUNT *\/\n\tif (chiakiFS_mount(chiakiFS_options) != CHIAKIFS_ERROR_NONE) {\n        CHIAKIFS_DBG(\"&#91;%s] mount error\\n\", __func__);\n\t\tfuse_exit(fuse_get_context()-&gt;fuse);\n\t\treturn NULL;\n\t} \n\treturn NULL;\n\t\/* \u30c7\u30d0\u30a4\u30b9\u306e\u5236\u5fa1\u4f8b *\/\n\t\/\/super.fd = ddriver_open(chiakiFS_options.device);\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_mount(&amp;chiakiFS_options)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30de\u30a6\u30f3\u30c8\u64cd\u4f5c\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u30de\u30a6\u30f3\u30c8\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u3001<code>fuse_exit<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066FUSE\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002<code>NULL<\/code> \u3092\u8fd4\u3059\u3053\u3068\u3067\u521d\u671f\u5316\u304c\u5b8c\u4e86\u3057\u305f\u3053\u3068\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_destroy<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u6642\u306b\u547c\u3073\u51fa\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief FS\u3092\u3000UNMOUNT\n * \n * @param p \u7121\u8996\u3067\u3044\u3044\n * @return void\n *\/\nvoid chiakiFS_destroy(void* p) {\n\t\/* TODO: \u3053\u3053\u3067\u3000UNMOUNT *\/\n\t\tif (chiakiFS_umount() != CHIAKIFS_ERROR_NONE) {\n\t\tCHIAKIFS_DBG(\"&#91;%s] unmount error\\n\", __func__);\n\t\tfuse_exit(fuse_get_context()-&gt;fuse);\n\t\treturn;\n\t}\n\t\/\/ddriver_close(super.fd);\n\treturn;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_umount()<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u64cd\u4f5c\u3092\u5b9f\u884c\u3057\u307e\u3059\u3002\u30a2\u30f3\u30de\u30a6\u30f3\u30c8\u306b\u5931\u6557\u3057\u305f\u5834\u5408\u3001<code>fuse_exit<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066FUSE\u3092\u7d42\u4e86\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_mkdir<\/h4>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief MKDIR\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u3092\u57fa\u6e96\u3068\u3057\u305f\u76f8\u5bfe\u30d1\u30b9\n * @param mode \u30e2\u30fc\u30c9\uff08READONLY\uff1f\u3000WRITEONLY\uff1f\uff09\uff0c\u7121\u8996\u3067\u3044\u3044\n * @return int \u6210\u529f\u306a\u30890\uff08CHIAKIFS_ERROR_NONE\uff09\uff0c\u5426\u3068\u3001\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_mkdir(const char* path, mode_t mode) {\n\t\/* TODO: \u30d1\u30b9\u3092\u89e3\u6790\uff0c\u65b0\u898f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u4f5c\u308b *\/\n\t(void)mode; \/\/ \u30e2\u30fc\u30c9\u306f\u4f7f\u7528\u3057\u306a\u3044\n\tboolean is_find, is_root; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u691c\u7d22\u7d50\u679c\u3092\u4fdd\u5b58\n\tchar* fname; \/\/ \u65b0\u3057\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u540d\u524d\n\tstruct chiakiFS_dentry* last_dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root); \/\/ \u30d1\u30b9\u306b\u57fa\u3065\u3044\u3066\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n\tstruct chiakiFS_dentry* dentry; \/\/ \u65b0\u898f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\n\tstruct chiakiFS_inode*  inode; \/\/ \u65b0\u898f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306einode\n\n\tif (is_find) { \/\/ \u3059\u3067\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\n\t\treturn -CHIAKIFS_ERROR_EXISTS;\n\t}\n\n\tif (CHIAKIFS_IS_REG(last_dentry-&gt;inode)) { \/\/ \u6700\u5f8c\u306e\u30a8\u30f3\u30c8\u30ea\u304c\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\u306f\u30a8\u30e9\u30fc\n\t\treturn -CHIAKIFS_ERROR_UNSUPPORTED;\n\t}\n\n\tfname  = chiakiFS_get_fname(path); \/\/ \u65b0\u3057\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u3092\u53d6\u5f97\n\tdentry = new_dentry(fname, CHIAKIFS_DIR); \/\/ \u65b0\u3057\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u4f5c\u6210\n\tdentry-&gt;parent = last_dentry; \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8a2d\u5b9a\n\tinode  = chiakiFS_alloc_inode(dentry); \/\/ \u65b0\u3057\u3044inode\u3092\u5272\u308a\u5f53\u3066\n    inode -&gt; link_cnt = 2;              \/\/\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30ea\u30f3\u30af\u6570\u306f\uff12\n\tchiakiFS_alloc_dentry(last_dentry-&gt;inode, dentry, TRUE); \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u65b0\u3057\u3044\u30a8\u30f3\u30c8\u30ea\u3092\u8ffd\u52a0\n\tlast_dentry-&gt;inode-&gt;link_cnt++;\n    chiakiFS_sync_inode(last_dentry-&gt;inode);\n\treturn CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306edentry\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u65b0\u3057\u3044dentry\u3068inode\u3092\u4f5c\u6210\u3057\u3001\u305d\u308c\u3092\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_getattr<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5c5e\u6027\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5c5e\u6027\u3092\u53d6\u5f97\u3059\u308b\u3001\u975e\u5e38\u306b\u91cd\u8981\uff01\uff01\uff01\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param chiakiFS_stat \u30b9\u30c6\u30fc\u30bf\u30b9\u306e\u8fd4\u308a\n * @return int \u6210\u529f\u306a\u30890\u3001\u5426\u3068\u3001\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_getattr(const char* path, struct stat * chiakiFS_stat) {\n\t\/* TODO: \u30d1\u30b9\u3092\u89e3\u6790\u3057\u3066Inode\u3092\u53d6\u5f97\u3057\u3001chiakiFS_stat\u3092\u8a2d\u5b9a\u3059\u308b\u3002\/fs\/simplefs\/sfs.c\u306esfs_getattr()\u95a2\u6570\u306e\u5b9f\u88c5\u3092\u53c2\u8003\u306b\u3067\u304d\u308b *\/\n\tboolean\tis_find, is_root; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u691c\u7d22\u7d50\u679c\u3092\u4fdd\u5b58\n\tstruct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root); \/\/ \u30d1\u30b9\u306b\u57fa\u3065\u3044\u3066\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n\tif (is_find == FALSE) { \/\/ \u30a8\u30f3\u30c8\u30ea\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\n\t\treturn -CHIAKIFS_ERROR_NOTFOUND;\n\t}\n\n\tif (CHIAKIFS_IS_DIR(dentry-&gt;inode)) { \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\n\t\tchiakiFS_stat-&gt;st_mode = S_IFDIR | CHIAKIFS_DEFAULT_PERM;\n\t\tchiakiFS_stat-&gt;st_size = dentry-&gt;inode-&gt;dir_cnt * sizeof(struct chiakiFS_dentry_d); \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30b5\u30a4\u30ba\u3092\u8a2d\u5b9a\n\t}\n\telse if (CHIAKIFS_IS_REG(dentry-&gt;inode)) { \/\/ \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\n\t\tchiakiFS_stat-&gt;st_mode = S_IFREG | CHIAKIFS_DEFAULT_PERM;\n\t\tchiakiFS_stat-&gt;st_size = dentry-&gt;inode-&gt;size; \/\/ \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u8a2d\u5b9a\n\t}\n\telse if (CHIAKIFS_IS_SYM_LINK(dentry-&gt;inode)) { \/\/ \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u306e\u5834\u5408\n\t\tchiakiFS_stat-&gt;st_mode = S_IFLNK | CHIAKIFS_DEFAULT_PERM;\n\t\tchiakiFS_stat-&gt;st_size = dentry-&gt;inode-&gt;size; \/\/ \u30ea\u30f3\u30af\u30b5\u30a4\u30ba\u3092\u8a2d\u5b9a\n\t}\n\n\tchiakiFS_stat-&gt;st_uid \t= getuid(); \/\/ \u30e6\u30fc\u30b6\u30fcID\n\tchiakiFS_stat-&gt;st_gid \t= getgid(); \/\/ \u30b0\u30eb\u30fc\u30d7ID\n\tchiakiFS_stat-&gt;st_atime = time(NULL); \/\/ \u30a2\u30af\u30bb\u30b9\u6642\u9593\n\tchiakiFS_stat-&gt;st_mtime = time(NULL); \/\/ \u66f4\u65b0\u6642\u9593\n\n\tchiakiFS_stat-&gt;st_blksize = CHIAKIFS_BLK_SZ(); \/\/ \u8ad6\u7406\u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\n    chiakiFS_stat-&gt;st_ino   = dentry-&gt;inode-&gt;ino; \/\/ Inode\u756a\u53f7\n    chiakiFS_stat-&gt;st_nlink = dentry-&gt;inode-&gt;link_cnt; \/\/ \u30ea\u30f3\u30af\u6570\n\n\tif (is_root) { \/\/ \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\n\t\tchiakiFS_stat-&gt;st_size\t= chiakiFS_super.sz_usage; \n\t\tchiakiFS_stat-&gt;st_blocks = CHIAKIFS_DISK_SZ() \/ CHIAKIFS_BLK_SZ(); \/\/ \u7dcf\u30d6\u30ed\u30c3\u30af\u6570\n\t\tchiakiFS_stat-&gt;st_nlink  = 2; \/\/ \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30ea\u30f3\u30af\u6570\u306f2\n\t}\n\treturn CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002dentry\u306e\u7a2e\u985e\u306b\u57fa\u3065\u3044\u3066stat\u69cb\u9020\u4f53\u306e\u5404\u30d5\u30a3\u30fc\u30eb\u30c9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_readdir<\/h4>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5185\u5bb9\u3092\u8aad\u307f\u53d6\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u8d70\u67fb\u3057\u3001\u30d0\u30c3\u30d5\u30a1\u306b\u633f\u5165\u3057\u3001FUSE\u306b\u6e21\u3059\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param buf \u51fa\u529b\u30d0\u30c3\u30d5\u30a1\n * @param filler \u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u8aac\u660e:\n * \n * typedef int (*fuse_fill_dir_t) (void *buf, const char *name,\n *\t\t\t\tconst struct stat *stbuf, off_t off)\n * buf: name\u304cbuf\u306b\u30b3\u30d4\u30fc\u3055\u308c\u308b\n * name: dentry\u306e\u540d\u524d\n * stbuf: \u30d5\u30a1\u30a4\u30eb\u306e\u30b9\u30c6\u30fc\u30bf\u30b9\u3001\u7121\u8996\u3067\u304d\u308b\n * off: \u6b21\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\u3001\u3053\u3053\u306f\u4f55\u756a\u76ee\u306edentry\u304b\u3092\u7406\u89e3\u3067\u3044\u3044\n * \n * @param offset \u4f55\u756a\u76ee\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\n * @param fi \u7121\u8996\u3067\u304d\u308b\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_readdir(const char * path, void * buf, fuse_fill_dir_t filler, off_t offset,\n\t\t\t    \t\t struct fuse_file_info * fi) {\n    \/* TODO: \/fs\/simplefs\/sfs.c\u306esfs_readdir()\u95a2\u6570\u306e\u5b9f\u88c5\u3092\u53c2\u8003\u306b\u3067\u304d\u308b *\/\n    boolean\tis_find, is_root; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u691c\u7d22\u7d50\u679c\u3092\u4fdd\u5b58\n\tint\t\tcur_dir = offset; \/\/ \u73fe\u5728\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u306e\u4f4d\u7f6e\n\n\tstruct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root); \/\/ \u30d1\u30b9\u306b\u57fa\u3065\u3044\u3066\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n\tstruct chiakiFS_dentry* sub_dentry; \/\/ \u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\n\tstruct chiakiFS_inode* inode; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306einode\n\tif (is_find) { \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u898b\u3064\u304b\u3063\u305f\u5834\u5408\n\t\tinode = dentry-&gt;inode; \n\t\tsub_dentry = chiakiFS_get_dentry(inode, cur_dir); \/\/ \u73fe\u5728\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u4f4d\u7f6e\u304b\u3089\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u53d6\u5f97\n\t\tif (sub_dentry) {\n\t\t\tfiller(buf, sub_dentry-&gt;fname, NULL, ++offset); \/\/ \u30d0\u30c3\u30d5\u30a1\u306b\u30b5\u30d6\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u3092\u633f\u5165\n\t\t}\n\t\treturn CHIAKIFS_ERROR_NONE;\n\t}\n\treturn -CHIAKIFS_ERROR_NOTFOUND;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u5185\u306edentry\u3092\u5de1\u56de\u3057\u3001filler\u95a2\u6570\u3092\u4f7f\u3063\u3066\u30e6\u30fc\u30b6\u30fc\u30d0\u30c3\u30d5\u30a1\u306b\u5185\u5bb9\u3092\u57cb\u3081\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_mknod<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u30ce\u30fc\u30c9\uff08\u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\uff09\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u65b0\u898f\u30d5\u30a1\u30a4\u30eb\u4f5c\u6210\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param mode \u30e2\u30fc\u30c9\uff08READONLY\uff1f\u3000WRITEONLY\uff1f\uff09\uff0c\u7121\u8996\u3067\u3044\u3044\n * @param dev \u30c7\u30d0\u30a4\u30b9\u30bf\u30a4\u30d7\u3001\u7121\u8996\u3067\u3044\u3044\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_mknod(const char* path, mode_t mode, dev_t dev) {\n\t\/* TODO: \u30d1\u30b9\u3092\u89e3\u6790\u3001\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210 *\/\n\tboolean\tis_find, is_root; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u691c\u7d22\u7d50\u679c\u3092\u4fdd\u5b58\n\t\n\tstruct chiakiFS_dentry* last_dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root); \/\/ \u30d1\u30b9\u306b\u57fa\u3065\u3044\u3066\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n\tstruct chiakiFS_dentry* dentry; \/\/ \u65b0\u898f\u30d5\u30a1\u30a4\u30eb\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\n\tstruct chiakiFS_inode* inode; \/\/ \u65b0\u898f\u30d5\u30a1\u30a4\u30eb\u306einode\n\tchar* fname; \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\n\t\n\tif (is_find == TRUE) { \/\/ \u3059\u3067\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\n\t\treturn -CHIAKIFS_ERROR_EXISTS;\n\t}\n\n\tfname = chiakiFS_get_fname(path); \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u3092\u53d6\u5f97\n\t\n\tif (S_ISREG(mode)) { \/\/ \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\n\t\tdentry = new_dentry(fname, CHIAKIFS_REG_FILE);\n\t}\n\telse if (S_ISDIR(mode)) { \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\n\t\tdentry = new_dentry(fname, CHIAKIFS_DIR);\n\t}\n\telse { \/\/ \u305d\u306e\u4ed6\u306e\u5834\u5408\n\t\tdentry = new_dentry(fname, CHIAKIFS_REG_FILE);\n\t}\n\tdentry-&gt;parent = last_dentry; \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u8a2d\u5b9a\n\tinode = chiakiFS_alloc_inode(dentry); \/\/ \u65b0\u3057\u3044inode\u3092\u5272\u308a\u5f53\u3066\n    inode -&gt; link_cnt = 1;\n\tchiakiFS_alloc_dentry(last_dentry-&gt;inode, dentry, TRUE); \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u65b0\u3057\u3044\u30a8\u30f3\u30c8\u30ea\u3092\u8ffd\u52a0\n\n\treturn CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u30e2\u30fc\u30c9\u306b\u57fa\u3065\u3044\u3066\u65b0\u3057\u3044dentry\u3068inode\u3092\u4f5c\u6210\u3057\u3001\u305d\u308c\u3092\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_utimens<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief TOUCH\u306ePANIC\u3092\u9632\u3050\u305f\u3081\u3001\u6642\u9593\u3092\u66f4\u65b0\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param tv \u6642\u9593\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_utimens(const char* path, const struct timespec tv&#91;2]) {\n\t(void)path;\n\treturn 0;\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_write<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u66f8\u304d\u8fbc\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param buf \u66f8\u304d\u8fbc\u3080\u5185\u5bb9\n * @param size \u66f8\u304d\u8fbc\u3080\u30b5\u30a4\u30ba\uff08Byte\uff09\n * @param offset \u30d5\u30a1\u30a4\u30eb\u5bfe\u3059\u308b\u66f8\u304d\u8fbc\u307f\u30aa\u30d5\u30bb\u30c3\u30c8\n * @param fi \u7121\u8996\u3067\u3044\u3044\n * @return int \u66f8\u304d\u8fbc\u307e\u308c\u305f\u30b5\u30a4\u30ba\n *\/\nint chiakiFS_write(const char* path, const char* buf, size_t size, off_t offset,\n                   struct fuse_file_info* fi) {\n    boolean is_find, is_root;\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root); \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u53d6\u5f97\n    struct chiakiFS_inode* inode;\n    int bytes_written = 0;\n\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND; \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n    }\n\n    if (CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_ISDIR; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u306e\u66f8\u304d\u8fbc\u307f\u306f\u30a8\u30e9\u30fc\n    }\n\n    inode = dentry-&gt;inode;\n    if (inode == NULL) {\n        inode = chiakiFS_read_inode(dentry, dentry-&gt;ino); \/\/ inode\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u8aad\u307f\u8fbc\u3080\n        if (inode == NULL) {\n            return -CHIAKIFS_ERROR_IO; \/\/ \u8aad\u307f\u8fbc\u307f\u5931\u6557\u6642\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n        }\n        dentry-&gt;inode = inode;\n    }\n\n    \/\/ inode\u306b\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u308a\u5f53\u3066\u308b\u5fc5\u8981\u304c\u3042\u308b\u304b\u78ba\u8a8d\n    size_t end_offset = offset + size;\n    size_t required_blocks = CHIAKIFS_ROUND_UP(end_offset, CHIAKIFS_BLK_SZ()) \/ CHIAKIFS_BLK_SZ();\n    if (required_blocks &gt; CHIAKIFS_DATA_PER_FILE) {\n        return -CHIAKIFS_ERROR_NOSPACE; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304c\u8db3\u308a\u306a\u3044\u5834\u5408\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n    }\n\n    \/\/ \u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u308a\u5f53\u3066\u308b\n    for (int blk_idx = 0; blk_idx &lt; required_blocks; blk_idx++) {\n        if (inode-&gt;dblk&#91;blk_idx] == 0) {\n            \/\/ \u65b0\u3057\u3044\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u308a\u5f53\u3066\u308b\u5fc5\u8981\u304c\u3042\u308b\u5834\u5408\n            int byte_cursor = 0;\n            int bit_cursor = 0;\n            int dno_cursor = 0;\n            boolean is_find_free_blk = FALSE;\n            for (byte_cursor = 0; byte_cursor &lt; CHIAKIFS_BLKS_SZ(chiakiFS_super.map_data_blks); byte_cursor++) {\n                for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n                    if ((chiakiFS_super.map_data&#91;byte_cursor] &amp; (0x1 &lt;&lt; bit_cursor)) == 0) {\n                        \/\/ \u7a7a\u304d\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u898b\u3064\u3051\u305f\u5834\u5408\n                        chiakiFS_super.map_data&#91;byte_cursor] |= (0x1 &lt;&lt; bit_cursor);\n                        inode-&gt;dblk&#91;blk_idx] = dno_cursor;\n                        is_find_free_blk = TRUE;\n                        break;\n                    }\n                    dno_cursor++;\n                }\n                if (is_find_free_blk) {\n                    break;\n                }\n            }\n            if (!is_find_free_blk || dno_cursor &gt;= chiakiFS_super.max_data) {\n                return -CHIAKIFS_ERROR_NOSPACE; \/\/ \u7a7a\u304d\u30d6\u30ed\u30c3\u30af\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n            }\n            \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30e1\u30e2\u30ea\u3092\u78ba\u4fdd\n            inode-&gt;data&#91;blk_idx] = (uint8_t*)malloc(CHIAKIFS_BLK_SZ());\n            memset(inode-&gt;data&#91;blk_idx], 0, CHIAKIFS_BLK_SZ()); \/\/ \u521d\u671f\u5316\n        }\n    }\n\n    \/\/ inode\u306e\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306b\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\n    size_t bytes_to_write = size;\n    size_t buf_offset = 0;\n    size_t file_offset = offset;\n\n    while (bytes_to_write &gt; 0) {\n        int blk_idx = file_offset \/ CHIAKIFS_BLK_SZ();\n        int blk_offset = file_offset % CHIAKIFS_BLK_SZ();\n        size_t bytes_in_blk = CHIAKIFS_BLK_SZ() - blk_offset;\n        size_t bytes_this_round = (bytes_to_write &lt; bytes_in_blk) ? bytes_to_write : bytes_in_blk;\n\n        memcpy(inode-&gt;data&#91;blk_idx] + blk_offset, buf + buf_offset, bytes_this_round); \/\/ \u30c7\u30fc\u30bf\u30b3\u30d4\u30fc\n\n        bytes_written += bytes_this_round;\n        bytes_to_write -= bytes_this_round;\n        buf_offset += bytes_this_round;\n        file_offset += bytes_this_round;\n    }\n\n    \/\/ \u5fc5\u8981\u306b\u5fdc\u3058\u3066inode\u306e\u30b5\u30a4\u30ba\u3092\u66f4\u65b0\n    if (file_offset &gt; inode-&gt;size) {\n        inode-&gt;size = file_offset;\n    }\n\n    \/\/ inode\u3092\u30de\u30fc\u30af\u3057\u3066\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\n    if (chiakiFS_sync_inode(inode) != CHIAKIFS_ERROR_NONE) {\n        return -CHIAKIFS_ERROR_IO; \/\/ \u540c\u671f\u30a8\u30e9\u30fc\u306e\u51e6\u7406\n    }\n\n    return bytes_written; \/\/ \u66f8\u304d\u8fbc\u307e\u308c\u305f\u30d0\u30a4\u30c8\u6570\u3092\u8fd4\u3059\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3002\u8aad\u307f\u53d6\u308a\u5931\u6557\u6642\u3082\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3002<br>\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u308a\u5f53\u3066\u3001\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u307f\u3002\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<br><code>chiakiFS_sync_inode(inode)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066inode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_read<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3092\u8aad\u307f\u53d6\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u8aad\u8fbc\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param buf \u8aad\u8fbc\u5185\u5bb9\n * @param size \u8aad\u8fbc\u30b5\u30a4\u30ba\n * @param offset \u30d5\u30a1\u30a4\u30eb\u5bfe\u3059\u308b\u8aad\u8fbc\u30aa\u30d5\u30bb\u30c3\u30c8\n * @param fi \u7121\u8996\u3067\u3044\u3044\n * @return int \u8aad\u8fbc\u307e\u308c\u305f\u30b5\u30a4\u30ba\n *\/\nint chiakiFS_read(const char* path, char* buf, size_t size, off_t offset,\n                  struct fuse_file_info* fi) {\n    boolean is_find, is_root;\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root); \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u30a8\u30f3\u30c8\u30ea\u3092\u53d6\u5f97\n    struct chiakiFS_inode* inode;\n    int bytes_read = 0;\n\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND; \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n    }\n\n    if (CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_ISDIR; \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u306e\u8aad\u307f\u8fbc\u307f\u306f\u30a8\u30e9\u30fc\n    }\n\n    inode = dentry-&gt;inode;\n    if (inode == NULL) {\n        inode = chiakiFS_read_inode(dentry, dentry-&gt;ino); \/\/ inode\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u306f\u8aad\u307f\u8fbc\u3080\n        if (inode == NULL) {\n            return -CHIAKIFS_ERROR_IO; \/\/ \u8aad\u307f\u8fbc\u307f\u5931\u6557\u6642\u306e\u30a8\u30e9\u30fc\u30cf\u30f3\u30c9\u30ea\u30f3\u30b0\n        }\n        dentry-&gt;inode = inode;\n    }\n\n    if (offset &gt;= inode-&gt;size) {\n        \/\/ \u30aa\u30d5\u30bb\u30c3\u30c8\u304c\u30b5\u30a4\u30ba\u4e0a\u9650\u3092\u8d85\u3048\u3066\u3044\u308b\u5834\u5408\u306f0\u3092\u8fd4\u3059\n        return 0;\n    }\n\n    size_t bytes_to_read = (offset + size &gt; inode-&gt;size) ? (inode-&gt;size - offset) : size; \/\/ \u8aad\u307f\u8fbc\u3080\u30d0\u30a4\u30c8\u6570\u3092\u6c7a\u5b9a\n    size_t buf_offset = 0;\n    size_t file_offset = offset;\n\n    while (bytes_to_read &gt; 0) {\n        int blk_idx = file_offset \/ CHIAKIFS_BLK_SZ();\n        int blk_offset = file_offset % CHIAKIFS_BLK_SZ();\n        size_t bytes_in_blk = CHIAKIFS_BLK_SZ() - blk_offset;\n        size_t bytes_this_round = (bytes_to_read &lt; bytes_in_blk) ? bytes_to_read : bytes_in_blk;\n\n        if (inode-&gt;data&#91;blk_idx] == NULL) {\n            \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u30c7\u30a3\u30b9\u30af\u304b\u3089\u30ed\u30fc\u30c9\n            inode-&gt;data&#91;blk_idx] = (uint8_t*)malloc(CHIAKIFS_BLK_SZ());\n            if (chiakiFS_driver_read(CHIAKIFS_DATA_OFS(inode-&gt;dblk&#91;blk_idx]),\n                                     inode-&gt;data&#91;blk_idx],\n                                     CHIAKIFS_BLK_SZ()) != CHIAKIFS_ERROR_NONE) {\n                return -CHIAKIFS_ERROR_IO; \/\/ \u8aad\u307f\u8fbc\u307f\u30a8\u30e9\u30fc\u306e\u51e6\u7406\n            }\n        }\n\n        memcpy(buf + buf_offset, inode-&gt;data&#91;blk_idx] + blk_offset, bytes_this_round); \/\/ \u30c7\u30fc\u30bf\u30b3\u30d4\u30fc\n\n        bytes_read += bytes_this_round;\n        bytes_to_read -= bytes_this_round;\n        buf_offset += bytes_this_round;\n        file_offset += bytes_this_round;\n    }\n\n    return bytes_read; \/\/ \u8aad\u307f\u8fbc\u307e\u308c\u305f\u30d0\u30a4\u30c8\u6570\u3092\u8fd4\u3059\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3002\u8aad\u307f\u53d6\u308a\u5931\u6557\u6642\u3082\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3002<br>\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u304b\u3089\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u53d6\u308a\u30d0\u30a4\u30c8\u6570\u3001\u30e6\u30fc\u30b6\u30fc\u306b\u8fd4\u3057\u307e\u3059\u3002<br><code>chiakiFS_driver_read<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u5185\u5bb9\u3092\u8aad\u307f\u53d6\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_unlink<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u524a\u9664\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_unlink(const char* path) {\n    boolean is_find, is_root;\n    \/\/ \u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n    struct chiakiFS_dentry* parent_dentry;\n    struct chiakiFS_inode* parent_inode;\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3051\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND;\n    }\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\u306f\u524a\u9664\u4e0d\u53ef\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    if (CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_ISDIR;\n    }\n\n    parent_dentry = dentry-&gt;parent;\n    parent_inode = parent_dentry-&gt;inode;\n    \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u30ea\u30b9\u30c8\u304b\u3089\u30a8\u30f3\u30c8\u30ea\u3092\u524a\u9664\n    if (chiakiFS_drop_dentry(parent_inode, dentry) &lt; 0) {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\t\/\/ inode\u306e\u30ea\u30f3\u30af\u6570\u3092\u30c7\u30af\u30ea\u30e1\u30f3\u30c8\n\tdentry-&gt;inode-&gt;link_cnt--;\n\tif (dentry-&gt;inode-&gt;link_cnt == 0) {\n\t    \/\/ \u30ea\u30f3\u30af\u6570\u304c0\u306b\u306a\u3063\u305f\u3089inode\u3092\u89e3\u653e\n\t    if (chiakiFS_drop_inode(dentry-&gt;inode) != CHIAKIFS_ERROR_NONE) {\n\t        return -CHIAKIFS_ERROR_IO;\n\t    }\n\t} else {\n\t    \/\/ \u305d\u3046\u3067\u306a\u3051\u308c\u3070inode\u3092\u540c\u671f\n\t    if (chiakiFS_sync_inode(dentry-&gt;inode) != CHIAKIFS_ERROR_NONE) {\n\t        return -CHIAKIFS_ERROR_IO;\n\t    }\n\t}\n\n    free(dentry); \/\/ dentry\u306e\u30e1\u30e2\u30ea\u3092\u89e3\u653e\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u3002<br>\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089dentry\u3092\u524a\u9664\u3057\u307e\u3059\u3002\u95a2\u9023\u3059\u308binode\u3068\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\u3057\u307e\u3059\u3002<br><code>chiakiFS_sync_inode(parent_inode)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u89aainode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_rmdir<\/h4>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u524a\u9664\n * \n * \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u524a\u9664\u306f\u6b21\u306e\u901a\u308a\u3067\u3044\u3044\uff1a\n * rm .\/tests\/mnt\/j\/ -r\n *  1) Step 1. rm .\/tests\/mnt\/j\/j\n *  2) Step 2. rm .\/tests\/mnt\/j\n * \u307e\u305a\u306f\u4e2d\u306e\u3082\u306e\u3092\u524a\u9664\u3001\u305d\u3093\u3067\u3053\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u524a\u9664\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_rmdir(const char* path) {\n    boolean is_find, is_root;\n    \/\/ \u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n    struct chiakiFS_dentry* parent_dentry;\n    struct chiakiFS_inode* parent_inode;\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u898b\u3064\u304b\u3089\u306a\u3051\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND;\n    }\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u306e\u5834\u5408\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u524a\u9664\u4e0d\u53ef\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    if (!CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_NOTDIR;\n    }\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u7a7a\u3067\u306a\u3044\u5834\u5408\u306f\u524a\u9664\u4e0d\u53ef\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    if (dentry-&gt;inode-&gt;dir_cnt &gt; 0) {\n        return -ENOTEMPTY;\n    }\n\n    parent_dentry = dentry-&gt;parent;\n    parent_inode = parent_dentry-&gt;inode;\n    \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u30ea\u30b9\u30c8\u304b\u3089\u30a8\u30f3\u30c8\u30ea\u3092\u524a\u9664\n    if (chiakiFS_drop_dentry(parent_inode, dentry) &lt; 0) {\n        return -CHIAKIFS_ERROR_IO;\n    }\n    \/\/ inode\u3068\u95a2\u9023\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u89e3\u653e\n    if (chiakiFS_drop_inode(dentry-&gt;inode) != CHIAKIFS_ERROR_NONE) {\n        return -CHIAKIFS_ERROR_IO;\n    }\n    \/\/ \u89aainode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\n    if (chiakiFS_sync_inode(parent_inode) != CHIAKIFS_ERROR_NONE) {\n        return -CHIAKIFS_ERROR_IO;\n    }\n    parent_inode-&gt;link_cnt--;\n    chiakiFS_sync_inode(parent_inode);\n    free(dentry); \/\/ dentry\u306e\u30e1\u30e2\u30ea\u3092\u89e3\u653e\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u7a7a\u3067\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089dentry\u3092\u524a\u9664\u3057\u307e\u3059\u3002\u95a2\u9023\u3059\u308binode\u3068\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\u3057\u307e\u3059\u3002<br><code>chiakiFS_sync_inode(parent_inode)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u89aainode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_rename<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u307e\u305f\u306f\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u540d\u524d\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30ea\u30cd\u30fc\u30e0\n * \n * @param from \u30bd\u30fc\u30b9\u30d1\u30b9\n * @param to \u30c7\u30b9\u30c6\u30a3\u30cd\u30fc\u30b7\u30e7\u30f3\u30d1\u30b9\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_rename(const char* from, const char* to) {\n    boolean is_find_from, is_root_from;\n    boolean is_find_to, is_root_to;\n    \/\/ \u30bd\u30fc\u30b9\u30d1\u30b9\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\u3092\u691c\u7d22\n    struct chiakiFS_dentry* dentry_from = chiakiFS_lookup(from, &amp;is_find_from, &amp;is_root_from);\n    struct chiakiFS_dentry* dentry_to_parent;\n    struct chiakiFS_inode* parent_inode_from;\n    struct chiakiFS_inode* parent_inode_to;\n    char* to_name;\n\n    \/\/ \u30bd\u30fc\u30b9\u304c\u5b58\u5728\u3057\u306a\u3044\u5834\u5408\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    if (!is_find_from) {\n        return -CHIAKIFS_ERROR_NOTFOUND;\n    }\n    \/\/ \u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u304c\u3059\u3067\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n    chiakiFS_lookup(to, &amp;is_find_to, &amp;is_root_to);\n    if (is_find_to) {\n        return -CHIAKIFS_ERROR_EXISTS;\n    }\n    \/\/ \u30c7\u30b9\u30c6\u30a3\u30cd\u30fc\u30b7\u30e7\u30f3\u306e\u89aainode\u3092\u53d6\u5f97\n    char* to_parent_path = strdup(to);\n    to_name = strrchr(to_parent_path, '\/');\n    if (to_name == NULL) {\n        dentry_to_parent = chiakiFS_super.root_dentry;\n        to_name = to_parent_path;\n    } else {\n        *to_name = '\\0';\n        to_name++;\n\n        \/\/ \u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\n        if (strlen(to_parent_path) == 0) {\n            dentry_to_parent = chiakiFS_super.root_dentry;\n        } else {\n            \/\/ \u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u691c\u7d22\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306a\u3044\u5834\u5408\u306f\u30a8\u30e9\u30fc\u3092\u8fd4\u3059\n            dentry_to_parent = chiakiFS_lookup(to_parent_path, &amp;is_find_to, &amp;is_root_to);\n            if (!is_find_to || !CHIAKIFS_IS_DIR(dentry_to_parent-&gt;inode)) {\n                free(to_parent_path);\n                return -CHIAKIFS_ERROR_NOTDIR;\n            }\n        }\n    }\n\n    parent_inode_from = dentry_from-&gt;parent-&gt;inode;\n    parent_inode_to = dentry_to_parent-&gt;inode;\n    \/\/ \u53e4\u3044\u89aa\u306edentry\u30ea\u30b9\u30c8\u304b\u3089\u30a8\u30f3\u30c8\u30ea\u3092\u524a\u9664\n    if (chiakiFS_drop_dentry(parent_inode_from, dentry_from) &lt; 0) {\n        free(to_parent_path);\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    \/\/ dentry\u306e\u540d\u524d\u3068\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u66f4\u65b0\n    memset(dentry_from-&gt;fname, 0, CHIAKIFS_MAX_FILE_NAME);\n    strncpy(dentry_from-&gt;fname, to_name, CHIAKIFS_MAX_FILE_NAME - 1);\n    dentry_from-&gt;parent = dentry_to_parent;\n    \/\/ \u65b0\u3057\u3044\u89aa\u306edentry\u30ea\u30b9\u30c8\u306b\u30a8\u30f3\u30c8\u30ea\u3092\u8ffd\u52a0\n    if (chiakiFS_alloc_dentry(parent_inode_to, dentry_from, TRUE) &lt; 0) {\n        free(to_parent_path);\n        return -CHIAKIFS_ERROR_IO;\n    }\n    \/\/ \u4e21\u65b9\u306e\u89aainode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\n    if (chiakiFS_sync_inode(parent_inode_from) != CHIAKIFS_ERROR_NONE) {\n        free(to_parent_path);\n        return -CHIAKIFS_ERROR_IO;\n    }\n    if (chiakiFS_sync_inode(parent_inode_to) != CHIAKIFS_ERROR_NONE) {\n        free(to_parent_path);\n        return -CHIAKIFS_ERROR_IO;\n    }\n    free(to_parent_path);\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(from, &amp;is_find_from, &amp;is_root_from)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u5143\u306e\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002<code>chiakiFS_lookup(to, &amp;is_find_to, &amp;is_root_to)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002<br>\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u5143\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3089\u5143\u306edentry\u3092\u524a\u9664\u3057\u307e\u3059\u3002<br>\u5143\u306edentry\u306e\u540d\u524d\u3068\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u66f4\u65b0\u3057\u307e\u3059\u3001\u30bf\u30fc\u30b2\u30c3\u30c8\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<br><code>chiakiFS_sync_inode(parent_inode_from)<\/code> \u3068 <code>chiakiFS_sync_inode(parent_inode_to)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066inode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_open<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u304f\n * \u7279\u306b\u3001fi-&gt;fh \u306f 64 \u30d3\u30c3\u30c8 \u30dd\u30a4\u30f3\u30bf\u30fc\u3001\u4fdd\u5b58\u3057\u305f\u3044\u30c7\u30fc\u30bf\u69cb\u9020\u3092 fh \u306b\u4fdd\u5b58\u3067\u304d\u307e\u3059\u3002\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param fi \u30d5\u30a1\u30a4\u30eb\u30a4\u30f3\u30d5\u30a9\u30e1\u30fc\u30b7\u30e7\u30f3\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_open(const char* path, struct fuse_file_info* fi) {\n    boolean is_find, is_root;\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND;\n    }\n\n    if (CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_ISDIR;\n    }\n\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u30cf\u30f3\u30c9\u30eb\u306binode\u30dd\u30a4\u30f3\u30bf\u30fc\u3092\u4fdd\u5b58\n    fi-&gt;fh = (uint64_t)(uintptr_t)dentry-&gt;inode;\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002inode\u30dd\u30a4\u30f3\u30bf\u3092 <code>fi-&gt;fh<\/code> \u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_opendir<\/h4>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u958b\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u958b\u304f\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param fi \u30d5\u30a1\u30a4\u30eb\u30a4\u30f3\u30d5\u30a9\u30e1\u30fc\u30b7\u30e7\u30f3\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_opendir(const char* path, struct fuse_file_info* fi) {\n    boolean is_find, is_root;\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND;\n    }\n\n    if (!CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_NOTDIR;\n    }\n\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u30cf\u30f3\u30c9\u30eb\u306binode\u30dd\u30a4\u30f3\u30bf\u30fc\u3092\u4fdd\u5b58\n    fi-&gt;fh = (uint64_t)(uintptr_t)dentry-&gt;inode;\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002inode\u30dd\u30a4\u30f3\u30bf\u3092 <code>fi-&gt;fh<\/code> \u306b\u4fdd\u5b58\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_truncate<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u30b5\u30a4\u30ba\u3092\u5909\u66f4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u5909\u66f4\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param offset \u5909\u66f4\u5f8c\u306e\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_truncate(const char* path, off_t offset) {\n    boolean is_find, is_root;\n    \/\/ \u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9\u306edentry\u3092\u691c\u7d22\u3057\u3001\u898b\u3064\u304b\u308c\u3070is_find\u304ctrue\u306b\u306a\u308b\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n    struct chiakiFS_inode* inode;\n\t\/\/ dentry\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8fd4\u3059\n    if (!is_find) {\n        return -CHIAKIFS_ERROR_NOTFOUND;\n    }\n\t\/\/ \u6307\u5b9a\u3055\u308c\u305f\u30d1\u30b9\u304c\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306e\u5834\u5408\u3001\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8fd4\u3059\n    if (CHIAKIFS_IS_DIR(dentry-&gt;inode)) {\n        return -CHIAKIFS_ERROR_ISDIR;\n    }\n\t\/\/ inode\u304cNULL\u306a\u3089\u3001dentry\u306einode\u3092\u8aad\u307f\u8fbc\u307f\u3001\u5931\u6557\u3057\u305f\u3089\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8fd4\u3059\n    inode = dentry-&gt;inode;\n    if (inode == NULL) {\n        inode = chiakiFS_read_inode(dentry, dentry-&gt;ino);\n        if (inode == NULL) {\n            return -CHIAKIFS_ERROR_IO;\n        }\n        dentry-&gt;inode = inode;\n    }\n\t\/\/ \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u304c\u5897\u3048\u308b\u5834\u5408\u3001\u30ae\u30e3\u30c3\u30d7\u30920\u3067\u57cb\u3081\u308b\n    if (offset &gt; inode-&gt;size) {\n        size_t additional_size = offset - inode-&gt;size;\n        char* zero_buf = (char*)calloc(additional_size, 1);\n        \/\/ \u65b0\u3057\u3044\u30b5\u30a4\u30ba\u307e\u30670\u57cb\u3081\u30c7\u30fc\u30bf\u3092\u66f8\u304d\u8fbc\u3080\n        chiakiFS_write(path, zero_buf, additional_size, inode-&gt;size, NULL);\n        free(zero_buf);\n    } else if (offset &lt; inode-&gt;size) {\n        \/\/ \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u304c\u6e1b\u308b\u5834\u5408\u3001\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5207\u308a\u8a70\u3081\u308b\n        size_t required_blocks = CHIAKIFS_ROUND_UP(offset, CHIAKIFS_BLK_SZ()) \/ CHIAKIFS_BLK_SZ();\n        \/\/ \u5fc5\u8981\u306a\u30d6\u30ed\u30c3\u30af\u6570\u3088\u308a\u591a\u3044\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\u3059\u308b\n        for (int blk_idx = required_blocks; blk_idx &lt; CHIAKIFS_DATA_PER_FILE; blk_idx++) {\n            if (inode-&gt;dblk&#91;blk_idx] != 0) {\n                \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u89e3\u653e\u51e6\u7406\n                int dblk = inode-&gt;dblk&#91;blk_idx];\n                int byte_index = dblk \/ UINT8_BITS;\n                int bit_index = dblk % UINT8_BITS;\n                \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u3092\u66f4\u65b0\u3057\u3001\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\n                chiakiFS_super.map_data&#91;byte_index] &amp;= (uint8_t)(~(0x1 &lt;&lt; bit_index));\n                inode-&gt;dblk&#91;blk_idx] = 0;\n                if (inode-&gt;data&#91;blk_idx]) {\n                    free(inode-&gt;data&#91;blk_idx]);\n                    inode-&gt;data&#91;blk_idx] = NULL;\n                }\n            }\n        }\n        \/\/ \u6700\u5f8c\u306e\u30d6\u30ed\u30c3\u30af\u306e\u30c7\u30fc\u30bf\u3092\u8abf\u6574\u3057\u30660\u3067\u57cb\u3081\u308b\n        if (required_blocks &gt; 0) {\n            int blk_idx = required_blocks - 1;\n            int blk_offset = offset % CHIAKIFS_BLK_SZ();\n            if (inode-&gt;data&#91;blk_idx]) {\n                memset(inode-&gt;data&#91;blk_idx] + blk_offset, 0, CHIAKIFS_BLK_SZ() - blk_offset);\n            }\n        }\n        inode-&gt;size = offset;\n    }\n    \/\/ inode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\n    if (chiakiFS_sync_inode(inode) != CHIAKIFS_ERROR_NONE) {\n        return -CHIAKIFS_ERROR_IO;\n    }\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u898b\u3064\u304b\u3089\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304b\u3069\u3046\u304b\u3092\u78ba\u8a8d\u3057\u3001\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3042\u308c\u3070\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u65b0\u3057\u3044\u30b5\u30a4\u30ba\u304c\u73fe\u5728\u306e\u30b5\u30a4\u30ba\u3088\u308a\u5927\u304d\u3044\u5834\u5408\u3001\u65b0\u3057\u3044\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u5272\u308a\u5f53\u3066\u3066\u30bc\u30ed\u3067\u57cb\u3081\u307e\u3059\u3002<br>\u65b0\u3057\u3044\u30b5\u30a4\u30ba\u304c\u73fe\u5728\u306e\u30b5\u30a4\u30ba\u3088\u308a\u5c0f\u3055\u3044\u5834\u5408\u3001\u4f59\u5206\u306a\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3092\u89e3\u653e\u3057\u307e\u3059\u3002\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<code>chiakiFS_sync_inode(inode)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066inode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_access<\/h4>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u306e\u30a2\u30af\u30bb\u30b9\u6a29\u3092\u78ba\u8a8d\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30d5\u30a1\u30a4\u30eb\u3092\u30a2\u30af\u30bb\u30b9\u3001\u6a29\u9650\u7167\u5408\u5fc5\u8981\n * \n * @param path \u30de\u30a6\u30f3\u30c8\u30dd\u30a4\u30f3\u30c8\u306b\u5bfe\u3059\u308b\u30d1\u30b9\n * @param type \u30a2\u30af\u30bb\u30b9\u30bf\u30a4\u30d7\n * R_OK: \u8aad\u8fbc\u6a29\u9650\u3092\u30c1\u30a7\u30c3\u30af\n * W_OK: \u66f8\u8fbc\u6a29\u9650\u3092\u30c1\u30a7\u30c3\u30af\n * X_OK: \u5b9f\u884c\u6a29\u9650\u3092\u30c1\u30a7\u30c3\u30af.\n * F_OK: \u3000\u3000\u3000\u5b58\u5728\u6027\u3092\u30c1\u30a7\u30c3\u30af. \n * \n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_access(const char* path, int type) {\n\tboolean\tis_find, is_root;\n\tboolean is_access_ok = FALSE;\n\tchiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n\n\tswitch (type)\n\t{\n\tcase R_OK:\n\t\tis_access_ok = TRUE;\n\t\tbreak;\n\tcase F_OK:\n\t\tif (is_find) {\n\t\t\tis_access_ok = TRUE;\n\t\t}\n\t\tbreak;\n\tcase W_OK:\n\t\tis_access_ok = TRUE;\n\t\tbreak;\n\tcase X_OK:\n\t\tis_access_ok = TRUE;\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n\treturn is_access_ok ? CHIAKIFS_ERROR_NONE : -CHIAKIFS_ERROR_ACCESS;\n}<\/code><\/pre>\n\n\n\n<p>\u30a2\u30af\u30bb\u30b9\u306e\u7a2e\u985e\uff08R_OK, W_OK, X_OK, F_OK\uff09\u306b\u57fa\u3065\u3044\u3066\u3001\u5bfe\u5fdc\u3059\u308b\u7d50\u679c\u3092\u8fd4\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_symlink<\/h4>\n\n\n\n<p>\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3092\u4f5c\u308b\n * \n * @param from \u30bd\u30fc\u30b9\u30d1\u30b9\n * @param to   \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u306e\u30d1\u30b9\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_symlink(const char *from, const char *to) {\n    boolean is_find, is_root;\n    char *fname;\n    struct chiakiFS_dentry *parent_dentry, *sym_dentry;\n    struct chiakiFS_inode *parent_inode, *inode;\n    int ret;\n\n    \/\/ to\u3001\u65e2\u306b\u5b58\u5728\uff1f\n    chiakiFS_lookup(to, &amp;is_find, &amp;is_root);\n    if (is_find) {\n        return -EEXIST;\n    }\n\n    \/\/ to\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n    char *parent_path = strdup(to);\n    char *last_slash = strrchr(parent_path, '\/');\n    if (last_slash == NULL) {\n        free(parent_path);\n        return -EINVAL;\n    }\n    if (last_slash == parent_path) {\n        \/\/ \u89aa\u304c\u30eb\u30fc\u30c8\n        *(last_slash + 1) = '\\0';\n    } else {\n        *last_slash = '\\0';\n    }\n\n    parent_dentry = chiakiFS_lookup(parent_path, &amp;is_find, &amp;is_root);\n    free(parent_path);\n    if (!is_find || !CHIAKIFS_IS_DIR(parent_dentry-&gt;inode)) {\n        return -ENOENT;\n    }\n    parent_inode = parent_dentry-&gt;inode;\n    \/\/ to\u306e\u30d5\u30a1\u30a4\u30eb\u30cd\u30fc\u30e0\n    fname = chiakiFS_get_fname(to);\n\n    \/\/ New Dentry\n    sym_dentry = new_dentry(fname, CHIAKIFS_SYM_LINK);\n    sym_dentry-&gt;parent = parent_dentry;\n\n    \/\/ New inode\n    inode = chiakiFS_alloc_inode(sym_dentry);\n\n    \/\/ \u3053\u306einode\u306etarget_path\u3092from\u306b\u8a2d\u7f6e\n    strncpy(inode-&gt;target_path, from, CHIAKIFS_MAX_FILE_NAME - 1);\n    inode-&gt;target_path&#91;CHIAKIFS_MAX_FILE_NAME - 1] = '\\0';\n\n    \/\/ \u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3092\u30ea\u30f3\u30af\u5143\u306e\u30b5\u30a4\u30ba\u306b\u8a2d\u7f6e\n    inode-&gt;size = strlen(from);\n\n    \/\/ dentry\u3092parent\u3078\u63a5\u7d9a\n    chiakiFS_alloc_dentry(parent_inode, sym_dentry, TRUE);\n\n    \/\/ \u30c7\u30a3\u30b9\u30af\u3078\u4fdd\u5b58\n    ret = chiakiFS_sync_inode(inode);\n    if (ret != CHIAKIFS_ERROR_NONE) {\n        return ret;\n    }\n\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(to, &amp;is_find_to, &amp;is_root_to)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u65b0\u3057\u3044dentry\u3068inode\u3092\u4f5c\u6210\u3057\u3001\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002<br>\u65b0\u3057\u3044dentry\u3092\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<code>chiakiFS_sync_inode(inode)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066inode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_readlink<\/h4>\n\n\n\n<p>\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u3092\u8aad\u307f\u53d6\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3092\u89e3\u6790\n * \n * @param path  \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30d1\u30b9\n * @param buf   \u89e3\u6790\u3055\u308c\u305f\u30d1\u30b9\u3092\u3053\u3053\u306b\n * @param size\u3000\u3000\u3000\u3000buf\u306e\u6700\u5927\u9577('\\0'\u3092\u542b\u3081)\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_readlink(const char *path, char *buf, size_t size) {\n    boolean is_find, is_root;\n    struct chiakiFS_dentry* dentry = chiakiFS_lookup(path, &amp;is_find, &amp;is_root);\n\n    if (!is_find) {\n        return -ENOENT;\n    }\n    \/\/\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3067\u306f\u306a\u3044\n    if (!CHIAKIFS_IS_SYM_LINK(dentry-&gt;inode)) {\n        return -EINVAL;\n    }\n\n    size_t len = strlen(dentry-&gt;inode-&gt;target_path);\n    if (len &gt;= size) {\n        len = size - 1;\n    }\n    memcpy(buf, dentry-&gt;inode-&gt;target_path, len);\n    buf&#91;len] = '\\0';\n\n    return 0;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(path, &amp;is_find, &amp;is_root)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u3067\u306a\u3044\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002\u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u3092\u30e6\u30fc\u30b6\u30fc\u30d0\u30c3\u30d5\u30a1\u306b\u30b3\u30d4\u30fc\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">chiakiFS_link<\/h4>\n\n\n\n<p>\u30cf\u30fc\u30c9\u30ea\u30f3\u30af\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/**\n * @brief \u30cf\u30fc\u30c9\u30ea\u30f3\u30af\u3092\u4f5c\u308b\n * \n * @param from \u30bd\u30fc\u30b9\u30d1\u30b9\n * @param to   \u30ea\u30f3\u30af\u306e\u30d1\u30b9\n * @return int \u6210\u529f\u306a\u30890\u3001\u5931\u6557\u6642\u306f\u5bfe\u5fdc\u3059\u308b\u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\n *\/\nint chiakiFS_link(const char *from, const char *to) {\n    boolean is_find_from, is_root_from;\n    boolean is_find_to, is_root_to;\n    struct chiakiFS_dentry *from_dentry, *parent_dentry, *link_dentry;\n    struct chiakiFS_inode *parent_inode;\n    char *fname;\n\n    \/\/ from\u5b58\u5728\u304b\uff1f\n    from_dentry = chiakiFS_lookup(from, &amp;is_find_from, &amp;is_root_from);\n    if (!is_find_from) {\n        return -ENOENT;\n    }\n\n    \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3078\u306e\u30cf\u30fc\u30c9\u30ea\u30f3\u30af\u306f\u4e0d\u53ef\n    if (CHIAKIFS_IS_DIR(from_dentry-&gt;inode)) {\n        return -EPERM;\n    }\n\n    \/\/ to\u5b58\u5728\u304b\uff1f\n    chiakiFS_lookup(to, &amp;is_find_to, &amp;is_root_to);\n    if (is_find_to) {\n        return -EEXIST;\n    }\n\n    \/\/ to\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n    char *parent_path = strdup(to);\n    char *last_slash = strrchr(parent_path, '\/');\n    if (last_slash == NULL) {\n        free(parent_path);\n        return -EINVAL;\n    }\n    if (last_slash == parent_path) {\n        \/\/ \u89aa\u304c\u30eb\u30fc\u30c8\n        *(last_slash + 1) = '\\0';\n    } else {\n        *last_slash = '\\0';\n    }\n\n    parent_dentry = chiakiFS_lookup(parent_path, &amp;is_find_to, &amp;is_root_to);\n    free(parent_path);\n    if (!is_find_to || !CHIAKIFS_IS_DIR(parent_dentry-&gt;inode)) {\n        return -ENOENT;\n    }\n    parent_inode = parent_dentry-&gt;inode;\n\n    \/\/ to\u306e\u30d5\u30a1\u30a4\u30eb\u30cd\u30fc\u30e0\n    fname = chiakiFS_get_fname(to);\n\n    \/\/ new dentry\n    link_dentry = new_dentry(fname, from_dentry-&gt;ftype); \/\/ Use same type as 'from'\n    link_dentry-&gt;parent = parent_dentry;\n    link_dentry-&gt;ino = from_dentry-&gt;ino; \/\/ Point to same inode\n    link_dentry-&gt;inode = from_dentry-&gt;inode;\n\n    \/\/ Dentry\u3092parent\u3078\u63a5\u7d9a\n    chiakiFS_alloc_dentry(parent_inode, link_dentry, TRUE);\n\n    \/\/ \u30c7\u30a3\u30b9\u30af\u3078\n    chiakiFS_sync_inode(parent_inode);\n    \/\/ \u30ea\u30f3\u30af\u5143\u306einode\u306e\u30ea\u30f3\u30af\u6570\u3092\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3057\u3001\u540c\u671f\u3059\u308b\n    from_dentry-&gt;inode-&gt;link_cnt++;\n    chiakiFS_sync_inode(from_dentry-&gt;inode);\n    return CHIAKIFS_ERROR_NONE;\n}<\/code><\/pre>\n\n\n\n<p><code>chiakiFS_lookup(from, &amp;is_find_from, &amp;is_root_from)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u5143\u306e\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002<code>chiakiFS_lookup(to, &amp;is_find_to, &amp;is_root_to)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u3092\u691c\u7d22\u3057\u307e\u3059\u3002\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u5834\u5408\u3001\u30a8\u30e9\u30fc\u3092\u8fd4\u3057\u307e\u3059\u3002<br>\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\u306e\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3092\u53d6\u5f97\u3057\u307e\u3059\u3002\u65b0\u3057\u3044dentry\u3092\u4f5c\u6210\u3057\u3001\u65e2\u5b58\u306einode\u3092\u6307\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002\u65b0\u3057\u3044dentry\u3092\u89aa\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u8ffd\u52a0\u3057\u307e\u3059\u3002<code>chiakiFS_sync_inode(parent_inode)<\/code> \u3092\u547c\u3073\u51fa\u3057\u3066\u89aainode\u3092\u30c7\u30a3\u30b9\u30af\u306b\u540c\u671f\u3057\u3001\u30cf\u30fc\u30c9\u30ea\u30f3\u30af\u306e\u53c2\u7167\u30ab\u30a6\u30f3\u30c8\uff08\u30ea\u30f3\u30af\u6570\uff09\u3092\u66f4\u65b0\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c7\u30d0\u30c3\u30b0<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30ed\u30b0\u30ec\u30fc\u30d9\u30eb\u30c7\u30d0\u30c3\u30b0<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">\/******************************************************************************\n* SECTION: macro debug\n*******************************************************************************\/\n#define CHIAKIFS_DBG(fmt, ...) do { printf(\"CHIAKIFS_DBG: \" fmt, ##__VA_ARGS__); } while(0) <\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u30c7\u30d0\u30c3\u30b0<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>void chiakiFS_dump_Imap() {\n    int byte_cursor = 0;\n    int bit_cursor = 0;\n\n    for (byte_cursor = 0; byte_cursor &lt; CHIAKIFS_BLKS_SZ(chiakiFS_super.map_inode_blks); \n         byte_cursor+=4)\n    {\n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_inode&#91;byte_cursor] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\t\");\n\n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_inode&#91;byte_cursor + 1] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\t\");\n        \n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_inode&#91;byte_cursor + 2] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\t\");\n        \n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_inode&#91;byte_cursor + 3] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\n\");\n    }\n}\n\nvoid chiakiFS_dump_Dmap() {\n    int byte_cursor = 0;\n    int bit_cursor = 0;\n\n    for (byte_cursor = 0; byte_cursor &lt; CHIAKIFS_BLKS_SZ(chiakiFS_super.map_data_blks); \n         byte_cursor+=4)\n    {\n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_data&#91;byte_cursor] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\t\");\n\n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_data&#91;byte_cursor + 1] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\t\");\n        \n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_data&#91;byte_cursor + 2] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\t\");\n        \n        for (bit_cursor = 0; bit_cursor &lt; UINT8_BITS; bit_cursor++) {\n            printf(\"%d \", (chiakiFS_super.map_data&#91;byte_cursor + 3] &amp; (0x1 &lt;&lt; bit_cursor)) &gt;&gt; bit_cursor);   \n        }\n        printf(\"\\n\");\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">FUSE\u3067\u7a3c\u50cd<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">struct custom_options {\n\tconst char*        device;     \/\/ \u30c7\u30d0\u30a4\u30b9\u540d\n\tboolean            show_help;  \/\/ \u30d8\u30eb\u30d7\u8868\u793a\u30d5\u30e9\u30b0\n};\n\n\/******************************************************************************\n* SECTION: \u30de\u30af\u30ed\u3000define\n*******************************************************************************\/\n#define OPTION(t, p)        { t, offsetof(struct custom_options, p), 1 }\n\n\/******************************************************************************\n* SECTION: \u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\n*******************************************************************************\/\nstatic const struct fuse_opt option_spec&#91;] = {   \/* FUSE\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u89e3\u6790\u7528 *\/\n\tOPTION(\"--device=%s\", device),\n\tFUSE_OPT_END\n};\n\nstruct custom_options chiakiFS_options;\t\t\t \/* \u30b0\u30ed\u30fc\u30d0\u30eb\u30aa\u30d7\u30b7\u30e7\u30f3 *\/\nstruct chiakiFS_super chiakiFS_super;\n\n\/******************************************************************************\n* SECTION: FUSE\u306e\u5165\u53e3\n*******************************************************************************\/\nint main(int argc, char **argv)\n{\n    int ret;\n\tstruct fuse_args args = FUSE_ARGS_INIT(argc, argv);\n\n\tchiakiFS_options.device = strdup(\/*\u3053\u3053\u306f\u3054\u81ea\u5206\u306eddriver\u30d1\u30b9*\/\"\/root\/ddriver\");\n\n\tif (fuse_opt_parse(&amp;args, &amp;chiakiFS_options, option_spec, NULL) == -1)\n\t\treturn -1;\n\t\n\tret = fuse_main(args.argc, args.argv, &amp;operations, NULL);\n\tfuse_opt_free_args(&amp;args);\n\treturn ret;\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5b9f\u73fe\u3055\u308c\u305f\u95a2\u6570\u4e00\u89a7<\/h3>\n\n\n\n<p>chiakiFS.h\u306e\u5168\u6587\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">#ifndef _CHIAKIFS_H_\n#define _CHIAKIFS_H_\n\n#define FUSE_USE_VERSION 26\n#include \"stdio.h\"\n#include \"stdlib.h\"\n#include &lt;unistd.h&gt;\n#include \"fcntl.h\"\n#include \"string.h\"\n#include \"fuse.h\"\n#include &lt;stddef.h&gt;\n#include \"ddriver.h\"\n#include \"errno.h\"\n#include \"types.h\"\n#include \"stdint.h\"\n\n#define CHIAKIFS_MAGIC     0x20040301   \/* TODO: \u304a\u597d\u304d\u306a\u6570\u5b57\u3067\u3044\u3044\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u306e\u30de\u30b8\u30c3\u30af\u30ca\u30f3\u30d0\u30fc *\/\n#define CHIAKIFS_DEFAULT_PERM    0777   \/* \u30d5\u30fc\u30eb\u30a2\u30af\u30bb\u30b9 *\/\n\n\/******************************************************************************\n* SECTION: macro debug\n*******************************************************************************\/\n#define CHIAKIFS_DBG(fmt, ...) do { printf(\"CHIAKIFS_DBG: \" fmt, ##__VA_ARGS__); } while(0) \n\/******************************************************************************\n* SECTION: chiakiFS_utils.c\n*******************************************************************************\/\nchar* \t\t\t\t      chiakiFS_get_fname(const char* path);\nint \t\t\t\t      chiakiFS_calc_lvl(const char * path);\nint \t\t\t\t      chiakiFS_driver_read(int offset, uint8_t *out_content, int size);\nint \t\t\t   \t      chiakiFS_driver_write(int offset, uint8_t *in_content, int size);\n\n\nint \t\t\t  \t      chiakiFS_mount(struct custom_options options);\nint \t\t\t  \t      chiakiFS_umount();\n\nint \t\t\t  \t      chiakiFS_alloc_dentry(struct chiakiFS_inode * inode, struct chiakiFS_dentry * dentry, int W);\nint \t\t\t  \t      chiakiFS_drop_dentry(struct chiakiFS_inode * inode, struct chiakiFS_dentry * dentry);\nstruct chiakiFS_inode*    chiakiFS_alloc_inode(struct chiakiFS_dentry * dentry);\nint \t\t\t\t      chiakiFS_sync_inode(struct chiakiFS_inode * inode);\nint \t\t\t\t      chiakiFS_drop_inode(struct chiakiFS_inode * inode);\nstruct chiakiFS_inode*    chiakiFS_read_inode(struct chiakiFS_dentry * dentry, int ino);\nstruct chiakiFS_dentry*   chiakiFS_get_dentry(struct chiakiFS_inode * inode, int dir);\n\nstruct chiakiFS_dentry*   chiakiFS_lookup(const char * path, boolean * is_find, boolean* is_root);\n\/******************************************************************************\n* SECTION: chiakiFS.c\n*******************************************************************************\/\nvoid* \t\t\t   chiakiFS_init(struct fuse_conn_info *);\nvoid  \t\t\t   chiakiFS_destroy(void *);\nint   \t\t\t   chiakiFS_mkdir(const char *, mode_t);\nint   \t\t\t   chiakiFS_getattr(const char *, struct stat *);\nint   \t\t\t   chiakiFS_readdir(const char *, void *, fuse_fill_dir_t, off_t, struct fuse_file_info *);\nint   \t\t\t   chiakiFS_mknod(const char *, mode_t, dev_t);\nint   \t\t\t   chiakiFS_write(const char *, const char *, size_t, off_t, struct fuse_file_info *);\nint   \t\t\t   chiakiFS_read(const char *, char *, size_t, off_t, struct fuse_file_info *);\nint   \t\t\t   chiakiFS_access(const char *, int);\nint   \t\t\t   chiakiFS_unlink(const char *);\nint   \t\t\t   chiakiFS_rmdir(const char *);\nint   \t\t\t   chiakiFS_rename(const char *, const char *);\nint   \t\t\t   chiakiFS_utimens(const char *, const struct timespec tv&#91;2]);\nint   \t\t\t   chiakiFS_truncate(const char *, off_t);\n\t\t\t\nint   \t\t\t   chiakiFS_open(const char *, struct fuse_file_info *);\nint   \t\t\t   chiakiFS_opendir(const char *, struct fuse_file_info *);\n\nint \t\t\t   chiakiFS_symlink(const char *, const char *);\nint \t\t\t   chiakiFS_readlink(const char *, char *, size_t);\nint \t\t\t   chiakiFS_link(const char *, const char *);\n\/******************************************************************************\n* SECTION: chiakiFS_debug.c\n*******************************************************************************\/\nvoid \t\t\t   chiakiFS_dump_Imap();\nvoid\t\t\t   chiakiFS_dump_Dmap();\n#endif  \/* _chiakiFS_H_ *\/\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u30c7\u30a3\u30b9\u30af\u30ec\u30a4\u30a2\u30a6\u30c8\u3068\u4ed6\u306e\u5b9a\u6570\u5b9a\u7fa9<\/h3>\n\n\n\n<p>types.h\u306e\u5168\u6587\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"c\">#ifndef _TYPES_H_\n#define _TYPES_H_\n\n\/******************************************************************************\n* SECTION: Type def (\u578b\u5b9a\u7fa9\u30bb\u30af\u30b7\u30e7\u30f3)\n*******************************************************************************\/\ntypedef int          boolean;      \/\/ \u30d6\u30fc\u30eb\u578b\u3092int\u3068\u3057\u3066\u5b9a\u7fa9\ntypedef uint16_t     flag16;       \/\/ 16\u30d3\u30c3\u30c8\u306e\u30d5\u30e9\u30b0\u578b\n\n\/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306e\u5217\u6319\u578b\u5b9a\u7fa9\ntypedef enum chiakiFS_file_type {\n    CHIAKIFS_REG_FILE,     \/\/ \u901a\u5e38\u30d5\u30a1\u30a4\u30eb\n    CHIAKIFS_DIR,          \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\n    CHIAKIFS_SYM_LINK      \/\/ \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\n} CHIAKIFS_FILE_TYPE;\n\n\/******************************************************************************\n* SECTION: Macro (\u30de\u30af\u30ed\u5b9a\u7fa9\u30bb\u30af\u30b7\u30e7\u30f3)\n*******************************************************************************\/\n#define TRUE                    1       \n#define FALSE                   0       \n#define UINT32_BITS             32      \n#define UINT8_BITS              8       \n\n#define CHIAKIFS_SUPER_OFS           0           \/\/ \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u30aa\u30d5\u30bb\u30c3\u30c8\n#define CHIAKIFS_ROOT_INO            0           \/\/ \u30eb\u30fc\u30c8inode\u756a\u53f7\n\n\/\/ Layout\u7528\u30de\u30af\u30ed\n#define CHIAKIFS_SUPER_BLKS          1           \/\/ \u30b9\u30fc\u30d1\u30fc\u30d6\u30ed\u30c3\u30af\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_MAP_INODE_BLKS      1           \/\/ inode\u30de\u30c3\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_MAP_DATA_BLKS       1           \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_INODE_PER_BLOCK     6           \/\/ \u30d6\u30ed\u30c3\u30af\u3054\u3068\u306einode\u6570 (Layout)\n#define CHIAKIFS_INODE_BLKS          164         \/\/ inode\u306e\u30d6\u30ed\u30c3\u30af\u6570\n#define CHIAKIFS_DATA_BLKS           3929        \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u306e\u6570\n\n\/\/ \u30a8\u30e9\u30fc\u30b3\u30fc\u30c9\u306e\u30de\u30af\u30ed\u5b9a\u7fa9\n#define CHIAKIFS_ERROR_NONE          0           \/\/ \u30a8\u30e9\u30fc\u306a\u3057\n#define CHIAKIFS_ERROR_ACCESS        EACCES      \/\/ \u30a2\u30af\u30bb\u30b9\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_SEEK          ESPIPE      \/\/ \u30b7\u30fc\u30af\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_ISDIR         EISDIR      \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_NOSPACE       ENOSPC      \/\/ \u30b9\u30da\u30fc\u30b9\u4e0d\u8db3\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_EXISTS        EEXIST      \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u65e2\u306b\u5b58\u5728\u3059\u308b\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_NOTFOUND      ENOENT      \/\/ \u30d5\u30a1\u30a4\u30eb\u304c\u898b\u3064\u304b\u3089\u306a\u3044\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_UNSUPPORTED   ENXIO       \/\/ \u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u306a\u3044\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_IO            EIO         \/\/ \u5165\u51fa\u529b\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_INVAL         EINVAL      \/\/ \u7121\u52b9\u306a\u5f15\u6570\u30a8\u30e9\u30fc\n#define CHIAKIFS_ERROR_NOTDIR        ENOTDIR     \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u306f\u306a\u3044\u30a8\u30e9\u30fc\n\n#define CHIAKIFS_MAX_FILE_NAME       128         \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u306e\u6700\u5927\u9577\u3055\n#define CHIAKIFS_INODE_PER_FILE      16          \/\/ \u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306einode\u6570 (Layout)\n#define CHIAKIFS_DATA_PER_FILE       4           \/\/ \u30d5\u30a1\u30a4\u30eb\u3054\u3068\u306e\u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u6570 (Layout)\n#define CHIAKIFS_DEFAULT_PERM        0777        \/\/ \u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u30d1\u30fc\u30df\u30c3\u30b7\u30e7\u30f3\n\n#define CHIAKIFS_IOC_MAGIC           'S'         \/\/ IOCTL\u306e\u30de\u30b8\u30c3\u30af\n#define CHIAKIFS_IOC_SEEK            _IO(CHIAKIFS_IOC_MAGIC, 0)  \/\/ IOCTL SEEK\n\n\/\/ \u30d0\u30c3\u30d5\u30a1\u306e\u30d5\u30e9\u30b0\u5b9a\u7fa9\n#define CHIAKIFS_FLAG_BUF_DIRTY      0x1         \/\/ \u30d0\u30c3\u30d5\u30a1\u304c\u30c0\u30fc\u30c6\u30a3\u72b6\u614b\n#define CHIAKIFS_FLAG_BUF_OCCUPY     0x2         \/\/ \u30d0\u30c3\u30d5\u30a1\u304c\u4f7f\u7528\u4e2d\n\n\/******************************************************************************\n* SECTION: Macro Function (\u30de\u30af\u30ed\u95a2\u6570\u30bb\u30af\u30b7\u30e7\u30f3)\n*******************************************************************************\/\n#define CHIAKIFS_IO_SZ()                     (chiakiFS_super.sz_io)                 \/\/ IO\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_DISK_SZ()                   (chiakiFS_super.sz_disk)               \/\/ \u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_BLK_SZ()                    (chiakiFS_super.sz_blk)                \/\/ \u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_DRIVER()                    (chiakiFS_super.driver_fd)             \/\/ \u30c9\u30e9\u30a4\u30d0\u53d6\u5f97\n#define CHIAKIFS_DENTRY_PER_DATABLK()        (CHIAKIFS_BLK_SZ()\/sizeof(struct chiakiFS_dentry))  \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u3054\u3068\u306edentry\u6570\n\n#define CHIAKIFS_ROUND_DOWN(value, round)    ((value) % (round) == 0 ? (value) : ((value) \/ (round)) * (round))\n#define CHIAKIFS_ROUND_UP(value, round)      ((value) % (round) == 0 ? (value) : ((value) \/ (round) + 1) * (round))\n\n#define CHIAKIFS_BLKS_SZ(blks)               ((blks) * CHIAKIFS_BLK_SZ())           \/\/ \u30d6\u30ed\u30c3\u30af\u6570\u304b\u3089\u30b5\u30a4\u30ba\u53d6\u5f97\n#define CHIAKIFS_ASSIGN_FNAME(pchiakiFS_dentry, _fname) \\\n    do { \\\n        strncpy((pchiakiFS_dentry)->fname, (_fname), CHIAKIFS_MAX_FILE_NAME - 1); \\\n        (pchiakiFS_dentry)->fname&#91;CHIAKIFS_MAX_FILE_NAME - 1] = '\\0'; \\\n    } while(0)\n \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\u306e\u5272\u308a\u5f53\u3066\n#define CHIAKIFS_INO_OFS(ino)                (chiakiFS_super.inode_offset \\\n     + (ino \/ CHIAKIFS_INODE_PER_BLOCK) * CHIAKIFS_BLK_SZ() \\\n     + (ino % CHIAKIFS_INODE_PER_BLOCK) * sizeof(struct chiakiFS_inode_d))                          \/\/ inode\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97\n\n#define CHIAKIFS_DATA_OFS(dno)               (chiakiFS_super.data_offset + CHIAKIFS_BLKS_SZ(dno))   \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\u8a08\u7b97\n\n\/\/ inode\u306e\u30bf\u30a4\u30d7\u3092\u30c1\u30a7\u30c3\u30af\u3059\u308b\u30de\u30af\u30ed\n#define CHIAKIFS_IS_DIR(pinode)              (pinode->dentry->ftype == CHIAKIFS_DIR)\n#define CHIAKIFS_IS_REG(pinode)              (pinode->dentry->ftype == CHIAKIFS_REG_FILE)\n#define CHIAKIFS_IS_SYM_LINK(pinode)         (pinode->dentry->ftype == CHIAKIFS_SYM_LINK)\n\n\/******************************************************************************\n* SECTION: FS Specific Structure - In memory structure (\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u56fa\u6709\u69cb\u9020 - \u30e1\u30e2\u30ea\u5185\u69cb\u9020)\n*******************************************************************************\/\nstruct chiakiFS_dentry;\nstruct chiakiFS_inode;\nstruct chiakiFS_super;\n\nstruct custom_options {\n\tconst char*        device;     \/\/ \u30c7\u30d0\u30a4\u30b9\u540d\n\tboolean            show_help;  \/\/ \u30d8\u30eb\u30d7\u8868\u793a\u30d5\u30e9\u30b0\n};\n\nstruct chiakiFS_inode\n{\n    int                     ino;                           \/\/ inode\u756a\u53f7\n    int                     size;                          \/\/ \u30d5\u30a1\u30a4\u30eb\u4f7f\u7528\u9818\u57df\u30b5\u30a4\u30ba\n    char                    target_path&#91;CHIAKIFS_MAX_FILE_NAME]; \/\/ \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u6642\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\n    int                     dir_cnt;                       \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\n    uint32_t                link_cnt;                      \/\/ \u30ea\u30f3\u30af\u6570\n    struct chiakiFS_dentry* dentry;                        \/\/ \u3053\u306einode\u3078\u306edentry\u3078\u306e\u30dd\u30a4\u30f3\u30bf\n    struct chiakiFS_dentry* dentrys;                       \/\/ \u5168\u3066\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30a8\u30f3\u30c8\u30ea\n    uint8_t*                data&#91;CHIAKIFS_DATA_PER_FILE];  \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\n    int                     dblk&#91;CHIAKIFS_DATA_PER_FILE];   \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u756a\u53f7\n};\n\nstruct chiakiFS_dentry\n{\n    char                    fname&#91;CHIAKIFS_MAX_FILE_NAME];\/\/ \u30d5\u30a1\u30a4\u30eb\u540d\n    struct chiakiFS_dentry* parent;                       \/\/ \u89aainode\u306edentry\n    struct chiakiFS_dentry* brother;                      \/\/ \u5144\u5f1fdentry\n    int                     ino;                          \/\/ inode\u756a\u53f7\n    struct chiakiFS_inode*  inode;                        \/\/ inode\u3078\u306e\u30dd\u30a4\u30f3\u30bf\n    CHIAKIFS_FILE_TYPE      ftype;                        \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\n};\n\nstruct chiakiFS_super\n{\n    int                driver_fd;                    \/\/ \u30c9\u30e9\u30a4\u30d0\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf\n\n    int                sz_io;                        \/\/ IO\u30b5\u30a4\u30ba\n    int                sz_disk;                      \/\/ \u30c7\u30a3\u30b9\u30af\u30b5\u30a4\u30ba\n    int                sz_blk;                       \/\/ \u30d6\u30ed\u30c3\u30af\u30b5\u30a4\u30ba\n    int                sz_usage;                     \/\/ \u4f7f\u7528\u30b5\u30a4\u30ba\n\n    int                max_ino;                      \/\/ \u6700\u5927inode\u6570\n    uint8_t*           map_inode;                    \/\/ inode\u30de\u30c3\u30d7\n    int                map_inode_blks;               \/\/ inode\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    int                map_inode_offset;             \/\/ inode\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    int                inode_offset;                 \/\/ inode\u30aa\u30d5\u30bb\u30c3\u30c8\n\n    int                max_data;                     \/\/ \u6700\u5927\u30c7\u30fc\u30bf\u6570\n    uint8_t*           map_data;                     \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\n    int                map_data_blks;                \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    int                map_data_offset;              \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    int                data_offset;                  \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\n\n    boolean            is_mounted;                   \/\/ \u30de\u30a6\u30f3\u30c8\u72b6\u614b\n\n    struct chiakiFS_dentry* root_dentry;             \/\/ \u30eb\u30fc\u30c8dentry\u3078\u306e\u30dd\u30a4\u30f3\u30bf\n};\n\n\/\/ \u65b0\u3057\u3044dentry\u3092\u4f5c\u6210\u3059\u308b\u95a2\u6570\nstatic inline struct chiakiFS_dentry* new_dentry(char * fname, CHIAKIFS_FILE_TYPE ftype) {\n    struct chiakiFS_dentry * dentry = (struct chiakiFS_dentry *)malloc(sizeof(struct chiakiFS_dentry));\n    memset(dentry, 0, sizeof(struct chiakiFS_dentry));\n    CHIAKIFS_ASSIGN_FNAME(dentry, fname);\n    dentry->ftype   = ftype;\n    dentry->ino     = -1;\n    dentry->inode   = NULL;\n    dentry->parent  = NULL;\n    dentry->brother = NULL;\n    return dentry;                                        \n}\n\n\/******************************************************************************\n* SECTION: FS Specific Structure - Disk structure (\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u56fa\u6709\u69cb\u9020 - \u30c7\u30a3\u30b9\u30af\u69cb\u9020)\n*******************************************************************************\/\nstruct chiakiFS_super_d\n{\n    uint32_t           magic_num;                \/\/ \u30de\u30b8\u30c3\u30af\u30ca\u30f3\u30d0\u30fc\n    uint32_t           sz_usage;                 \/\/ \u4f7f\u7528\u30b5\u30a4\u30ba\n\n    uint32_t           max_ino;                  \/\/ \u6700\u5927inode\u6570\n    uint32_t           map_inode_blks;           \/\/ inode\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    uint32_t           map_inode_offset;         \/\/ inode\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    uint32_t           inode_offset;             \/\/ inode\u30aa\u30d5\u30bb\u30c3\u30c8\n    uint32_t           max_data;                 \/\/ \u6700\u5927\u30c7\u30fc\u30bf\u6570\n    uint32_t           map_data_blks;            \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30d6\u30ed\u30c3\u30af\u6570\n    uint32_t           map_data_offset;          \/\/ \u30c7\u30fc\u30bf\u30de\u30c3\u30d7\u30aa\u30d5\u30bb\u30c3\u30c8\n    uint32_t           data_offset;              \/\/ \u30c7\u30fc\u30bf\u30aa\u30d5\u30bb\u30c3\u30c8\n};\n\nstruct chiakiFS_inode_d\n{\n    uint32_t           ino;                     \/\/ inode\u30d3\u30c3\u30c8\u30de\u30c3\u30d7\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\n    uint32_t           size;                    \/\/ \u30d5\u30a1\u30a4\u30eb\u4f7f\u7528\u9818\u57df\u30b5\u30a4\u30ba\n    char               target_path&#91;CHIAKIFS_MAX_FILE_NAME]; \/\/ \u30b7\u30f3\u30dc\u30ea\u30c3\u30af\u30ea\u30f3\u30af\u6642\u306e\u30bf\u30fc\u30b2\u30c3\u30c8\u30d1\u30b9\n    uint32_t           dir_cnt;                 \/\/ \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30ab\u30a6\u30f3\u30c8\n    uint32_t           link_cnt;                \/\/ \u30ea\u30f3\u30af\u6570\n    CHIAKIFS_FILE_TYPE ftype;                   \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\n    int                dblk&#91;CHIAKIFS_DATA_PER_FILE]; \/\/ \u30c7\u30fc\u30bf\u30d6\u30ed\u30c3\u30af\u756a\u53f7\n};  \n\nstruct chiakiFS_dentry_d\n{\n    char               fname&#91;CHIAKIFS_MAX_FILE_NAME]; \/\/ \u30d5\u30a1\u30a4\u30eb\u540d\n    CHIAKIFS_FILE_TYPE ftype;                     \/\/ \u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\n    uint32_t           ino;                       \/\/ \u6307\u5b9a\u3055\u308c\u305finode\u756a\u53f7\n};  \n\n#endif \/* _TYPES_H_ *\/<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u30c6\u30b9\u30c8<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Demo File System\u306e\u30c6\u30b9\u30c8<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30de\u30cb\u30e5\u30a2\u30eb\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<p>\u307e\u305a\u306f\u30c6\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u5c0e\u5165<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"zsh\">\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/user-land-filesystem\/fs\/demo]\n\u2514\u2500# cd tests &amp;&amp; .\/start.sh &amp;&amp; cd ..\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0137056 s, 306 MB\/s<\/code><\/pre>\n\n\n\n<p>\u30c7\u30a3\u30b9\u30af\u3092\u30de\u30a6\u30f3\u30c8<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/user-land-filesystem\/fs\/demo]\n\u2514\u2500# .\/build\/demo -f -d -s -o use_ino .\/tests\/mnt<\/code><\/pre>\n\n\n\n<p>\u4ed6\u306e\u30bf\u30fc\u30df\u30ca\u30eb\u3067\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3092\u5b9f\u884c\u3001<span class=\"swl-marker mark_green\">pass_task1.txt\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u3001\u30c6\u30b9\u30c8OK<\/span>\u3067\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"zsh\">\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/user-land-filesystem\/fs\/demo]\n\u2514\u2500# cd tests\n                                                                                \n\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/user-land-filesystem\/fs\/demo\/tests]\n\u2514\u2500# cd mnt\n                                                                                \n\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/\u2026\/fs\/demo\/tests\/mnt]\n\u2514\u2500# ls\npass_task1.txt\n                                                                                \n\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/\u2026\/fs\/demo\/tests\/mnt]\n\u2514\u2500# cd .. \n                                                                                \n\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/user-land-filesystem\/fs\/demo\/tests]\n\u2514\u2500# fusermount -uz mnt<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u306f\u30c7\u30a3\u30b9\u30af\u306e\u30ed\u30b0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FUSE library version: 2.9.9\nnullpath_ok: 0\nnopath: 0\nutime_omit_ok: 0\nunique: 2, opcode: INIT (26), nodeid: 0, insize: 104, pid: 0\nINIT: 7.40\nflags=0x73fffffb\nmax_readahead=0x00020000\nsuper.driver_fd: 4\n   INIT: 7.19\n   flags=0x00000011\n   max_readahead=0x00020000\n   max_write=0x00020000\n   max_background=0\n   congestion_threshold=0\n   unique: 2, success, outsize: 40\nunique: 4, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 5292\ngetattr \/\n   unique: 4, success, outsize: 120\nunique: 6, opcode: ACCESS (34), nodeid: 1, insize: 48, pid: 5292\n   unique: 6, error: -38 (Function not implemented), outsize: 16\nunique: 8, opcode: OPENDIR (27), nodeid: 1, insize: 48, pid: 6722\n   unique: 8, success, outsize: 32\nunique: 10, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 6722\ngetattr \/\n   unique: 10, success, outsize: 120\nunique: 12, opcode: READDIR (28), nodeid: 1, insize: 80, pid: 6722\nreaddir&#91;0] from 0\n   unique: 12, success, outsize: 56\nunique: 14, opcode: LOOKUP (1), nodeid: 1, insize: 55, pid: 6722\nLOOKUP \/pass_task1.txt\ngetattr \/pass_task1.txt\n   NODEID: 2\n   unique: 14, success, outsize: 144\nunique: 16, opcode: READDIR (28), nodeid: 1, insize: 80, pid: 6722\n   unique: 16, success, outsize: 16\nunique: 18, opcode: RELEASEDIR (29), nodeid: 1, insize: 64, pid: 0\n   unique: 18, success, outsize: 16\nunique: 20, opcode: LOOKUP (1), nodeid: 1, insize: 42, pid: 5292\nLOOKUP \/c\ngetattr \/c\n   NODEID: 3\n   unique: 20, success, outsize: 144\nunique: 22, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 5292\ngetattr \/\n   unique: 22, success, outsize: 120\nunique: 24, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 5292\ngetattr \/\n   unique: 24, success, outsize: 120\nunique: 26, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 5292\ngetattr \/\n   unique: 26, success, outsize: 120\nunique: 28, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 5292\ngetattr \/\n   unique: 28, success, outsize: 120<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u30aa\u30fc\u30c8\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<p>demo\/tests\u3067test.sh\u3092\u5b9f\u884c\u3001<span class=\"swl-marker mark_green\">Test Pass!!!\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u3001\u30c6\u30b9\u30c8OK<\/span>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"zsh\">\u250c\u2500\u2500(root\u327fAmamitsu)-&#91;~\/user-land-filesystem\/fs\/demo]\n\u2514\u2500# cd tests &amp;&amp; .\/test.sh &amp;&amp; cd ..\nTest Pass!!!<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">chiakiFS\u306e\u30c6\u30b9\u30c8<\/h3>\n\n\n\n<h4 class=\"wp-block-heading\">\u30aa\u30fc\u30c8\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<p>chiaki\/tests\u3067test.sh\u3092\u5b9f\u884c\u3001<span class=\"swl-marker mark_green\">\u304a\u3081\u3067\u3068\u3046\u3001All Test Pass!!!(34\/34)\u304c\u8868\u793a\u3055\u308c\u308c\u3070\u3001\u30c6\u30b9\u30c8OK<\/span>\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> .\/test.sh\n\u30c6\u30b9\u30c8\u65b9\u6cd5\u3092\u9078\u3093\u3067\u304f\u3060\u3055\u3044[N(\u57fa\u672c\u6a5f\u80fd\u30c6\u30b9\u30c8) \/ E(\u30a8\u30af\u30b9\u30c8\u30e9\u6a5f\u80fd\u30c6\u30b9\u30c8) \/ S(\u30b9\u30c6\u30c3\u30d7\u3054\u3068\u30c6\u30b9\u30c8)]: E\n\u30c6\u30b9\u30c8\uff1amount, mkdir, touch, ls, read&write, cp, umount\n\u30c6\u30b9\u30c8\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30a3\u30ec\u30af\u30c8\u30ea: \/root\/user-land-filesystem\/fs\/chiaki\/tests\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/mount.sh\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/mkdir.sh\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/touch.sh\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/ls.sh\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/remount.sh\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/rw.sh\n\u30c6\u30b9\u30c8\u30d1\u30c3\u30af: \/root\/user-land-filesystem\/fs\/chiaki\/tests\/stages\/cp.sh\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0135117 s, 310 MB\/s\n================================================================================\n<font color=\"#5EBDAB\">pass: case 1 - mount<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.00674529 s, 622 MB\/s\n================================================================================\n<font color=\"#5EBDAB\">pass: case 2.1 - mkdir \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0<\/font>\n<font color=\"#5EBDAB\">pass: case 2.2 - mkdir \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0\/dir0<\/font>\n<font color=\"#5EBDAB\">pass: case 2.3 - mkdir \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0\/dir0\/dir0<\/font>\n<font color=\"#5EBDAB\">pass: case 2.4 - mkdir \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir1<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0063167 s, 664 MB\/s\n================================================================================\n<font color=\"#5EBDAB\">pass: case 3.1 - touch \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file0<\/font>\n<font color=\"#5EBDAB\">pass: case 3.2 - touch \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file1<\/font>\n<font color=\"#5EBDAB\">pass: case 3.3 - touch \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0\/file1<\/font>\n<font color=\"#5EBDAB\">pass: case 3.4 - touch \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0\/file2<\/font>\n<font color=\"#5EBDAB\">pass: case 3.5 - touch \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir1\/file3<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0141014 s, 297 MB\/s\n================================================================================\n<font color=\"#5EBDAB\">pass: case 4.1 - ls \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/<\/font>\n<font color=\"#5EBDAB\">pass: case 4.2 - ls \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0<\/font>\n<font color=\"#5EBDAB\">pass: case 4.3 - ls \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0\/dir1<\/font>\n<font color=\"#5EBDAB\">pass: case 4.4 - ls \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/dir0\/dir1\/dir2<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.01359 s, 309 MB\/s\n================================================================================\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0147269 s, 285 MB\/s\n<font color=\"#5EBDAB\">pass: case 5.1 - umount \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt<\/font>\n<font color=\"#5EBDAB\">pass: case 5.2 - remount \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0139879 s, 300 MB\/s\n<font color=\"#5EBDAB\">pass: case 5.3 - check bitmap<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0152768 s, 275 MB\/s\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0131412 s, 319 MB\/s\n================================================================================\n<font color=\"#5EBDAB\">pass: case 6.1 - write \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file0<\/font>\n<font color=\"#5EBDAB\">pass: case 6.2 - read \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file0<\/font>\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.0146024 s, 287 MB\/s\n================================================================================\n<font color=\"#5EBDAB\">pass: case 7.1 - prepare content of \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file9<\/font>\n<font color=\"#5EBDAB\">pass: case 7.2 - copy \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file9 to \/root\/user-land-filesystem\/fs\/chiaki\/tests\/mnt\/file10<\/font>\n================================================================================ \nScore: 34\/34\n<font color=\"#5EBDAB\">pass: \u304a\u3081\u3067\u3068\u3046\u3001All Test Pass!!!(34\/34)<\/font><\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u30de\u30cb\u30e5\u30a2\u30eb\u30c6\u30b9\u30c8<\/h4>\n\n\n\n<p>\u4e0a\u8a18\u306e\u30aa\u30fc\u30c8\u30c6\u30b9\u30c8\u306f\u3001mount, mkdir, touch, ls, read&amp;write, cp, umount\u3060\u3051\u3092\u30c6\u30b9\u30c8\u3059\u308b\u3002<br>\u4ed6\u306e\u6a5f\u80fd\u3001\u3064\u307e\u308a\u30a8\u30af\u30b9\u30c8\u30e9\u30a8\u30af\u30b9\u30c8\u30e9\u6a5f\u80fd\u306e\u30c6\u30b9\u30c8\u306f\u3001\u30de\u30cb\u30e5\u30a2\u30eb\u7684\u306b\u884c\u3046\u3002<\/p>\n\n\n\n<p><strong>\u307e\u305a\u3001\u30d5\u30a1\u30a4\u30eb\u30b7\u30b9\u30c6\u30e0\u3092\u521d\u671f\u5316\u3057\u3001\u4e0a\u8ff0\u3057\u305f\u6a5f\u80fd\u3092\u30c6\u30b9\u30c8\u3059\u308b\u305f\u3081\u306e\u74b0\u5883\u3092\u69cb\u7bc9\u3057\u307e\u3059\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ddriver<\/font> <font color=\"#5EBDAB\">-r<\/font> \n\u30bf\u30fc\u30b2\u30c3\u30c8\u30c7\u30d0\u30a4\u30b9 \/root\/ddriver\n8192+0 records in\n8192+0 records out\n4194304 bytes (4.2 MB, 4.0 MiB) copied, 0.00637671 s, 658 MB\/s\n                                                                                                                                               \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">.\/build\/chiakiFS<\/font> <font color=\"#5EBDAB\">-f<\/font> <font color=\"#5EBDAB\">-d<\/font> <font color=\"#5EBDAB\">-o<\/font> use_ino <font color=\"#5EBDAB\">-s<\/font> <b>.\/tests\/mnt<\/b>\nFUSE library version: 2.9.9\nnullpath_ok: 0\nnopath: 0\nutime_omit_ok: 0\nunique: 2, opcode: INIT (26), nodeid: 0, insize: 104, pid: 0\nINIT: 7.40\nflags=0x73fffffb\nmax_readahead=0x00020000\nCHIAKIFS_DBG: inode map blocks: 1\n<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u624b\u9806\u3067\u30eb\u30fc\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea<code>~\/user-land-filesystem\/fs\/chiaki\/tests\/mnt<\/code>\u306b\u8a2d\u5b9a\u3057\u307e\u3059\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> \n<font color=\"#49AEE6\">touch<\/font> file.txt\n<font color=\"#49AEE6\">echo<\/font> <font color=\"#FEA44C\">&quot;This is file.txt, it is a simple file on the chiakiFS file system. Well there are just 1024 Bytes for this block. Lorem ipsum dolor sit amet, ccccc I do not know.&quot;<\/font> <font color=\"#277FFF\"><b>&gt;<\/b><\/font> file.txt\n<font color=\"#49AEE6\">mkdir<\/font> dir\n<font color=\"#49AEE6\">cd<\/font> dir\n<font color=\"#49AEE6\">touch<\/font> 1.asm\n<font color=\"#49AEE6\">echo<\/font> <font color=\"#5EBDAB\">-e<\/font> <font color=\"#FEA44C\">&quot;.text\\nLI a0,0xDEADBEEF\\nECALL&quot;<\/font> <font color=\"#277FFF\"><b>&gt;<\/b><\/font> 1.asm\n<font color=\"#49AEE6\">cd<\/font> <b>..<\/b>\n<font color=\"#49AEE6\">ln<\/font> <font color=\"#5EBDAB\">-s<\/font> dir dir_slink\n<font color=\"#49AEE6\">ln<\/font> dir\/1.asm asm.hlink\n<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u3067\u3001\u8ffd\u52a0\u306e\u30c6\u30b9\u30c8\u74b0\u5883\u304c\u69cb\u7bc9\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u6b21\u306b\u3001\u5404\u30d5\u30a1\u30a4\u30eb\u306e\u57fa\u672c\u7684\u306a\u5c5e\u6027\u3092\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> .\n  File: .\n  Size: 0         \tBlocks: 4096       IO Block: 1024   directory\nDevice: 0,62\tInode: 0           Links: 2\nAccess: (0777\/drwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:33:33.000000000 +0800\nModify: 2024-12-10 22:33:33.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> file.txt \n  File: file.txt\n  Size: 163       \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 1           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:33:35.000000000 +0800\nModify: 2024-12-10 22:33:35.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> dir\n  File: dir\n  Size: 136       \tBlocks: 0          IO Block: 1024   directory\nDevice: 0,62\tInode: 2           Links: 2\nAccess: (0777\/drwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:33:38.000000000 +0800\nModify: 2024-12-10 22:33:38.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> dir\/1.asm \n  File: dir\/1.asm\n  Size: 29        \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 3           Links: 2\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:33:43.000000000 +0800\nModify: 2024-12-10 22:33:43.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> dir_slink\n  File: dir_slink -> dir\n  Size: 3         \tBlocks: 0          IO Block: 1024   symbolic link\nDevice: 0,62\tInode: 4           Links: 1\nAccess: (0777\/lrwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:33:50.000000000 +0800\nModify: 2024-12-10 22:33:50.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> stat asm.hlink \n  File: asm.hlink\n  Size: 29        \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 3           Links: 2\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:33:55.000000000 +0800\nModify: 2024-12-10 22:33:55.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u69cb\u9020\u306f\u4ee5\u4e0b\u306e\u901a\u308a\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font>\nasm.hlink  dir  dir_slink  file.txt\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> dir\n1.asm\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 2 root root  29 Dec 10 22:33 asm.hlink\n2 drwxrwxrwx 2 root root 136 Dec 10 22:33 dir\n4 lrwxrwxrwx 1 root root   3 Dec 10 22:33 dir_slink -> dir\n1 -rwxrwxrwx 1 root root 163 Dec 10 22:33 file.txt\n\n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/user-land-filesystem\/fs\/chiaki\/tests<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> dir <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 2 root root 29 Dec 10 22:34 1.asm\n<\/code><\/pre>\n\n\n\n<p>\u3053\u308c\u306f\u3001\u4ee5\u524d\u306b\u63d0\u793a\u3057\u305f\u30aa\u30f3\u30c7\u30a3\u30b9\u30af\u69cb\u9020\u56f3\u3068\u4e00\u81f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30cf\u30fc\u30c9\u30ea\u30f3\u30af<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir\/1.asm<\/b>                  \n.text\nLI a0,0xDEADBEEF\nECALL\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>asm.hlink<\/b> \n.text\nLI a0,0xDEADBEEF\nECALL\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u5185\u5bb9\u3092\u5909\u66f4<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">echo<\/font> <font color=\"#5EBDAB\">-e<\/font> <font color=\"#FEA44C\">&quot;\\n.end of .text&quot;<\/font> <font color=\"#277FFF\"><b>&gt;&gt;<\/b><\/font> <b>asm.hlink<\/b>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir\/1.asm<\/b> \n.text\nLI a0,0xDEADBEEF\nECALL\n\n.end of .text\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u672c\u5f53\u306b\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30d5\u30a1\u30a4\u30eb\u30b3\u30d4\u30fc<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cp<\/font> <b>dir\/1.asm<\/b> dir\/copy.asm\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <b>dir<\/b> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 2 root root 44 Dec 10 22:36 <font color=\"#47D4B9\"><b>1.asm<\/b><\/font>\n5 -rwxrwxrwx 1 root root 44 Dec 10 22:36 <font color=\"#47D4B9\"><b>copy.asm<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir\/copy.asm<\/b>         \n.text\nLI a0,0xDEADBEEF\nECALL\n\n.end of .text\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir\/copy.asm<\/b>      \n  File: dir\/copy.asm\n  Size: 44        \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 5           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:37:09.000000000 +0800\nModify: 2024-12-10 22:37:09.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u65b0\u3057\u3044\u30d5\u30a1\u30a4\u30eb\u3068\u3057\u3066\u78ba\u8a8d\u3067\u304d\u3001\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30d5\u30a1\u30a4\u30eb\u540d\u5909\u66f4<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">mv<\/font> <b>dir\/copy.asm<\/b> dir\/rename.asm\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <b>dir<\/b> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 2 root root 44 Dec 10 22:50 <font color=\"#47D4B9\"><b>1.asm<\/b><\/font>\n5 -rwxrwxrwx 1 root root 44 Dec 10 22:50 <font color=\"#47D4B9\"><b>rename.asm<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir\/rename.asm<\/b> \n.text\nLI a0,0xDEADBEEF\nECALL\n\n.end of .text\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir\/rename.asm<\/b> \n  File: dir\/rename.asm\n  Size: 44        \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 5           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:50:26.000000000 +0800\nModify: 2024-12-10 22:50:26.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30d5\u30a1\u30a4\u30eb\u79fb\u52d5<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cd<\/font> <b>dir<\/b>            \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">mv<\/font> <b>rename.asm<\/b> ..\/moved.asm    \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <b>..<\/b> <font color=\"#5EBDAB\">-li<\/font> \ntotal 0\n3 -rwxrwxrwx 2 root root  44 Dec 10 22:51 <font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>\n2 drwxrwxrwx 2 root root 136 Dec 10 22:51 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n4 lrwxrwxrwx 1 root root   3 Dec 10 22:51 <font color=\"#05A1F7\"><b>dir_slink<\/b><\/font> -&gt; <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n1 -rwxrwxrwx 1 root root 163 Dec 10 22:51 <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n5 -rwxrwxrwx 1 root root  44 Dec 10 22:51 <font color=\"#47D4B9\"><b>moved.asm<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>..\/moved.asm<\/b>  \n.text\nLI a0,0xDEADBEEF\nECALL\n\n.end of .text\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>..\/moved.asm<\/b>  \n  File: ..\/moved.asm\n  Size: 44        \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 5           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:51:30.000000000 +0800\nModify: 2024-12-10 22:51:30.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30d5\u30a1\u30a4\u30eb\u524a\u9664<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">rm<\/font> <b>..\/moved.asm<\/b> \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <b>..<\/b> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 2 root root  44 Dec 10 22:51 <font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>\n2 drwxrwxrwx 2 root root 136 Dec 10 22:51 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n4 lrwxrwxrwx 1 root root   3 Dec 10 22:51 <font color=\"#05A1F7\"><b>dir_slink<\/b><\/font> -&gt; <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n1 -rwxrwxrwx 1 root root 163 Dec 10 22:51 <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> ..\/moved.asm\ncat: ..\/moved.asm: No such file or directory\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30bd\u30d5\u30c8\u30ea\u30f3\u30af<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/chiaki\/tests\/mnt\/dir<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cd<\/font> <b>..<\/b>           \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir_slink\/1.asm<\/b>\n.text\nLI a0,0xDEADBEEF\nECALL\n\n.end of .text\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">echo<\/font> <font color=\"#FEA44C\">&quot;Tested&quot;<\/font> <font color=\"#277FFF\"><b>&gt;<\/b><\/font> <b>dir_slink\/1.asm<\/b>       \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir\/1.asm<\/b>      \nTested\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir\/1.asm<\/b>     \n  File: dir\/1.asm\n  Size: 7         \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 3           Links: 2\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:53:35.000000000 +0800\nModify: 2024-12-10 22:53:35.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir_slink\/1.asm<\/b> \n  File: dir_slink\/1.asm\n  Size: 7         \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 3           Links: 2\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:53:42.000000000 +0800\nModify: 2024-12-10 22:53:42.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u30b3\u30d4\u30fc<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cp<\/font> <font color=\"#5EBDAB\">-r<\/font> <b>dir<\/b> directory      \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <font color=\"#5EBDAB\">-li<\/font>   \ntotal 0\n3 -rwxrwxrwx 2 root root   7 Dec 10 22:55 <font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>\n2 drwxrwxrwx 2 root root 136 Dec 10 22:55 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n4 lrwxrwxrwx 1 root root   3 Dec 10 22:55 <font color=\"#05A1F7\"><b>dir_slink<\/b><\/font> -&gt; <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n5 drwxrwxrwx 2 root root 136 Dec 10 22:55 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">directory<\/font><\/span>\n1 -rwxrwxrwx 1 root root 163 Dec 10 22:55 <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir<\/b>            \n  File: dir\n  Size: 136       \tBlocks: 0          IO Block: 1024   directory\nDevice: 0,62\tInode: 2           Links: 2\nAccess: (0777\/drwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:55:08.000000000 +0800\nModify: 2024-12-10 22:55:08.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>directory<\/b>      \n  File: directory\n  Size: 136       \tBlocks: 0          IO Block: 1024   directory\nDevice: 0,62\tInode: 5           Links: 2\nAccess: (0777\/drwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:55:13.000000000 +0800\nModify: 2024-12-10 22:55:13.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir\/1.asm<\/b>\n  File: dir\/1.asm\n  Size: 7         \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 3           Links: 2\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:55:19.000000000 +0800\nModify: 2024-12-10 22:55:19.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>directory\/1.asm<\/b>\n  File: directory\/1.asm\n  Size: 7         \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 6           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:55:23.000000000 +0800\nModify: 2024-12-10 22:55:23.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u30d5\u30a1\u30a4\u30eb\u3092\u6bd4\u8f03\u3001\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3001\u5185\u90e8\u306e\u30d5\u30a1\u30a4\u30eb\u304c\u65b0\u3057\u3044\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u540d\u5909\u66f4<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">mv<\/font> <b>directory<\/b> direname         \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 2 root root   7 Dec 10 22:56 <font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>\n2 drwxrwxrwx 2 root root 136 Dec 10 22:56 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n4 lrwxrwxrwx 1 root root   3 Dec 10 22:56 <font color=\"#05A1F7\"><b>dir_slink<\/b><\/font> -&gt; <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>\n5 drwxrwxrwx 2 root root 136 Dec 10 22:56 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">direname<\/font><\/span>\n1 -rwxrwxrwx 1 root root 163 Dec 10 22:56 <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>direname\/1.asm<\/b> \nTested\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <b>direname<\/b> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n6 -rwxrwxrwx 1 root root 7 Dec 10 22:56 <font color=\"#47D4B9\"><b>1.asm<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>direname<\/b>       \n  File: direname\n  Size: 136       \tBlocks: 0          IO Block: 1024   directory\nDevice: 0,62\tInode: 5           Links: 2\nAccess: (0777\/drwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:56:55.000000000 +0800\nModify: 2024-12-10 22:56:55.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>direname\/1.asm<\/b>\n  File: direname\/1.asm\n  Size: 7         \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 6           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:56:58.000000000 +0800\nModify: 2024-12-10 22:56:58.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u79fb\u52d5<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">mv<\/font> <b>direname<\/b> <b>dir<\/b>      \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font>             \n<font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>  <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">dir<\/font><\/span>  <font color=\"#05A1F7\"><b>dir_slink<\/b><\/font>  <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <b>dir<\/b> <font color=\"#5EBDAB\">-li<\/font>     \ntotal 0\n3 -rwxrwxrwx 2 root root   7 Dec 10 22:57 <font color=\"#47D4B9\"><b>1.asm<\/b><\/font>\n5 drwxrwxrwx 2 root root 136 Dec 10 22:57 <span style=\"background-color:#367BF0\"><font color=\"#1F2229\">direname<\/font><\/span>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>dir\/direname\/1.asm<\/b>\nTested\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>dir\/direname\/1.asm<\/b>\n  File: dir\/direname\/1.asm\n  Size: 7         \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 6           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 22:57:54.000000000 +0800\nModify: 2024-12-10 22:57:54.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u524a\u9664<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">rm<\/font> <font color=\"#5EBDAB\">-r<\/font> <b>dir<\/b>      \n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <font color=\"#5EBDAB\">-li<\/font>    \ntotal 0\n3 -rwxrwxrwx 1 root root   7 Dec 10 22:58 <font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>\n4 lrwxrwxrwx 1 root root   3 Dec 10 22:58 <span style=\"background-color:#1F2229\"><font color=\"#EC0101\"><b>dir_slink<\/b><\/font><\/span> -&gt; <span style=\"background-color:#1F2229\"><font color=\"#EC0101\"><b>dir<\/b><\/font><\/span>\n1 -rwxrwxrwx 1 root root 163 Dec 10 22:58 <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cd<\/font> <b>dir_slink<\/b>          \ncd: no such file or directory: dir_slink\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>asm.hlink<\/b>         \nTested\n<\/code><\/pre>\n\n\n\n<p>\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u524a\u9664\u3055\u308c\u3001\u30c7\u30c3\u30c9\u30ea\u30f3\u30af\u304c\u767a\u751f\u3002\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u4ee5\u524d\u306b\u4f5c\u6210\u3057\u305f\u30cf\u30fc\u30c9\u30ea\u30f3\u30af\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u30c7\u30fc\u30bf\u304c\u53d6\u5f97\u3067\u304d\u3001\u53c2\u7167\u30ab\u30a6\u30f3\u30c8\u304c1\u306b\u6e1b\u5c11\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u306b\u3088\u308a\u3001\u30cf\u30fc\u30c9\u30ea\u30f3\u30af\u8a2d\u8a08\u306e\u6b63\u78ba\u6027\u304c\u518d\u3073\u8a3c\u660e\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\ud83d\udcab<strong>vim\u3067\u306e\u30d5\u30a1\u30a4\u30eb\u8aad\u307f\u66f8\u304d\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"nohighlight\"><font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">vim<\/font> <b>file.txt<\/b>\n<pre class=\"wp-block-code\"><code class=\"nohighlight\">&#91;input as following]\n&#91;I]\nThis is file.txt, it is a simple file on the chiakiFS file system. Well there are just 1024 Bytes for this block. Lorem ipsum dolor sit amet, ccccc I do not know.\n&#91;Esc]&#91;:]&#91;w]&#91;q]&#91;Enter]&#91;y]<\/code><\/pre>                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">cat<\/font> <b>file.txt<\/b> \nThis is file.txt, it is a simple file on the chiakiFS file system. Well there are just 1024 Bytes for this block. Lorem ipsum dolor sit amet, ccccc I do not knowThis is file.txt, it is a simple file on the chiakiFS file system. Well there are just 1024 Bytes for this block. Lorem ipsum dolor sit amet, ccccc I do not know..\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">stat<\/font> <b>file.txt<\/b>          \n  File: file.txt\n  Size: 325       \tBlocks: 0          IO Block: 1024   regular file\nDevice: 0,62\tInode: 5           Links: 1\nAccess: (0777\/-rwxrwxrwx)  Uid: (    0\/    root)   Gid: (    0\/    root)\nAccess: 2024-12-10 23:01:27.000000000 +0800\nModify: 2024-12-10 23:01:27.000000000 +0800\nChange: 1970-01-01 08:00:00.000000000 +0800\n Birth: -\n                                                                                                                                                                                                                                  \n<font color=\"#367BF0\">\u250c\u2500\u2500(<\/font><font color=\"#EC0101\"><b>root\u327fAmamitsu<\/b><\/font><font color=\"#367BF0\">)-[<\/font><b>~\/\u2026\/fs\/chiaki\/tests\/mnt<\/b><font color=\"#367BF0\">]<\/font>\n<font color=\"#367BF0\">\u2514\u2500<\/font><font color=\"#EC0101\"><b>#<\/b><\/font> <font color=\"#49AEE6\">ls<\/font> <font color=\"#5EBDAB\">-li<\/font>\ntotal 0\n3 -rwxrwxrwx 1 root root   7 Dec 10 23:01 <font color=\"#47D4B9\"><b>asm.hlink<\/b><\/font>\n4 lrwxrwxrwx 1 root root   3 Dec 10 23:01 <span style=\"background-color:#1F2229\"><font color=\"#EC0101\"><b>dir_slink<\/b><\/font><\/span> -&gt; <span style=\"background-color:#1F2229\"><font color=\"#EC0101\"><b>dir<\/b><\/font><\/span>\n5 -rwxrwxrwx 1 root root 325 Dec 10 23:01 <font color=\"#47D4B9\"><b>file.txt<\/b><\/font>\n<\/code><\/pre>\n\n\n\n<p>\u6a5f\u80fd\u304c\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u3092\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<br>\u307e\u305f\u3001Visual Studio Code\u306b\u3088\u308b\u30d5\u30a1\u30a4\u30eb\u66f8\u304d\u8fbc\u307f\u52d5\u4f5c\u3082\u6b63\u5e38\u3067\u3042\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u308b\u305f\u3081\u3001\u3053\u3053\u3067\u306f\u8a73\u7d30\u3092\u5272\u611b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p class=\"has-text-align-center is-style-kakko_box\">\u4ee5\u4e0a\u3067\u3059<\/p>\n\n\n\n\n","protected":false},"excerpt":{"rendered":"<p>\u30cf\u30eb\u30d3\u30f3\u5de5\u696d\u5927\u5b66\uff08\u6df1\u5733\uff09\u2022 2024 \u2022 \u30aa\u30da\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u30b7\u30b9\u30c6\u30e0 Lab5 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"swell_btn_cv_data":"","_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[88,9],"tags":[],"class_list":["post-1535","post","type-post","status-publish","format-standard","hentry","category-operating-system","category-computerscience"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/posts\/1535","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/comments?post=1535"}],"version-history":[{"count":78,"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/posts\/1535\/revisions"}],"predecessor-version":[{"id":1910,"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/posts\/1535\/revisions\/1910"}],"wp:attachment":[{"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/media?parent=1535"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/categories?post=1535"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yanagichiaki.jp\/index.php\/wp-json\/wp\/v2\/tags?post=1535"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}