Operating System - HP-UX
1833758 Members
2822 Online
110063 Solutions
New Discussion

E_NOENT while file exist !

 
Laurent Laperrousaz
Regular Advisor

E_NOENT while file exist !

Could this error be related to a kernel limit?
6 REPLIES 6
Navin Bhat_2
Trusted Contributor

Re: E_NOENT while file exist !

check the directory path and permissions also. Not related to kernel parameters.
Bharat Katkar
Honored Contributor

Re: E_NOENT while file exist !

When and where did you see the this error. Please give more details regarding the same.
Regards,
You need to know a lot to actually know how little you know
A. Clay Stephenson
Acclaimed Contributor

Re: E_NOENT while file exist !

Generally not but ENOENT can be set my many system calls --- some of which have nothing to do with files. An errno value out of context (at a minimum the system call that it is related to) is of little value.

Ideally, you need errno and the system call that set it along with the actual parameters passed to the system call. Tusc can actually be used to yield these results for a process.
If it ain't broke, I can fix that.
Laurent Laperrousaz
Regular Advisor

Re: E_NOENT while file exist !

I already posted a question for this problem:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=216102
and i thought it was gone...

Alas, it is back!

here is the code where I test the existence of the file:
It may say "file not exist" or it works fine (with the same file)

// Pour vérifier l'existence d'un fichier
bool fileExists(const char *filename)
{
// Initialise à NULL
FILE *fichier = NULL;

// Ouvre le fichier en lecture seulement
fichier = fopen(filename, "r");

// Si NULL est renvoyé c'est parce que le fichier n'a pas été trouvé ou bien qu'il est déjà ouvert(pas accessible...) ou autres...
if (fichier == NULL)
{
cout << "erreur fileExists " << string(filename, strlen(filename)) <<" , errno = " << errno < return false;
}
// Ferme le fichier
fclose(fichier);

// Renvoie true, le fichier existe bien
A. Clay Stephenson
Acclaimed Contributor

Re: E_NOENT while file exist !

The first thing that I notice is that there is no return for this function when the file is able to be opened. This may be because you have posted only a snippit of code or i you may have an defined result.

In any event, sometimes it's nice to fall back on the old standards to print errors. I would replace the cout with
(void) fprintf(stderr,"Filename: \"%s\" errno: %d\n",filename,errno);
int i = 0,len = 0;
len = strlen(filename);
while (i < len)
{
if (filename[i] >= ' ' && filename[i] <= '~') (void) fprintf(stderr,"%c",filename[i])
else (void) fprintf(stderr,"|%03o|",(int) filename[i]);
++i;
}
(void) fprintf(stderr,"\n");
(void) fflush(stderr);

The idea is to detect any non-printable characters embedded in the filename.

One other observation, fopen is slightly removed from the actual system call open() so if you are really fighting a mysterious problem, you may want to use open instead so that you know it is what actually set errno although fopen should be close enough to the scene of the crime.
If it ain't broke, I can fix that.
Laurent Laperrousaz
Regular Advisor

Re: E_NOENT while file exist !

you are right, I forgot 2 lines in my cut and paste!

Anyway I will try your suggestions and let you know...

Thanks

Laurent