Page 1 of 1

[Solved} 4.30 FileSize() on a RAM disk

Posted: Fri Jan 16, 2009 1:37 pm
by infratec
Hi together,

I tried to communicate between 2 programs and I use files to do this.
I simply check if a specific file exits and than I delete it.

For the check I use the FileSize() procedure as suggested.

On the normal filesystem (ext3) it works.
To avoid many harddisk accesses I installed a ramdisk with

mount -t tmpfs tmpfs /tmp/ramdisk -o size=64k,mode=01777

The disks works. I can read and write to the disk.

But FileSize("/tmp/ramdisk/test") hangs.

Any idea ???

Best regards,

Bernd

Posted: Fri Jan 16, 2009 1:47 pm
by Thalius
hmm just as a tought - are the permissions correctly set ( eg filesize needs +x iirc. ) ?

Posted: Fri Jan 16, 2009 1:52 pm
by infratec
Thanks for the fast response.

But why to hell needs FileSize() execution rights on the file?

So I never can use this function on a 644 file ???

But that's not true.
Because if I try it on /tmp/test which is ext3 it works.


Bernd

Posted: Fri Jan 16, 2009 7:41 pm
by flaith
hi,

i tried the same way under Debian etch but inside mnt directory :

Code: Select all

flaith@wooky:/mnt$ sudo mkdir ramdisk
flaith@wooky:/mnt$ sudo mount -t tmpfs tmpfs /mnt/ramdisk/ -o size=64k,mode=01777
flaith@wooky:/mnt$ cd ramdisk/
flaith@wooky:/mnt/ramdisk$ vi test.txt
Put everything you want inside "test.txt"

With Pb a

Code: Select all

Debug FileSize("/mnt/ramdisk/test.txt")
gives 22
so it works :)

Posted: Fri Jan 16, 2009 11:36 pm
by Thalius
the x part was just guessed. so it just needs read rights - had not too much time but in my case i had the wrong permissions set on the dir inside mnt while accessing from a non sudo'ed user ... :roll: -- clearly sometimes a day working with windows can hurt your thinking lol :)

Posted: Sat Jan 17, 2009 12:30 pm
by infratec
Now I'm at home and I checked it with my Kubuntu 8.10 installation.

Result:

FileSize() works correct!

I have an other problem:

Directly behind the filesize check I try to delete the file in an endless loop.
And that is my problem.

At work I can't see this, because the target PC has only 800x600 screen resolution,
and than I can not read the PureBASIC Menu and output: it is to small.

I have to check this now.

As normal user I can not delete a file from user root, but it has 666 as rights.
So it should be possible.

Bernd

Posted: Sat Jan 17, 2009 12:55 pm
by infratec
Hi ,

PROBLEM SOLVED !

It was the mount command!

I set the sticky bit, that was my fault.
With the sticky bit on a directory, only the owner can do a delete,
even when the rights are 666 or 777.

And when I tried it in /tmp, I didn't recognize that kubuntu also has the sticky bit on the
/tmp directory!

(I think on SuSE /tmp has no sticky bit set)

So:

If you want to use a RAM disk as information exchange directory, where the files should be fully accessible, use mode=0777 and not mode=01777

Best regards and thanks,

Bernd