UNIX 6th code reading - ãã¡ã¤ã«ã·ã¹ãã æ¦è¦ãã®ï¼
ã¯ããã«
前回のエントリã®ç¶ãã§ãä»åãUNIX v6ã®ãã¡ã¤ã«ã·ã¹ãã ãè¦ã¦ããã¾ãã
ååã¯ãããã¯ããã¤ã¹ãä¸å¿ã«è¦ã¦ããã¾ãããä»åã¯ã³ã¢ã¡ã¢ãªãä¸å¿ã«è¦ã¦ããã¾ãã
ã³ã¢ã¡ã¢ãªä¸ã®ãã¡ã¤ã«é¢ä¿ã®ãã¼ã¿æ§é
inodeæ§é ä½
ã¢ã¯ãã£ããªãã¡ã¤ã«ã®inodeãªã©ã¯ã³ã¢ã¡ã¢ãªä¸ã®inode[]æ§é ä½ã®é å(5659è¡ç®ã§å®ç¾©)ã«æ ¼ç´ããã¾ãããããã¯ãã£ã¹ã¯ä¸ã§æ±ãããinodeæ§é ä½ã®å®ç¾©(5605è¡ç®ã§å®ç¾©)ã¨ä¸èº«ãå°ãç°ãªãã¾ãã®ã§æ³¨æãã¦ãã ããã
inodeæ§é ä½ã¯i_countã¨ããåç §ã«ã¦ã³ãããã£ã¦ããããã®ã«ã¦ã³ãã0ã ã£ãå ´åããã®inodeã¨ã³ããªã¯å²ããã¦ããã¦ããªã空ãã¨ã³ããªã¨ã¿ãªããã¾ãã
fileæ§é ä½
ãã¡ã¤ã«ããªã¼ãã³ããã¨ã5507è¡ç®ã§å®£è¨ããã¦ããfileæ§é ä½ã®é åã«ã¨ã³ããªã追å ããã¾ãã
fileæ§é ä½ã¯READ, WRITE, PIPEã示ããã©ã°ãæã¡ãã¾ããREAD, WRITEã«ãããã対å¿ãããªãã»ãã(èªã¿æ¸ãä¸ã®ãã¤ã)ãæã¡ã¾ãã
fileæ§é ä½ã¯å¯¾å¿ããinodeã¸ã®ãã¤ã³ã¿ãæã¡ã¾ãã
u.u_ofile
u.u_ofileé åã¯ããã®ããã»ã¹ãéãã¦ãããã¡ã¤ã«(fileã®ã¨ã³ããª)ã¸ã®ãã¤ã³ã¿ãæ ¼ç´ãã¾ãã
newproc( )ãè¦ãã¨ãããã¾ãããåããã»ã¹ã«ã¯u.u_ofile[]ã®æ å ±ã¯å¼ãç¶ããã¾ã(1876-1878è¡ç®)ãã¤ã¾ãã親ãéãã¦ãããã¡ã¤ã«æ å ±ã¯ãåã«ãã®ã¾ã¾å¼ãç¶ããã¾ãã
ä¸è¨ãçµµã§ã¾ã¨ããã¨ãããªæãã§ãã
fileã¨inodeãåãã¦ããã®ã§ãè¤æ°ã®ããã»ã¹ãããä¸ã¤ã®ãã¡ã¤ã«ã«å¯¾ããç¬ç«ããèªã¿æ¸ããªãã»ããã¨èªã¿æ¸ãã¢ã¼ããæã¤ãã¨ãã§ãã¾ããããã«ãããè¤æ°ãã¡ã¤ã«ç¬ç«ã«ãã¡ã¤ã«ã®èªã¿æ¸ããè¡ãããããªãã¾ãã
ãã¡ã¤ã«ã®èªã¿è¾¼ã¿ããã¡ã¤ã«ã¸ã®æ¸ãè¾¼ã¿
ã¦ã¼ã¶ããã»ã¹ã¯ã·ã¹ãã ã³ã¼ã«ã使ã£ã¦ãã¡ã¤ã«ããã¦ã¼ã¶ç©ºéã«ãã¼ã¿ãèªã¿è¾¼ã¿ãã¦ã¼ã¶ç©ºéãããã¡ã¤ã«ã¸ãã¼ã¿ãæ¸ãè¾¼ã¿ã¾ãã
ãã¡ã¤ã«é¢ä¿ã®ã·ã¹ãã ã³ã¼ã«ã«ã¤ãã¦ã¯ãå¾ã®ã¨ã³ããªã§è©³ç´°ãã¾ã¨ããäºå®ã§ãã
çµããã«
ä»åã¯ã³ã¢ã¡ã¢ãªä¸ã§ã®ãã¡ã¤ã«å¨ãã®ãã¼ã¿æ§é ã解説ãã¾ããã
次åã¯ãããã¯ããã¤ã¹ããã³ã¢ã¡ã¢ãªã¸ã®inodeå²ãå½ã¦ã解説ããäºå®ã§ãã
å½åã¯Lionsæ¬ã«å¾ã£ã¦è§£èª¬ãããäºå®ã§ããããLionsæ¬ã®ãã¡ã¤ã«ã·ã¹ãã å¨ãã®è§£èª¬ããããã¥ããæããã®ã§ãèªåãªãã«ã¾ã¨ãã¦ãããã¨ã«ãã¾ããã