int main(int argc, char *argv[]) { char ans[2]; char *fileargs[64]; char *optargs[64]; int n_options; int index; int help_flag = 0; #ifdef __TURBOC__ setvect(0x23, ctrlc_hndlr); #else _dos_setvect(0x23, ctrlc_hndlr); #endif atexit(on_exit); n_options = classify_args(argc, argv, fileargs, optargs); for (index=0;index<n_options;index++) { if (optargs[index][0] == '?') help_flag=1; else { myprintf("Invalid parameter - /",0); myprintf(optargs[index],0); /* removed strupr */ myprintf("\r\n",0); exit(1); } /* end else. */ } /* end for. */ if (help_flag) { myprintf("\r\nLABEL Version " VERSION "\r\n", 0); myprintf("Creates, changes or deletes the volume label of a disk.\r\n",0); myprintf("\r\n",0); myprintf("Syntax: LABEL [drive:][label] [/?]\r\n",0); myprintf(" [drive:] Specifies which drive you want to label\r\n",0); myprintf(" [label] Specifies the new label you want to label the drive\r\n",0); myprintf(" /? Displays this help message\r\n",0); return 0; } /* end if. */ do_cmdline(argc, argv); if (*Drive == '?') /* If no drive specified, use current. */ GetDrive(); /* Save current directory and move to root. */ GetCurDir(curdir); if (curdir[0] != 0) { *rootdir = *Drive; SetCurDir(rootdir); } /* end if. */ /* If no label was specified, show current one first and then get new one. */ if (*Label == '\0') { disp_label(); get_label(); } /* end if. */ /* If they entered an empty label, then ask them if they want to */ /* delete the existing volume label. */ if ((*Label == '\0') && (!NoLabel)) { do { myprintf("\nDelete current volume label (Y/N)? ",0); mygets(ans,2); /* WHY not use getch? ??? */ } /* end do. */ while (((*ans=(char)toupper(*ans)) != 'Y') && (*ans != 'N')); if (toupper(*ans) == 'N') exit(1); } /* end if. */ /* Delete the old volume label. */ del_label(); /* Create the new one, if there is one to create. */ if (*Label != '\0') { if (make_label()) { exit(1); } /* end if. */ } /* end if. */ exit(0); return 0; } /* end main. */
int main(int argc, char *argv[]) { if (argc > 1) return do_cmdline(argc, argv); int res; static char *const cmd[] = { "/init", NULL }; umask(000); // Init only the little we need, leave the rest for real init mkdir("/dev", 0755); mkdir("/dev/pts", 0755); mkdir("/dev/socket", 0755); mkdir("/proc", 0755); mkdir("/sys", 0755); mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755"); mount("devpts", "/dev/pts", "devpts", 0, NULL); mount("proc", "/proc", "proc", 0, NULL); mount("sysfs", "/sys", "sysfs", 0, NULL); mount("pstore", "/sys/fs/pstore", "pstore", 0, NULL); #if MR_USE_DEBUGFS_MOUNT // Mount the debugfs kernel sysfs mkdir("/sys/kernel/debug", 0755); mount("debugfs", "/sys/kernel/debug", "debugfs", 0, NULL); #endif klog_init(); // output all messages to dmesg, // but it is possible to filter out INFO messages klog_set_level(6); mrom_set_log_tag("trampoline"); INFO("Running trampoline v%d\n", VERSION_TRAMPOLINE); if(is_charger_mode()) { INFO("Charger mode detected, skipping multirom\n"); goto run_main_init; } #if MR_DEVICE_HOOKS >= 3 tramp_hook_before_device_init(); #endif INFO("Initializing devices...\n"); devices_init(); INFO("Done initializing\n"); run_core(); // close and destroy everything devices_close(); run_main_init: umount("/dev/pts"); rmdir("/dev/pts"); rmdir("/dev/socket"); if(access(KEEP_REALDATA, F_OK) < 0) { umount("/dev"); } #if MR_USE_DEBUGFS_MOUNT umount("/sys/kernel/debug"); #endif umount("/proc"); umount("/sys/fs/pstore"); umount("/sys"); INFO("Running main_init\n"); fixup_symlinks(); chmod("/main_init", EXEC_MASK); rename("/main_init", "/init"); res = execve(cmd[0], cmd, NULL); ERROR("execve returned %d %d %s\n", res, errno, strerror(errno)); return 0; }