Changeset 2149


Ignore:
Timestamp:
Aug 23, 2012, 3:30:06 PM (6 years ago)
Author:
matthijs
Message:

mountd: Restructure handling of unsupported filesystems.

Before, there were checks for supportedness of filesystem in different
places, which checked for different things. Now, a single check is done,
which is saved in memory and used in other places. Also, some checks
which weren't really needed have been removed.

Furthermore, unsupported filesystems now _do_ end up in the internal
mounts list and the uci file, instead of being skipped entirely.

Location:
trunk/fon/mountd/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/fon/mountd/src/include/lib/fs.h

    r1027 r2149  
    1 #define NONE            -1
    2 #define MBR                     2
    3 #define EXT2            3
    4 #define EXT3            4
    5 #define FAT                     5
    6 #define HFSPLUS         6
    7 #define EFI                     7
    8 #define NTFS            8
    9 #define EXTENDED        9
     1/* When changing these, don't forget to update fs_names in mount.c */
     2#define NONE            0
     3#define EXT2            1
     4#define EXT3            2
     5#define FAT             3
     6#define NTFS            4
     7#define HFSPLUS         5
     8
     9#define MAX_SUPPORTED   HFSPLUS
     10#define EFI             6
     11#define EXTENDED        7
     12#define MBR             8
    1013
    1114int detect_fs(char *device);
  • trunk/fon/mountd/src/lib/mount.c

    r2147 r2149  
    4040        char rev[64];
    4141        int mounted;
     42        int supported;
    4243        int ignore;
    4344        char size[64];
     
    135136
    136137char *fs_names[] = {
    137         "",
    138         "",
    139         "MBR",
     138        "UNKNOWN",
    140139        "EXT2",
    141140        "EXT3",
    142141        "FAT",
     142        "NTFS",
    143143        "HFSPLUS",
    144144        "EFI",
    145         "NTFS",
    146         "EXTENDED"
     145        "EXTENDED",
     146        "MBR"
    147147};
    148148
     
    208208                struct mount *q = container_of(p, struct mount, list);
    209209                char t[64];
    210                 if(q->fs == EXTENDED)
    211                         continue;
    212210                ucix_add_section(ctx, mountd, q->serial, type);
    213211                strcpy(t, q->dev);
     
    222220                snprintf(t, 64, "size%d", atoi(&q->dev[3]));
    223221                ucix_add_option(ctx, mountd, q->serial, t, q->size);
    224                 if(q->fs > MBR && q->fs <= NTFS)
    225                 {
    226                         snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
    227                         ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
    228                 }
     222                snprintf(t, 64, "fs%d", atoi(&q->dev[3]));
     223                ucix_add_option(ctx, mountd, q->serial, t, fs_names[q->fs]);
    229224                if(q->mounted)
    230225                        mounted++;
     
    443438        char tmp[64], tmp2[64];
    444439        int i;
    445         if(fs <= MBR || fs > NTFS)
    446                 return;
     440
    447441        mount  = malloc(sizeof(struct mount));
    448442        INIT_LIST_HEAD(&mount->list);
     
    458452        mount->mounted = 0;
    459453        mount->fs = fs;
     454        mount->supported = mount->fs && mount->fs <= MAX_SUPPORTED;
    460455        for(i = 0; i < 16; i++)
    461456                mount->wd_path[i] = 0;
    462457        list_add(&mount->list, &mounts);
    463         if((!mount->ignore) && (mount->fs > MBR) && (mount->fs <= NTFS))
     458        if((!mount->ignore) && mount->supported)
    464459        {
    465460                log_printf("new mount : %s -> %s (%s)\n", name, dev, fs_names[mount->fs]);
     
    542537                return -1;
    543538        }
    544         if(mount->ignore || mount->mounted || mount->fs == EXTENDED)
    545                 return -1;
    546539        snprintf(tmp, 256, "%s%s", path, mount->dev);
    547540        log_printf("mounting %s\n", tmp);
Note: See TracChangeset for help on using the changeset viewer.