Linux2010. 1. 8. 16:26
# mount -t ntfs-3g

머.. 이런식으로 실행하면 자동으로 mount.ntfs-3g 라는 파일을 찾아서 실행을 한다.
처음에는 오 졸라 신기해!!! 하면서 뻘짓으로 ..

make 과정중에 나온 intall-exec-hook 인줄 알고 파고 들었다가 웬걸 ㄱ-
아무튼 install-exec-hook은 설치후 trigger 식으로 실행해주는 루틴을 의미할 뿐,
execution hook 이랑은 연관이 없다. (젠장 된장 미네랄!)
[링크 : http://wiki.kldp.org/wiki.php/DocbookSgml/Autotools-KLDP]

아무튼, linux kernel utils 를 검색해서 mount.c 를 열어보니 busybox와는 다른 확연한 차이가 있었다.
일단 exec() 패밀리와 fork()를 사용하는 루틴의 존재유무

util-linux-2.12r/mount/mount.c

01static int
02check_special_mountprog(const char *spec, const char *node, const char *type,
03            int flags, char *extra_opts, int *status) {
04  char mountprog[120];
05  struct stat statbuf;
06  int res;
07 
08  if (!external_allowed)
09      return 0;
10 
11  if (type && strlen(type) < 100) {
12       sprintf(mountprog, "/sbin/mount.%s", type);
13       if (stat(mountprog, &statbuf) == 0) {
14        res = fork();
15        if (res == 0) {
16         const char *oo, *mountargs[10];
17         int i = 0;
18 
19         setuid(getuid());
20         setgid(getgid());
21         oo = fix_opts_string (flags, extra_opts, NULL);
22         mountargs[i++] = mountprog;
23         mountargs[i++] = spec;
24         mountargs[i++] = node;
25         if (nomtab)
26              mountargs[i++] = "-n";
27         if (verbose)
28              mountargs[i++] = "-v";
29         if (oo && *oo) {
30              mountargs[i++] = "-o";
31              mountargs[i++] = oo;
32         }
33         mountargs[i] = NULL;
34         execv(mountprog, (char **) mountargs);
35         exit(1);   /* exec failed */
36        } else if (res != -1) {
37         int st;
38         wait(&st);
39         *status = (WIFEXITED(st) ? WEXITSTATUS(st) : EX_SYSERR);
40         return 1;
41        } else {
42             int errsv = errno;
43         error(_("mount: cannot fork: %s"), strerror(errsv));
44        }
45       }
46  }
47  return 0;
48}

위에 소스에서 보면

sprintf(mountprog, "/sbin/mount.%s", type);
res = fork();
execv(mountprog, (char **) mountargs);

mount -t ntfs 는 mount.ntfs 로
mount -t cifs 는 mount.cifs 로

-t type 으로 받은 인자를 이용하여 실행을 넘겨준다.



결론 : busybox에서는 mount 소스가 많이 간략화 되어있으므로
         표준 mount 파일에서 지원하는 mount.type 실행치환 기능을 지원하지 않는다.

[링크 : ftp://ftp.kernel.org/pub/linux/utils/util-linux/] 리눅스용 mount.c
[링크 : http://www.koders.com/c/fid840A8124E3B838F1EC7B690C35A7A6F9BF10277B.aspx] busybox용 mount.c

'Linux' 카테고리의 다른 글

linux에 연결된 HDD의 IO 상태보기  (0) 2010.01.11
fork-exec 종료시 리턴값  (0) 2010.01.11
ntfs-3g 크로스 컴파일 하기 (ntfs-3g cross compile)  (0) 2010.01.07
FUSE 넌 머냐?  (0) 2010.01.07
ntfs-3g at Tuxera  (0) 2010.01.06
Posted by 구차니