Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » al_findfirst cannot "see" other users files on linux?

This thread is locked; no one can reply to it. rss feed Print
al_findfirst cannot "see" other users files on linux?
kronoman
Member #2,911
November 2002
avatar

Hi, I have this problem, my game searches for files using al_findfirst.
I'm using Allegro WIP 4.18
Well, when the files are owned by the user that is running the game, all is fine.
Now, when the files are stored in /usr/share/games/kball/levels, the game cannot find them.

ls /usr/share/games/kball/levels
10.map  14.map  2.map  5.map  8.map       easy.fmp
trainer.fmp
11.map  15.map  3.map  6.map  9.map       hard.fmp
12.map  1.map   4.map  7.map  deluxe.fmp  medium.fmp

This files have the permissions:
rw-r--r- 1 root root

To read the dir, I'm doing

 ret = al_findfirst(path_str, &dir_reader,(FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_LABEL | FA_ARCH));

        while (!ret)
        {
                menu.add_item_to_menu(dir_reader.name);
                ret = al_findnext(&dir_reader);
        }

        al_findclose(&dir_reader);

The path str and everything is set perfectly, in fact, if I change the owner of the same files in the same dir (/usr/blah) to the current user, the game will run perfectly.

So, I think that is a Allegro fault.

I need to store the things like that (in /usr/blah) to do the Debian package.
I'm helping someone to do the packages for it.

So, well, how do I solve this ? (making al_findfirst find someone else owned files?)

Elias
Member #358
May 2000

Can you post a small testcase?

--
"Either help out or stop whining" - Evert

kronoman
Member #2,911
November 2002
avatar

damn, with the test code, I can see the files. :o
I don't know what is wrong... :(

Test code:

1#include <stdio.h>
2#include <allegro.h>
3 
4int main()
5{
6 struct al_ffblk dir_reader;
7 int ret = 0;
8
9 if (allegro_init() != 0)
10 return 1;
11 
12 printf("starting\n\n");
13 
14 ret = al_findfirst("/usr/share/games/kball/levels/*.map", &dir_reader, (FA_RDONLY | FA_HIDDEN | FA_SYSTEM | FA_LABEL | FA_ARCH));
15 
16 while (!ret)
17 {
18 printf("file : %s\n", dir_reader.name);
19 ret = al_findnext(&dir_reader);
20 }
21 
22 al_findclose(&dir_reader);
23 
24 printf("\n\ndone\n\n");
25 
26 return 0;
27}
28END_OF_MAIN();

Test commands:

1[root@localhost kronoman]# mkdir /usr/share/games/kball
2[root@localhost kronoman]# mkdir /usr/share/games/kball/levels
3[root@localhost kronoman]# echo > /usr/share/games/kball/levels/1.map
4[root@localhost kronoman]# echo > /usr/share/games/kball/levels/2.map
5[root@localhost kronoman]# echo > /usr/share/games/kball/levels/3.map
6[root@localhost kronoman]# echo > /usr/share/games/kball/levels/4.map
7[root@localhost kronoman]# echo > /usr/share/games/kball/levels/5.map
8[root@localhost kronoman]# ls -l /usr/share/ga
9gal-2.0 games
10[root@localhost kronoman]# ls -l /usr/share/games/kball/levels/
11total 20
12-rw-r--r-- 1 root root 1 abr 5 17:11 1.map
13-rw-r--r-- 1 root root 1 abr 5 17:11 2.map
14-rw-r--r-- 1 root root 1 abr 5 17:11 3.map
15-rw-r--r-- 1 root root 1 abr 5 17:11 4.map
16-rw-r--r-- 1 root root 1 abr 5 17:11 5.map
17[root@localhost kronoman]#

[kronoman@localhost kronoman]$ gcc test_alfindfirst.c -o test_alfindfirst.bin -Wall `allegro-config --libs`
[kronoman@localhost kronoman]$ ./test_alfindfirst.bin 
starting

file : 1.map
file : 2.map
file : 3.map
file : 4.map
file : 5.map


done

[kronoman@localhost kronoman]$

well, I'm clueless, my game uses almost the same code... but, when runs as normal user, I can't see the same files posted before.
I will recheck it again at night to see was wrong. :(

ReyBrujo
Moderator
January 2001
avatar

Are you sure the pattern your program is sending is right?

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

kronoman
Member #2,911
November 2002
avatar

The pattern that is sending is ok, I have a trace system that goes dumping all the stuff that happens, and I checked and is OK.
Anyways, I fooled around and I don't know how, but the problem solved for now... mysterious errors...

Go to: