int mount_new(char *path, char *dev);
-struct list_head mounts;
+static struct list_head mounts;
struct mount {
struct list_head list;
int fs;
};
-char *fs_names[] = {
+static char *fs_names[] = {
"",
"",
"mbr",
#define MAX_MOUNTED 32
#define MAX_MOUNT_NAME 32
-char mounted[MAX_MOUNTED][3][MAX_MOUNT_NAME];
-int mounted_count = 0;
+static char mounted[MAX_MOUNTED][3][MAX_MOUNT_NAME];
+static int mounted_count = 0;
extern char uci_path[32];
static void mount_dump_uci_state(void)
{
struct mount *mount;
char tmp[64], tmp2[64];
- if(fs <= MBR || fs > LASTFS)
- return;
+
mount = malloc(sizeof(struct mount));
INIT_LIST_HEAD(&mount->list);
strncpy(mount->vendor, vendor, 64);
mount->mounted = 0;
mount->fs = fs;
list_add(&mount->list, &mounts);
- if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= LASTFS))
+ if (!mount->ignore)
{
log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
snprintf(tmp, 64, "%s%s", uci_path, name);
snprintf(tmp2, 64, "/tmp/run/mountd/%s", dev);
symlink(tmp2, tmp);
- mount_new("/tmp/run/mountd/", dev);
- system_printf("ACTION=add DEVICE=%s NAME=%s /sbin/hotplug-call mount", dev, name);
+ if (!mount_new("/tmp/run/mountd/", dev))
+ system_printf("ACTION=add DEVICE=%s NAME=%s /sbin/hotplug-call mount", dev, name);
}
}
if(!fp)
{
log_printf("error reading /proc/mounts");
- fclose(fp);
return avail;
}
- while((fgets(tmp, 256, fp) > 0) && (avail == -1))
+ while((fgets(tmp, 256, fp) != NULL) && (avail == -1))
{
char *t;
char tmp2[32];
fp = fopen(tmp2, "r");
if(fp)
{
- while(fgets(tmp2, 64, fp) > 0)
+ while(fgets(tmp2, 64, fp) != NULL)
{
serial = strstr(tmp2, "Serial Number:");
if(serial)
char sector_size[64];
FILE *fp;
int offset = 3;
+ int fs;
strcpy(name, dev);
if (!strncmp(name, "mmcblk", 6))
fclose(fp);
}
snprintf(tmp, 64, "/dev/%s", dev);
- mount_add_list(node, dev, s, vendor, model, rev, ignore, size, sector_size, detect_fs(tmp));
+ fs = detect_fs(tmp);
+ if (fs <= MBR || fs > LASTFS) {
+ ignore = 1;
+ }
+ mount_add_list(node, dev, s, vendor, model, rev, ignore, size, sector_size, fs);
mount_dump_uci_state();
}
}
if(!fp)
{
log_printf("error reading /proc/mounts");
- fclose(fp);
return;
}
mounted_count = 0;
- while(fgets(tmp, 256, fp) > 0)
+ while(fgets(tmp, 256, fp) != NULL)
{
char *t, *t2;
t = strstr(tmp, " ");
return 0;
}
#define MAX_BLOCK 64
-char block[MAX_BLOCK][MAX_BLOCK];
-int blk_cnt = 0;
+static char block[MAX_BLOCK][MAX_BLOCK];
+static int blk_cnt = 0;
static int check_block(char *b)
{