Linux에서 마운트 정보를 읽어보자. getmntent() 가 바로 그것이다. 아쉽게도 POSIX, ANSI, IEEE 표준이 아니며, 리눅스 와 SunOS , HP-UX 등에서 사용할 수 있으며, FreeBSD 에서는 getmntinfo() 로부터 알아낼 수 있다. 이 함수는 내부 버퍼를 사용하기 때문에 쓰레드에 안전하지 않으며, getmntent_r() 으로 쓰레드에 대응할 수 있다. 자, 먼저 getmntent()를 하기 앞서, 마운트 정보를 읽고 쓸 수 있도록 핸들을 얻어와야하는데 그것을 하는 것이 setmntent() 이고, 다 쓴 핸들을 닫을 때 쓰는 것이 endmntent() 이다. 만약 중간에 마운트 정보를 바꿨으면, endmntent()할 때 비로소 적용된다. 자세한 것은 man페이지를 참조하고, 간단하게 C++로 마운트 목록을 보여주는 프로그램을 짜보았다. #include <iostream> #include <list> #include <string> #include <cstdio> #include <errno.h> using namespace std; #include <mntent.h> typedef struct me_type { string fsname; string dir; string type; string opts; int freq; int passno; } me_type; typedef list<me_type> me_list; bool getMountList(me_list& ml) { ml.clear(); struct mntent * mnt; cons...