Merge "Remove MTD cruft from init."
This commit is contained in:
commit
90db709a2f
|
@ -382,22 +382,7 @@ static int do_mount(const std::vector<std::string>& args) {
|
|||
source = args[2].c_str();
|
||||
target = args[3].c_str();
|
||||
|
||||
if (!strncmp(source, "mtd@", 4)) {
|
||||
n = mtd_name_to_number(source + 4);
|
||||
if (n < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
snprintf(tmp, sizeof(tmp), "/dev/block/mtdblock%d", n);
|
||||
|
||||
if (wait)
|
||||
wait_for_file(tmp, COMMAND_RETRY_TIMEOUT);
|
||||
if (mount(tmp, target, system, flags, options) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
goto exit_success;
|
||||
} else if (!strncmp(source, "loop@", 5)) {
|
||||
if (!strncmp(source, "loop@", 5)) {
|
||||
int mode, loop, fd;
|
||||
struct loop_info info;
|
||||
|
||||
|
|
|
@ -311,8 +311,6 @@ mount_all <fstab> [ <path> ]*
|
|||
|
||||
mount <type> <device> <dir> [ <flag> ]* [<options>]
|
||||
Attempt to mount the named device at the directory <dir>
|
||||
<device> may be of the form mtd@name to specify a mtd block
|
||||
device by name.
|
||||
<flag>s include "ro", "rw", "remount", "noatime", ...
|
||||
<options> include "barrier=1", "noauto_da_alloc", "discard", ... as
|
||||
a comma separated string, eg: barrier=1,noauto_da_alloc
|
||||
|
|
|
@ -119,22 +119,13 @@ void set_device_permission(int nargs, char **args)
|
|||
return;
|
||||
}
|
||||
|
||||
/* If path starts with mtd@ lookup the mount number. */
|
||||
if (!strncmp(name, "mtd@", 4)) {
|
||||
int n = mtd_name_to_number(name + 4);
|
||||
if (n >= 0)
|
||||
asprintf(&tmp, "/dev/mtd/mtd%d", n);
|
||||
name = tmp;
|
||||
} else {
|
||||
int len = strlen(name);
|
||||
char *wildcard_chr = strchr(name, '*');
|
||||
if ((name[len - 1] == '*') &&
|
||||
(wildcard_chr == (name + len - 1))) {
|
||||
prefix = 1;
|
||||
name[len - 1] = '\0';
|
||||
} else if (wildcard_chr) {
|
||||
wildcard = 1;
|
||||
}
|
||||
int len = strlen(name);
|
||||
char *wildcard_chr = strchr(name, '*');
|
||||
if ((name[len - 1] == '*') && (wildcard_chr == (name + len - 1))) {
|
||||
prefix = 1;
|
||||
name[len - 1] = '\0';
|
||||
} else if (wildcard_chr) {
|
||||
wildcard = 1;
|
||||
}
|
||||
|
||||
perm = strtol(args[1], &endptr, 8);
|
||||
|
|
|
@ -199,78 +199,6 @@ int write_file(const char* path, const char* content) {
|
|||
return result;
|
||||
}
|
||||
|
||||
#define MAX_MTD_PARTITIONS 16
|
||||
|
||||
static struct {
|
||||
char name[16];
|
||||
int number;
|
||||
} mtd_part_map[MAX_MTD_PARTITIONS];
|
||||
|
||||
static int mtd_part_count = -1;
|
||||
|
||||
static void find_mtd_partitions(void)
|
||||
{
|
||||
int fd;
|
||||
char buf[1024];
|
||||
char *pmtdbufp;
|
||||
ssize_t pmtdsize;
|
||||
int r;
|
||||
|
||||
fd = open("/proc/mtd", O_RDONLY|O_CLOEXEC);
|
||||
if (fd < 0)
|
||||
return;
|
||||
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
pmtdsize = read(fd, buf, sizeof(buf) - 1);
|
||||
pmtdbufp = buf;
|
||||
while (pmtdsize > 0) {
|
||||
int mtdnum, mtdsize, mtderasesize;
|
||||
char mtdname[16];
|
||||
mtdname[0] = '\0';
|
||||
mtdnum = -1;
|
||||
r = sscanf(pmtdbufp, "mtd%d: %x %x %15s",
|
||||
&mtdnum, &mtdsize, &mtderasesize, mtdname);
|
||||
if ((r == 4) && (mtdname[0] == '"')) {
|
||||
char *x = strchr(mtdname + 1, '"');
|
||||
if (x) {
|
||||
*x = 0;
|
||||
}
|
||||
INFO("mtd partition %d, %s\n", mtdnum, mtdname + 1);
|
||||
if (mtd_part_count < MAX_MTD_PARTITIONS) {
|
||||
strcpy(mtd_part_map[mtd_part_count].name, mtdname + 1);
|
||||
mtd_part_map[mtd_part_count].number = mtdnum;
|
||||
mtd_part_count++;
|
||||
} else {
|
||||
ERROR("too many mtd partitions\n");
|
||||
}
|
||||
}
|
||||
while (pmtdsize > 0 && *pmtdbufp != '\n') {
|
||||
pmtdbufp++;
|
||||
pmtdsize--;
|
||||
}
|
||||
if (pmtdsize > 0) {
|
||||
pmtdbufp++;
|
||||
pmtdsize--;
|
||||
}
|
||||
}
|
||||
close(fd);
|
||||
}
|
||||
|
||||
int mtd_name_to_number(const char *name)
|
||||
{
|
||||
int n;
|
||||
if (mtd_part_count < 0) {
|
||||
mtd_part_count = 0;
|
||||
find_mtd_partitions();
|
||||
}
|
||||
for (n = 0; n < mtd_part_count; n++) {
|
||||
if (!strcmp(name, mtd_part_map[n].name)) {
|
||||
return mtd_part_map[n].number;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
time_t gettime() {
|
||||
timespec now;
|
||||
clock_gettime(CLOCK_MONOTONIC, &now);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#define COLDBOOT_DONE "/dev/.coldboot_done"
|
||||
|
||||
int mtd_name_to_number(const char *name);
|
||||
int create_socket(const char *name, int type, mode_t perm,
|
||||
uid_t uid, gid_t gid, const char *socketcon);
|
||||
|
||||
|
|
Loading…
Reference in New Issue