[Solved} 4.30 FileSize() on a RAM disk

Linux specific forum
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

[Solved} 4.30 FileSize() on a RAM disk

Post 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
Last edited by infratec on Sat Jan 17, 2009 6:53 pm, edited 1 time in total.
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

hmm just as a tought - are the permissions correctly set ( eg filesize needs +x iirc. ) ?
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Post 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
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Post 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 :)
“Fear is a reaction. Courage is a decision.” - WC
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post 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 :)
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone! ;)"
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Post 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
infratec
Always Here
Always Here
Posts: 7662
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Post 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
Post Reply