トップ «前の日記(2013-07-25) 最新 次の日記(2013-07-27)» 編集

ヨタの日々

2001|08|09|10|11|12|
2002|01|02|03|04|05|06|07|08|09|10|11|12|
2003|01|02|03|04|05|06|07|08|09|10|11|12|
2004|01|02|03|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|12|
2024|01|02|03|04|05|

2013-07-26 :-(

_ 午前

0520 起床

0730 仮眠

0900 ガジェット

_ 午後

1300 ガジェット

_

1800 ガジェット

2330 退勤

2430 飯

_ [du][NetBSD]/usr/bin/du

du を眺めるなど。

fts を利用してディレクトリ構造をたどりながらファイルの stat をかき集めて ブロックサイズを印字する。という流れらしい。

The fts functions are provided for traversing UNIX file hierarchies.

du.c はこちら

http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/usr.bin/du/du.c

fts_open してひたすら fts_read してく

 if ((fts = fts_open(argv, ftsoptions, NULL)) == NULL)
   err(1, "fts_open `%s'", *argv);
 for (rval = 0; (p = fts_read(fts)) != NULL;) {
   if (nflag) {

かき集めながら印字か

/*
 * If listing each file, or a non-directory file was
 * the root of a traversal, display the total.
 */
if (listfiles || !p->fts_level)
  prstat(p->fts_path, COUNT);

COUNT は冒頭に定義されている。

/* Count inodes or file size */
#define	COUNT	(iflag ? 1 : p->fts_statp->st_blocks)

st_blocks は stat(2) のメンバー変数。ブロック数を表す。

st_blocks   The actual number of blocks allocated for the file in
            512-byte units.  As short symbolic links are stored in
            the inode, this number may be zero.

fts.c はつまり木構造をたどっていくry

http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/lib/libc/gen/fts.c