Jump to content
Eternal Lands Official Forums
ttlanhil

New file handling routines

Recommended Posts

Slackware 11.0, Intel 915GM card, cvs updated before posting.

For me latest cvs segfault when opening the TAB-map, also the knowledge list (ctrl+k) is empty and all the entrables are missing.

Except for the reason of the segfault when opening map (I've no idea), the rest makes sense since it's failing to load some files (which are there, and were working with the cvs of 2~3 days ago)

 

Error_log:

Log started at 2008-01-11 10:13:48 localtime (CET)

 

[10:13:48] Using the server profile: main

[10:13:49] Cannot create directory (mkdir() failed): opt, /opt/games/elc//mapinfo.lst

[10:13:49] Error: Can't open file "mapinfo.lst"

[10:13:49] Cannot create directory (mkdir() failed): opt, /opt/games/elc//harvestable.lst

[10:13:49] Error: Can't open file "harvestable.lst"

[10:13:49] Cannot create directory (mkdir() failed): opt, /opt/games/elc//entrable.lst

[10:13:49] Error: Can't open file "entrable.lst"

[10:13:49] Cannot create directory (mkdir() failed): opt, /opt/games/elc//languages/en/knowledge.lst

Last message repeated 1 time

[10:13:49] Error: Can't open file "knowledge.lst"

[10:13:52] Error: Can't open file "quest.log"

[10:13:52] Cannot create directory (mkdir() failed): opt, /opt/games/elc//custom_mirrors.lst

[10:13:52] Error: Can't open file "custom_mirrors.lst"

[10:13:52] Cannot create directory (mkdir() failed): opt, /opt/games/elc//commands.lst

[10:13:52] Error: Can't open file "commands.lst"

[10:25:27] Client closed

 

In elpathwrapper.c, line 252, I've tried reverting back from the new

if (mkdir_tree (locbuffer, 1)){

to the previous

if (mkdir_tree (filename, 1)){

That has removed the crash and the all the errors about the files loading, and everything works fine as before.

 

**Note**

After the 'fix' the error_log contains different errors, but they have been there for weeks and till now I had assumed the problem was with permissions or with already existing files (non-critical anyway, never caused a crash); but comparing them with the ones posted above, I wonder if maybe there is another mkdir_tree in another position giving a similar problem.

Log started at 2008-01-11 10:25:45 localtime (CET)

 

[10:25:45] Using the server profile: main

[10:25:48] Error: Can't open file "quest.log"

[10:25:48] * server www.eternal-lands.com filename http://www.eternal-lands.com/updates/custom_files.lst

[10:25:48] Downloading http://www.eternal-lands.com/updates/custom_files.lst from www.eternal-lands.com

[10:25:48] Finished downloading http://www.eternal-lands.com/updates/custom_files.lst

[10:25:49] Cannot create directory (mkdir() failed): custom, custom/player/acelon/meshes/cape_custom.bmp.gz

[10:25:49] Cannot create directory (mkdir() failed): custom, custom/player/aislinn/meshes/cape_custom.bmp.gz

[10:25:49] Cannot create directory (mkdir() failed): custom, custom/player/learner/meshes/cape_custom.bmp.gz

[10:25:49] Cannot create directory (mkdir() failed): custom, custom/player/placid/meshes/cape_custom.bmp.gz

[10:25:49] Download needed for custom/player/placid/meshes/cape_custom.bmp.gz

[10:25:49] @@ www.eternal-lands.com http://www.eternal-lands.com/updates/custo...e_custom.bmp.gz

[10:25:49] Downloading http://www.eternal-lands.com/updates/custo...e_custom.bmp.gz from www.eternal-lands.com

[10:25:49] Cannot create directory (mkdir() failed): custom, custom/player/sistema/meshes/cape_custom.bmp.gz

[10:25:49] Cannot create directory (mkdir() failed): custom, custom/player/soldus/meshes/cape_custom.bmp.gz

[10:25:50] Finished downloading http://www.eternal-lands.com/updates/custo...e_custom.bmp.gz

[10:25:50] Cannot create directory (mkdir() failed): custom, custom/player/placid/meshes/cape_custom.bmp.gz

[10:25:50] Unable to finish processing of custom/player/placid/meshes/cape_custom.bmp.gz (13)

Share this post


Link to post
Share on other sites

Slackware 11.0, Intel 915GM card, cvs updated before posting.

For me latest cvs segfault when opening the TAB-map, also the knowledge list (ctrl+k) is empty and all the entrables are missing.

Except for the reason of the segfault when opening map (I've no idea), the rest makes sense since it's failing to load some files (which are there, and were working with the cvs of 2~3 days ago)

Wow so many reasons to go wrong! First off, the sigfault is a bug and I can reproduce it but only after really messing up my install. It's probably because you can't read the file but I'll look into that later. A few questions, apologies if these are silly questions:

 

1) What is the install path for your data files?

2) What is data_dir set to in your ~/.elc/main/el.ini file?

3) Does the user you are running el from, have at least read/execute on all the directories and read on all the installed files?

4) If the user does not have write access to those files and directories, you will need to turn off the "Automatic Updates" option in the server config tab to avoid the error mesaages.

4) You also have "Custom Looks Update" enabled but it appears your user does not have full access to ~/.elc/ or ~/.elc/custom so check that too.

 

The code change was correct but before, you may have been reading/writing to somewhere else. I suspect your data_dir is not pointng where you think it is....

Edited by bluap

Share this post


Link to post
Share on other sites

Wow so many reasons to go wrong! First off, the sigfault is a bug and I can reproduce it but only after really messing up my install. It's probably because you can't read the file but I'll look into that later. A few questions, apologies if these are silly questions:

 

1) What is the install path for your data files?

It's /opt/games/elc/ it has been the same for ~2 years

2) What is data_dir set to in your ~/.elc/main/el.ini file?

It's /opt/games/elc/

3) Does the user you are running el from, have at least read/execute on all the directories and read on all the installed files?

yes

4) If the user does not have write access to those files and directories, you will need to turn off the "Automatic Updates" option in the server config tab to avoid the error mesaages.

It's off (I don't want the autoupdate to delete the work I do on ency files :))

4) You also have "Custom Looks Update" enabled but it appears your user does not have full access to ~/.elc/ or ~/.elc/custom so check that too.

ok, the permissions here were a bit weird, fixed them now (but actually, the permissions for user and group were right, just the ones for "others" were wrong)

The code change was correct but before, you may have been reading/writing to somewhere else. I suspect your data_dir is not pointng where you think it is....

The datadir is correct, and even after fixing those permissions in .elc (which shouldn't have mattered anyway) I still have ctrl+k empty and such.

 

EDIT:

just found this, still at line 252

if (mkdir_tree (locbuffer, 1)){

changing the 1 to 0 fixes my issue

Edited by Theryndan

Share this post


Link to post
Share on other sites

just found this, still at line 252

if (mkdir_tree (locbuffer, 1)){

changing the 1 to 0 fixes my issue

 

Right. I wondered why it tried to create opt instead of /opt.

 

It worked before because the path was always relative to $CWD and is now absolute and I did not notice it on windows because the absolute path check looks only for the slash and not for a drive letter like "C:\"

 

I guess it worked for other users because they allow writing to data_dir and they will most likely have an /opt/games/elc/opt/games/elc tree now.

Edited by ago

Share this post


Link to post
Share on other sites

just found this, still at line 252

if (mkdir_tree (locbuffer, 1)){

changing the 1 to 0 fixes my issue

 

Right. I wondered why it tried to create opt instead of /opt.

 

It worked before because the path was always relative to $CWD and is now absolute and I did not notice it on windows because the absolute path check looks only for the slash and not for a drive letter like "C:\"

 

I guess it worked for other users because they allow writing to data_dir and they will most likely have an /opt/games/elc/opt/games/elc tree now.

I've just reproduced the exact error by moving my data_dir to /opt/games/elc, it was not enough to make the existing tree non-write for my normal user. :) I was just starting to work though normalize_path() when I saw your reply Ago.

 

The question still in my mind is why the call to mkdir_tree() at all for a data_dir file? If the data_dir path does not exist, the client should surely give up with a nice error message....

Edited by bluap

Share this post


Link to post
Share on other sites

We should structure the code a bit more.

 

I really don't like how the NEW_FILE_IO is implemented (the open-and-fallback routines), plus the new server profile structure does not help a lot here. Too many code, too less generic methods (or too generic ones).

 

Let me give you a concrete example: as I was writing support for config "changes" file (where the maintainers can, at each version, add/remove/modify dynamically the el.ini file for obsolete/new entries) I found out that copying "el.ini" from the install directory to the server profile dir was being done in.... write_el_ini(). Stoke me as weird. And unusual. We ought to copy the file once we don't find it. But maybe because it was working, no other noticed.

 

Other weird think is the auto fallback when opening config files. Althrough it might have been useful, with the new server profiles, makes not much sense. We should copy all files when creating the new profile.

 

I know that sanitizing all file IO is not an easy task. But we can do it, and should not take much time (I estimate a total of 40-50 man-hour).

 

Álvaro

Share this post


Link to post
Share on other sites

We should structure the code a bit more.

I agree, to me, the code is too complex and its too easy to have errors and wrongdoing covered up with attempted fall back. I like nice simple code that break decisively and obviously when things aren't right. The problem is, someone has thought a lot about this and written lots of code; that makes me wary to make large changes just because (in my case) I can't follow what's happening. I'm sure its plain and simple to the author. May be there are a few bugs but I'm not currently confident to fix them. There are, as you know also several aspects to consider. One major issue is auto file updates, not many of us want to run the client as root/admin simply because we have installed it for general use not just our own user.

 

Right now, we need to know if that mkdir_tree() call at line 255 was intended, is so to what purpose. If not, we probably need to change it to this:

Index: io/elpathwrapper.c
===================================================================
RCS file: /cvsroot/elc/elc/io/elpathwrapper.c,v
retrieving revision 1.17
diff -a -u -r1.17 elpathwrapper.c
--- io/elpathwrapper.c  9 Jan 2008 21:52:20 -0000	   1.17
+++ io/elpathwrapper.c  11 Jan 2008 21:57:49 -0000
@@ -252,9 +252,7 @@
	char locbuffer[MAX_PATH];
	if(strlen(datadir) + strlen(filename) + 2 < MAX_PATH){
			safe_snprintf(locbuffer, sizeof(locbuffer), "%s/%s", datadir, filename);
-			   if (mkdir_tree (locbuffer, 1)){
-					   return fopen(locbuffer, mode);
-			   }
+			   return fopen(locbuffer, mode);
	}
	return NULL;
}

Edited by bluap

Share this post


Link to post
Share on other sites

just found this, still at line 252

if (mkdir_tree (locbuffer, 1)){

changing the 1 to 0 fixes my issue

After a lot of re-reading this entire thread, testing and investigation, I've now checked in that change.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×