3 Tomato Firmware modified - AKA: ugly hacks
4 Copyright (C) 2007 Augusto Bott
5 Modified by Tomasz S³odkowicz for SDHC/MMC driver v2.0.1
11 #include <sys/mount.h>
13 static void error(const char *message
)
17 snprintf(s
, sizeof(s
), "Error %s SDHC/MMC. Check the logs to see if they contain more details about this error.", message
);
29 const char *mmc_fs_type
;
30 const char *mmc_part_number
;
31 const char *mmc_exec_mount
;
33 if (!nvram_match("mmc_on", "1")) {
34 notice_set("mmc", "");
37 if (((mmc_cs
= nvram_get("mmc_cs")) != NULL
) && (*mmc_cs
!= 0) &&
38 ((mmc_cl
= nvram_get("mmc_clk")) != NULL
) && (*mmc_cl
!= 0) &&
39 ((mmc_di
= nvram_get("mmc_din")) != NULL
) && (*mmc_di
!= 0) &&
40 ((mmc_do
= nvram_get("mmc_dout")) != NULL
) && (*mmc_do
!= 0)) {
41 snprintf(p
[0], sizeof(p
[0]), "cs=%s", mmc_cs
);
42 snprintf(p
[1], sizeof(p
[1]), "clk=%s", mmc_cl
);
43 snprintf(p
[2], sizeof(p
[2]), "din=%s", mmc_di
);
44 snprintf(p
[3], sizeof(p
[3]), "dout=%s", mmc_do
);
45 } else *p
[0]=*p
[1]=*p
[2]=*p
[3]=0;
46 if (eval("modprobe", "-s", "mmc", "major=121", "dbg=1", p
[0], p
[1], p
[2], p
[3]) != 0) {
47 error("loading module for");
50 if (((mmc_fs_type
= nvram_get("mmc_fs_type")) != NULL
) && (*mmc_fs_type
!= 0) &&
51 ((mmc_part_number
= nvram_get("mmc_fs_partition")) != NULL
) && (*mmc_part_number
!= 0)) {
52 if (modprobe(mmc_fs_type
) != 0 ) {
54 error("loading filesystem module for");
57 snprintf(s
, sizeof(s
), "/dev/mmc/disc0/part%s", mmc_part_number
);
58 if (mount(s
, "/opt", mmc_fs_type
, MS_NOATIME
|MS_NODIRATIME
, "") != 0) {
59 modprobe_r(mmc_fs_type
);
64 if (((mmc_exec_mount
= nvram_get("mmc_exec_mount")) != NULL
) && (*mmc_exec_mount
!= 0)) {
66 xstart(mmc_exec_mount
);
70 notice_set("mmc", "");
75 if (!wait_action_idle(10)) return;
76 eval(nvram_safe_get("mmc_exec_umount"));
77 notice_set("mmc", "");
79 if (umount ("/opt") != 0) {
84 modprobe_r(nvram_safe_get("mmc_fs_type"));