<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def status(stats=False, config=False, internals=False, superblock=False, alldevs=False):
    '''
    Show the full status of the BCache system and optionally all it's involved devices

    CLI example:

    .. code-block:: bash

        salt '*' bcache.status
        salt '*' bcache.status stats=True
        salt '*' bcache.status internals=True alldevs=True

    :param stats: include statistics
    :param config: include settings
    :param internals: include internals
    :param superblock: include superblock
    '''
    bdevs = []
    for _, links, _ in salt.utils.path.os_walk('/sys/block/'):
        for block in links:
            if 'bcache' in block:
                continue

            for spath, sdirs, _ in salt.utils.path.os_walk('/sys/block/{0}'.format(block), followlinks=False):
                if 'bcache' in sdirs:
                    bdevs.append(os.path.basename(spath))
    statii = {}
    for bcache in bdevs:
        statii[bcache] = device(bcache, stats, config, internals, superblock)

    cuuid = uuid()
    cdev = _bdev()
    if cdev:
        count = 0
        for dev in statii:
            if dev != cdev:
                # it's a backing dev
                if statii[dev]['cache'] == cuuid:
                    count += 1
        statii[cdev]['attached_backing_devices'] = count

        if not alldevs:
            statii = statii[cdev]

    return statii