mkdir() error on RFS

Xiang Cui medivhc at gmail.com
Sat Jul 2 15:01:53 UTC 2011


Hi,

mkdir("test/..",0777) on RFS seems to raise an error. It should return
EEXIST. The test code is something like the below and I omit all the
check of status code to make it clean.
I use sparc_sis and RTEMS 4.11.

#include <bsp.h>
#include <stdio.h>
#include <stdlib.h>
#include <rtems.h>
#include <rtems/ramdisk.h>
#include <rtems/blkdev.h>
#include <rtems/libio.h>
#include <rtems/bdbuf.h>
#include <rtems/rtems-rfs.h>
#include <rtems/rtems-rfs-format.h>
#define  RAMDISK_BLOCK_SIZE  (512)
#define  RAMDKSI_BLOCK_COUNT (512)
#define  BLOCK_SIZE          (512)
#define  RAMDISK_PATH "/ramdisk"
rtems_rfs_format_config config=
{
        block_size:BLOCK_SIZE
};
dev_t dev = 0;
int  init_ramdisk(const char * ramdisk_path)
{
        int rc=0;
        rc =rtems_disk_io_initialize();
        rc =ramdisk_register(RAMDISK_BLOCK_SIZE,RAMDISK_BLOCK_SIZE,false,ramdisk_path,&dev);
        return rc;
}
int  initialize_filesystem(const char* base)
{
        int rc=0;
        rc=mkdir(base,0777);
        init_ramdisk(RAMDISK_PATH);
        rc=rtems_rfs_format(RAMDISK_PATH,&config);
#if 1
        rc=mount(RAMDISK_PATH,
                        base,
                        "rfs",
                        RTEMS_FILESYSTEM_READ_WRITE,
                        NULL);
#else
        rc=mount(NULL,
                        base,
                        "imfs",
                        RTEMS_FILESYSTEM_READ_WRITE,
                        NULL);
#endif
        return rc;
}
rtems_task Init(
                rtems_task_argument ignored)
{
        int rc=0;
        char *path="mnt";
        rc =initialize_filesystem(path);

        rc=chdir(path);
        rc=mkdir("test",0777);
        puts("test");

        rc=mkdir("test/..",0777);
        if (rc!=0)
                perror("mkdir error");

        puts("end");
        exit( 0 );
}
/* configuration */
/* drivers */
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
/* filesystem */
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
#define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS   40
#define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK    512
#define CONFIGURE_MAXIMUM_DRIVERS                  10
#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK
#define CONFIGURE_SWAPOUT_TASK_PRIORITY            10
#define CONFIGURE_MAXIMUM_TASKS                    rtems_resource_unlimited (10)
#define CONFIGURE_MAXIMUM_SEMAPHORES               rtems_resource_unlimited (10)
#define CONFIGURE_MAXIMUM_MESSAGE_QUEUES           rtems_resource_unlimited (5)
#define CONFIGURE_MAXIMUM_PARTITIONS               rtems_resource_unlimited (2)
#define CONFIGURE_UNIFIED_WORK_AREAS
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_FILESYSTEM_RFS
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
/* end of file */




More information about the users mailing list