Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

FreeRTOS+FAT ff_mkdir strange behavior

Posted by maketych on November 17, 2017

Hi all,

I am using FreeRTOS version 9.0.0 and FreeRTOS+FAT version 160919 with patch 0001-Changes-since-160919 to work with SD card and USB flash drive on LPC1788.

During testing I noticed that when i trying to create directory with name same as disk mount point it will successfuly create directory with empty name on the disk :

I mounted usb flash drive to point "/usb". Mount was successful, i can see files and folders on the drive.

Then for test purposes i call ffmkdir("/usb") awaiting that it return me some error, for example FFERRDIROBJECT_EXISTS, but it was successful !

Looking in flash disk drive i see new directory whith empty name that can not be entered or deleted.

Only formating whole drive helps remove it ))

Same thing happens with SD card mounted to "/sd" and calling ff_mkdir("/sd").

Is it normal ?


FreeRTOS+FAT ff_mkdir strange behavior

Posted by heinbali01 on November 17, 2017

Hi Sergey,

when i trying to create directory with name same as disk mount point it will successfully create directory with empty name on the disk :

Yes, we were aware of this. After creation there will be a physical directory "/usb", and a logical (mounted) directory with the same name.

I mounted usb flash drive to point "/usb". Mount was successful, i can see files and folders on the drive.

Indeed, when you access /usb, the logical ( mounted ) directory will prevail.

Then for test purposes i call ff_mkdir("/usb") awaiting that it return me some error, for example FF_ERR_DIR_OBJECT_EXISTS, but it was successful !

You're right, formally this should be checked for.

Looking in flash disk drive i see new directory whith empty name that can not be entered or deleted.

There is indeed a bit of a problem here, also FTP shows two directories: a virtual one, and a physical directory on an SD-card.

Only formatting whole drive helps remove it ))

Not true. When using the FF_ functions, the directory can be emptied and removed. As you have probably seen, the ff_ functions from ff_stdio.c are aware of the mounted directories. FF_ functions have an I/O manager as a parameter, and these functions are working on physical drives only.

Is it normal ?

We always seek a balance between simplicity and completeness, correctness.

I was aware that a physical directory can be created, while a mounted directory already exists. But what should the library say if you mount a drive on "/usr", while a directory with that name already exists. Do you want the mount to fail? Personally, I think that the physical directory should be ignored by the "ff_" functions. And yes, a call to ff_mkdir should fail.

Some work has to be done here.


FreeRTOS+FAT ff_mkdir strange behavior

Posted by maketych on November 20, 2017

Hi Hein,

Thanks for the answer.

I gues I am not accurately described the situation. In steps it looks like this:

1 Start the system, no any drives mounted, nothing created.

2 Only mount USB flash drive to point "/usb". Nothing else mounted or created.

3 Call ff_mkdir("/usb").

4 Do nothing.

In result it creates directory whith emty name on USB flash drive, not in root of virtual FS. Path of this directory is "/usb/ ". How can it be deleted if it have no name? When i plug this usb flash drive on Windows it looks like folder with no name (see screenshot in attachment, blue line mark). And it can not be deleted, because Windows trying to delete whole usb drive, seems like this empty name directory is linked to usb drive itself. Only formatting the drive solve it.

Attachments


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS