libaums icon indicating copy to clipboard operation
libaums copied to clipboard

Create folder operation successful but after unplug/plug device folder is not there

Open diogowbrito opened this issue 9 years ago • 40 comments

I had noticed this behaviour at least since 3.0 but after pulling the latest code (5dfe700) it is still noticeable.

Steps to reproduce (even with the given test libaums app) are:

  1. Under any folder in root create a subfolder.
  2. The operation will go ok and the folder will be there.
  3. Unplug and plug the device.
  4. Navigate into that folder. The created folder is not there.

diogowbrito avatar Jun 28 '16 13:06 diogowbrito

Unfortunately I am not able to reproduce this currently.

Which Android version and which device are you using? Does this also happen if you use the genymotion simulator?

magnusja avatar Jul 18 '16 10:07 magnusja

@magnusja ya am also getting this bug as @diogowbrito say .If we create a folder in main root directory it will not disappear even we unplug the usb, But if we create a folder inside any folder in the root directory it will disappear once we un plug the usb.if we create a file it will not disappear this issue occur only if we create a folder under any folder in root directory.(The created folder only disapper after we unplug the usb)

Device info am testing : Samsung Galaxy On5 Pro Version-6.0 Model No-SM-G550FY Some screen shots Screen 1 Directory in root file -

screenshot_20161216-102900

Screen 2 Created a subfolder and file inside folder folderinroot

screenshot_20161216-102955

Screen3 After creating the folder and file i un-pluged the device and plugged back but now when i go to the folderinroot folder(name of folder in the root directory), i cant see the folder i created only the file is visble the folder created has disappear

screenshot_20161216-103028

What may be the reason for the disappearance of the folder i cant find anything on debugging ?, i think this is a high priority bug.

rameshvoltella avatar Dec 16 '16 05:12 rameshvoltella

Changes are written immediately to disk (https://github.com/magnusja/libaums/blob/develop/libaums/src/main/java/com/github/mjdev/libaums/fs/fat32/FatDirectory.java#L382). I quickly tested it with my example app, and did not have a problem. Do you have the same problem with my example?

Do you see the USB drive blinking when creating a directory? Do you see that there is actually data written in the logs, resp. if you debug?

How long do you wait until detaching the pen drive?

magnusja avatar Dec 16 '16 05:12 magnusja

@magnusja did you created a subfolder inside a folder in your example.

update @magnusja I have just recently test your current sample but the problem remains in the sample also,created file is not disappearing but created folder in subfolder of root folder is disappearing. again if we create a folder in the root directory remains only subfolder under any folder in root is disappearing(or deleted in some how)

I tested this in moto x .Folder created but there is no problem in moto x even we unplug it, moto x have no auto mount because it has no sdcard support, but in samsung device i test has auto mount. When i test deeply i found that we dont need to unplug the device to reproduce the issue when we close the UsbMassStorageDevice on on destory the device mount the usb drive and when we open sample app again and the folder will get disapper(On Samasung device i tested which support sdcard)

i checked the log

Log when create the folder in root

12-16 13:02:21.006 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: ViewPostImeInputStage processPointer 0 12-16 13:02:21.286 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: ViewPostImeInputStage processPointer 1 12-16 13:02:21.296 4437-4437/com.github.mjdev.usbfileman D/FsInfoStructure: writing to device 12-16 13:02:21.296 4437-4437/com.github.mjdev.usbfileman I/FAT: allocating clusters finished 12-16 13:02:21.296 4437-4437/com.github.mjdev.usbfileman D/FatDirectory: adding entry: [FatLfnDirectoryEntry getName()=amma] with short name: AM0000~0.000 12-16 13:02:21.296 4437-4437/com.github.mjdev.usbfileman W/Partition: we have to round up size to next block sector 12-16 13:02:21.301 4437-4437/com.github.mjdev.usbfileman D/ClusterChain: Init a cluster chain, reading from FAT 12-16 13:02:21.301 4437-4437/com.github.mjdev.usbfileman D/ClusterChain: Finished init of a cluster chain 12-16 13:02:21.301 4437-4437/com.github.mjdev.usbfileman W/Partition: we have to round up size to next block sector 12-16 13:02:21.311 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: #3 mView = null 12-16 13:02:21.331 4437-4437/com.github.mjdev.usbfileman D/AbsListView: onsize change 12-16 13:02:21.341 4437-4437/com.github.mjdev.usbfileman E/ViewRootImpl: sendUserActionEvent() mView == null 12-16 13:02:21.381 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 48 - 0, 0) vi=Rect(0, 48 - 0, 0) or=1

Log when creating subfolder

12-16 13:03:26.376 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: ViewPostImeInputStage processPointer 0 12-16 13:03:26.471 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: ViewPostImeInputStage processPointer 1 12-16 13:03:26.476 4437-4437/com.github.mjdev.usbfileman D/FsInfoStructure: writing to device 12-16 13:03:26.481 4437-4437/com.github.mjdev.usbfileman I/FAT: allocating clusters finished 12-16 13:03:26.481 4437-4437/com.github.mjdev.usbfileman D/FatDirectory: adding entry: [FatLfnDirectoryEntry getName()=iop] with short name: IO0000~0.000 12-16 13:03:26.481 4437-4437/com.github.mjdev.usbfileman W/Partition: we have to round up size to next block sector 12-16 13:03:26.486 4437-4437/com.github.mjdev.usbfileman D/ClusterChain: Init a cluster chain, reading from FAT 12-16 13:03:26.486 4437-4437/com.github.mjdev.usbfileman D/ClusterChain: Finished init of a cluster chain 12-16 13:03:26.486 4437-4437/com.github.mjdev.usbfileman W/Partition: we have to round up size to next block sector 12-16 13:03:26.501 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: #3 mView = null 12-16 13:03:26.511 4437-4437/com.github.mjdev.usbfileman D/AbsListView: onsize change 12-16 13:03:26.521 4437-4437/com.github.mjdev.usbfileman E/ViewRootImpl: sendUserActionEvent() mView == null 12-16 13:03:26.551 4437-4437/com.github.mjdev.usbfileman D/ViewRootImpl: MSG_RESIZED: ci=Rect(0, 48 - 0, 0) vi=Rect(0, 48 - 0, 0) or=1

i dont find any error while creating folder

The pendrive am using is ScanDisk CRUZER BLADE

what may be the reason for this type of issue?can you fix this i think its a major bug

rameshvoltella avatar Dec 16 '16 07:12 rameshvoltella

any solution? i try to do some change in lib but noting fix the issue

rameshvoltella avatar Dec 17 '16 08:12 rameshvoltella

@magnusja any solution?

rameshvoltella avatar Dec 19 '16 08:12 rameshvoltella

@rameshvoltella Unfortunately, I have no news. The only thing I find a little weird is that it says it has to round. But usually the file system stuff should always be aligned with the block size.

Can you tell me the block size of the drive and the cluster size of the FAT32?

Maybe you can uncomment the logs in Partition#write and ScsiBlockDevice#write.

magnusja avatar Dec 19 '16 23:12 magnusja

@magnusja

I/ScsiBlockDevice: Block size: 512

When create folder in sub folder

12-20 12:21:45.381 9740-9740/com.filemangerapp.anything D/ViewRootImpl: ViewPostImeInputStage processPointer 0 12-20 12:21:45.491 9740-9740/com.filemangerapp.anything D/ViewRootImpl: ViewPostImeInputStage processPointer 1 12-20 12:21:45.501 9740-9740/com.filemangerapp.anything D/ScsiBlockDevice: writing: ScsiWrite10 [blockAddress=2122, transferBytes=1024, blockSize=512, transferBlocks=2, getdCbwDataTransferLength()=1024] 12-20 12:21:45.501 9740-9740/com.filemangerapp.anything D/FsInfoStructure: writing to device 12-20 12:21:45.501 9740-9740/com.filemangerapp.anything D/ScsiBlockDevice: writing: ScsiWrite10 [blockAddress=2049, transferBytes=512, blockSize=512, transferBlocks=1, getdCbwDataTransferLength()=512] 12-20 12:21:45.506 9740-9740/com.filemangerapp.anything I/FAT: allocating clusters finished 12-20 12:21:45.506 9740-9740/com.filemangerapp.anything D/FatDirectory: adding entry: [FatLfnDirectoryEntry getName()=koop] with short name: KOOP 12-20 12:21:45.506 9740-9740/com.filemangerapp.anything W/ScsiBlockDevice: we have to round up size to next block sector 12-20 12:21:45.506 9740-9740/com.filemangerapp.anything D/ScsiBlockDevice: writing: ScsiWrite10 [blockAddress=6464, transferBytes=512, blockSize=512, transferBlocks=1, getdCbwDataTransferLength()=512] 12-20 12:21:45.511 9740-9740/com.filemangerapp.anything W/ScsiBlockDevice: we have to round up size to next block sector 12-20 12:21:45.511 9740-9740/com.filemangerapp.anything D/ScsiBlockDevice: writing: ScsiWrite10 [blockAddress=15360, transferBytes=512, blockSize=512, transferBlocks=1, getdCbwDataTransferLength()=512]

rameshvoltella avatar Dec 20 '16 06:12 rameshvoltella

Cluster size?

magnusja avatar Dec 21 '16 00:12 magnusja

I dont find the log for that

rameshvoltella avatar Dec 21 '16 00:12 rameshvoltella

FileSystem.getChunkSize()

magnusja avatar Dec 21 '16 00:12 magnusja

Wait for 10 min let me turn my laptop on once again where should i put the log to get the cluster size is that on fat. 32 class?

rameshvoltella avatar Dec 21 '16 00:12 rameshvoltella

Nah it's Partition.getFileSystem and then you can access that anywhere in your code.

magnusja avatar Dec 21 '16 00:12 magnusja

i dont get the methord getChunkSize()

is it partition.blockSize?

rameshvoltella avatar Dec 21 '16 00:12 rameshvoltella

Are you using current develop branch?

magnusja avatar Dec 21 '16 00:12 magnusja

yes your sample project let me recheck. ok i got the method sorry i was just wake up so little sleepy i put log in partition class inside public static Partition createPartition method like this

Log.d(TAG,"cluster sizee"+partition.fileSystem.getChunkSize());

rameshvoltella avatar Dec 21 '16 00:12 rameshvoltella

Should be there then.

Log.d(TAG, "Chunk size: " + currentFs.getChunkSize());

https://github.com/magnusja/libaums/blob/develop/app/src/main/java/com/github/mjdev/libaums/usbfileman/MainActivity.java#L574

magnusja avatar Dec 21 '16 00:12 magnusja

Chunk size: 32768

rameshvoltella avatar Dec 21 '16 00:12 rameshvoltella

Is it a 128GB stick?

magnusja avatar Dec 21 '16 00:12 magnusja

no its jut 4 gb pendrive, it working fine on Motorola device

rameshvoltella avatar Dec 21 '16 00:12 rameshvoltella

Okay interesting, I will format a stick of mine with 32K cluster size and then lets see what happens

magnusja avatar Dec 21 '16 00:12 magnusja

i tested in samsung device as i mentioned above it failed, but in moto device its working, do you think its issue with the pendrive or the devices. i only tested in samsung and moto device

rameshvoltella avatar Dec 21 '16 01:12 rameshvoltella

@magnusja r u testing now?

rameshvoltella avatar Dec 21 '16 01:12 rameshvoltella

Yes I did a test.

Fat32BootSector{bytesPerSector=512, sectorsPerCluster=64, reservedSectors=32, fatCount=2, totalNumberOfSectors=30713472, sectorsPerFat=3749, rootDirStartCluster=2, fsInfoStartSector=1, fatMirrored=true, validFat=0, volumeLabel=''}

I am still unable to reproduce. Do you have the problem also with my example app?

I think it might be a problem with your device. Data is definitely written to the USB drive. Maybe you the Motorola Android has buffering issues. Do you just plug it out or do you also wait until the call to UsbDevice.close() succeeded?

magnusja avatar Dec 21 '16 01:12 magnusja

i never un plug the device, the close call is a sucess because the samsung mount again after i close our example application. i have never unplug the device, also the issue is with samsung device not motorola, Am using the same example.yes definitely written to the USB drive. because i can open the folder and view files inside until i close UsbDevice.close() after that samsung device mount automatically. so after that again i open our app the folder is begin disapper

rameshvoltella avatar Dec 21 '16 01:12 rameshvoltella

I see. Can you maybe deactivate the mounting of the Samsung device? Maybe that interferes somehow with my library.

magnusja avatar Dec 21 '16 01:12 magnusja

@magnusja i dont find any option to stop that, Device info am testing : Samsung Galaxy On5 Pro Version-6.0 Model No-SM-G550FY

you can easily reproduce this issue if you use this model

i can make a video how this is happening if you want to see?

rameshvoltella avatar Dec 21 '16 01:12 rameshvoltella

@magnusja can you tell me what difference between when a file and folder creation because the files created in subfolder of root directory is not disappearing, only folder is disappearing.(so that i can give a try to fix this) what does dotdot entry do when create a sub folder?

rameshvoltella avatar Dec 21 '16 01:12 rameshvoltella

Yeah I don't have that model and I don't think that I am going to buy it :D Nah, I belive you.

Okay that is interesting. The content of a file can be any bytes you wish. The content of directories is in a certain format: fat directory entries. Each entry is 32 bytes and describes either another sub dir or a file.

The dot and the dotdot entries are special entries every directory has (except root dir). Dot entry is a link to the current directory you are in. dotdot is a link to the parent directory.

You can find a detailed description in my thesis.

magnusja avatar Dec 21 '16 01:12 magnusja

@magnusja let me give a try :)

rameshvoltella avatar Dec 21 '16 02:12 rameshvoltella