Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/libbb/find_mount_point.c

    r1765 r2725  
    55 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
    66 *
    7  * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
     7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
    88 */
    99
     
    1818 * filesystem.
    1919 */
    20 struct mntent *find_mount_point(const char *name, const char *table)
     20struct mntent* FAST_FUNC find_mount_point(const char *name, int subdir_too)
    2121{
    2222    struct stat s;
    23     dev_t mountDevice;
    24     FILE *mountTable;
     23    FILE *mtab_fp;
    2524    struct mntent *mountEntry;
     25    dev_t devno_of_name;
     26    bool block_dev;
    2627
    2728    if (stat(name, &s) != 0)
    28         return 0;
     29        return NULL;
    2930
    30     if ((s.st_mode & S_IFMT) == S_IFBLK)
    31         mountDevice = s.st_rdev;
    32     else
    33         mountDevice = s.st_dev;
     31    devno_of_name = s.st_dev;
     32    block_dev = 0;
     33    if (S_ISBLK(s.st_mode)) {
     34        devno_of_name = s.st_rdev;
     35        block_dev = 1;
     36    }
    3437
     38    mtab_fp = setmntent(bb_path_mtab_file, "r");
     39    if (!mtab_fp)
     40        return NULL;
    3541
    36     mountTable = setmntent(table ? table : bb_path_mtab_file, "r");
    37     if (!mountTable)
    38         return 0;
     42    while ((mountEntry = getmntent(mtab_fp)) != NULL) {
     43        /* rootfs mount in Linux 2.6 exists always,
     44         * and it makes sense to always ignore it.
     45         * Otherwise people can't reference their "real" root! */
     46        if (strcmp(mountEntry->mnt_fsname, "rootfs") == 0)
     47            continue;
    3948
    40     while ((mountEntry = getmntent(mountTable)) != 0) {
    4149        if (strcmp(name, mountEntry->mnt_dir) == 0
    4250         || strcmp(name, mountEntry->mnt_fsname) == 0
     
    4452            break;
    4553        }
    46         if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == mountDevice)  /* Match the device. */
     54
     55        if (!(subdir_too || block_dev))
     56            continue;
     57
     58        /* Is device's dev_t == name's dev_t? */
     59        if (stat(mountEntry->mnt_fsname, &s) == 0 && s.st_rdev == devno_of_name)
    4760            break;
    48         if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == mountDevice)  /* Match the directory's mount point. */
     61        /* Match the directory's mount point. */
     62        if (stat(mountEntry->mnt_dir, &s) == 0 && s.st_dev == devno_of_name)
    4963            break;
    5064    }
    51     endmntent(mountTable);
     65    endmntent(mtab_fp);
     66
    5267    return mountEntry;
    5368}
Note: See TracChangeset for help on using the changeset viewer.