Changeset 07c833f in rtems


Ignore:
Timestamp:
Dec 19, 2016, 8:54:16 AM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
ade135d4
Parents:
4aba8d79
git-author:
Sebastian Huber <sebastian.huber@…> (12/19/16 08:54:16)
git-committer:
Sebastian Huber <sebastian.huber@…> (12/20/16 07:26:21)
Message:

JFFS2: Add RTEMS_JFFS2_GET_INFO

Add IO control RTEMS_JFFS2_GET_INFO to get some JFFS2 filesystem
instance information.

Update #2844.

Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libfs/src/jffs2/include/rtems/jffs2.h

    r4aba8d79 r07c833f  
    11/*
    2  * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
     2 * Copyright (c) 2013, 2016 embedded brains GmbH.  All rights reserved.
    33 *
    44 *  embedded brains GmbH
     
    1818#include <rtems/fs.h>
    1919#include <sys/param.h>
     20#include <sys/ioccom.h>
    2021#include <zlib.h>
    2122
     
    456457);
    457458
     459/**
     460 * @brief JFFS2 filesystem instance information.
     461 *
     462 * @see RTEMS_JFFS2_GET_INFO.
     463 */
     464typedef struct {
     465  /**
     466   * @brief Flash size in bytes.
     467   */
     468  uint32_t flash_size;
     469
     470  /**
     471   * @brief Count of flash blocks (eraseable units).
     472   */
     473  uint32_t flash_blocks;
     474
     475  /**
     476   * @brief Size of a flash block in bytes.
     477   */
     478  uint32_t flash_block_size;
     479
     480  /**
     481   * @brief Used size in bytes.
     482   *
     483   * Used areas contain valid data.
     484   */
     485  uint32_t used_size;
     486
     487  /**
     488   * @brief Dirty size in bytes.
     489   *
     490   * Used areas contain no longer used data.
     491   */
     492  uint32_t dirty_size;
     493
     494  /**
     495   * @brief Wasted size in bytes.
     496   *
     497   * Wasted areas are unusable.
     498   */
     499  uint32_t wasted_size;
     500
     501  /**
     502   * @brief Free size in bytes.
     503   *
     504   * Free areas may be used to store new data.
     505   */
     506  uint32_t free_size;
     507
     508  /**
     509   * @brief Bad size in bytes.
     510   *
     511   * Bad areas indicate damaged flash blocks.
     512   */
     513  uint32_t bad_size;
     514
     515  /**
     516   * @brief Count of clean blocks.
     517   *
     518   * Clean blocks contain only used areas.
     519   */
     520  uint32_t clean_blocks;
     521
     522  /**
     523   * @brief Count of dirty blocks.
     524   *
     525   * Dirty blocks contain dirty and used areas.
     526   */
     527  uint32_t dirty_blocks;
     528
     529  /**
     530   * @brief Count of erasable blocks.
     531   *
     532   * Erase blocks contain only dirty or wasted areas.
     533   */
     534  uint32_t erasable_blocks;
     535
     536  /**
     537   * @brief Count of free blocks.
     538   *
     539   * Free blocks contain a free area.
     540   */
     541  uint32_t free_blocks;
     542
     543  /**
     544   * @brief Count of bad blocks.
     545   *
     546   * Bad blocks are damaged.
     547   */
     548  uint32_t bad_blocks;
     549} rtems_jffs2_info;
     550
     551/**
     552 * @brief IO control to get the JFFS2 filesystem instance information.
     553 *
     554 * @see rtems_jffs2_info.
     555 */
     556#define RTEMS_JFFS2_GET_INFO _IOR('F', 1, rtems_jffs2_info)
     557
    458558/** @} */
    459559
  • cpukit/libfs/src/jffs2/src/fs-rtems.c

    r4aba8d79 r07c833f  
    55 * Copyright © 2001-2007 Red Hat, Inc.
    66 * Copyright © 2004-2010 David Woodhouse <dwmw2@infradead.org>
    7  * Copyright © 2013 embedded brains GmbH <rtems@embedded-brains.de>
     7 * Copyright © 2013, 2016 embedded brains GmbH <rtems@embedded-brains.de>
    88 *
    99 * Created by Dominic Ostrowski <dominic.ostrowski@3glab.com>
     
    513513}
    514514
     515static uint32_t rtems_jffs2_count_blocks(const struct list_head *list)
     516{
     517        uint32_t count = 0;
     518        struct jffs2_eraseblock *jeb;
     519
     520        list_for_each_entry(jeb, list, list) {
     521                ++count;
     522        }
     523
     524        return count;
     525}
     526
     527static void rtems_jffs2_get_info(
     528        const struct jffs2_sb_info *c,
     529        rtems_jffs2_info           *info
     530)
     531{
     532        info->flash_size = c->flash_size;
     533        info->flash_blocks = c->nr_blocks;
     534        info->flash_block_size = c->sector_size;
     535        info->used_size = c->used_size;
     536        info->dirty_size = c->dirty_size;
     537        info->wasted_size = c->wasted_size;
     538        info->free_size = c->free_size;
     539        info->bad_size = c->bad_size;
     540        info->clean_blocks = rtems_jffs2_count_blocks(&c->clean_list);
     541        info->dirty_blocks = rtems_jffs2_count_blocks(&c->very_dirty_list)
     542                + rtems_jffs2_count_blocks(&c->dirty_list);
     543        info->dirty_blocks += c->gcblock != NULL;
     544        info->erasable_blocks = rtems_jffs2_count_blocks(&c->erasable_list)
     545                + rtems_jffs2_count_blocks(&c->erasable_pending_wbuf_list)
     546                + rtems_jffs2_count_blocks(&c->erasing_list)
     547                + rtems_jffs2_count_blocks(&c->erase_checking_list)
     548                + rtems_jffs2_count_blocks(&c->erase_pending_list)
     549                + rtems_jffs2_count_blocks(&c->erase_complete_list);
     550        info->free_blocks = rtems_jffs2_count_blocks(&c->free_list);
     551        info->free_blocks += c->nextblock != NULL;
     552        info->bad_blocks = rtems_jffs2_count_blocks(&c->bad_list);
     553}
     554
     555static int rtems_jffs2_ioctl(
     556        rtems_libio_t   *iop,
     557        ioctl_command_t  request,
     558        void            *buffer
     559)
     560{
     561        struct _inode *inode = rtems_jffs2_get_inode_by_iop(iop);
     562        int eno;
     563
     564        rtems_jffs2_do_lock(inode->i_sb);
     565
     566        switch (request) {
     567                case RTEMS_JFFS2_GET_INFO:
     568                        rtems_jffs2_get_info(&inode->i_sb->jffs2_sb, buffer);
     569                        eno = 0;
     570                        break;
     571                default:
     572                        eno = EINVAL;
     573                        break;
     574        }
     575
     576        rtems_jffs2_do_unlock(inode->i_sb);
     577
     578        return rtems_jffs2_eno_to_rv_and_errno(eno);
     579}
     580
    515581static const rtems_filesystem_file_handlers_r rtems_jffs2_directory_handlers = {
    516582        .open_h = rtems_filesystem_default_open,
     
    518584        .read_h = rtems_jffs2_dir_read,
    519585        .write_h = rtems_filesystem_default_write,
    520         .ioctl_h = rtems_filesystem_default_ioctl,
     586        .ioctl_h = rtems_jffs2_ioctl,
    521587        .lseek_h = rtems_filesystem_default_lseek_directory,
    522588        .fstat_h = rtems_jffs2_fstat,
     
    660726        .read_h = rtems_jffs2_file_read,
    661727        .write_h = rtems_jffs2_file_write,
    662         .ioctl_h = rtems_filesystem_default_ioctl,
     728        .ioctl_h = rtems_jffs2_ioctl,
    663729        .lseek_h = rtems_filesystem_default_lseek_file,
    664730        .fstat_h = rtems_jffs2_fstat,
     
    678744        .read_h = rtems_filesystem_default_read,
    679745        .write_h = rtems_filesystem_default_write,
    680         .ioctl_h = rtems_filesystem_default_ioctl,
     746        .ioctl_h = rtems_jffs2_ioctl,
    681747        .lseek_h = rtems_filesystem_default_lseek,
    682748        .fstat_h = rtems_jffs2_fstat,
  • testsuites/fstests/Makefile.am

    r4aba8d79 r07c833f  
    22
    33_SUBDIRS =
     4_SUBDIRS += fsjffs2gc01
    45_SUBDIRS += fsimfsconfig03
    56_SUBDIRS += fsimfsconfig02
  • testsuites/fstests/configure.ac

    r4aba8d79 r07c833f  
    7878# Explicitly list all Makefiles here
    7979AC_CONFIG_FILES([Makefile
     80fsjffs2gc01/Makefile
    8081fsimfsconfig03/Makefile
    8182fsimfsconfig02/Makefile
Note: See TracChangeset for help on using the changeset viewer.