C Board  

Go Back   C Board > Platform Specific Boards > Linux Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 12-16-2008, 12:37 PM   #1
Registered User
 
Join Date: Oct 2006
Posts: 298
opendir() returns null but errno is zero

I'm having a problem with some code I'm writing on linux to list files in a directory using opendir/readdir, where opendir is returning NULL, but it's not setting errno to a useful value. I know for a fact that the directory I'm attempting to open exists, is a directory, I have access to it, there are not too many descriptors in use, there are not too many files open, and there is plenty of memory available. I'm really confused about this.
Elkvis is offline   Reply With Quote
Old 12-16-2008, 12:50 PM   #2
Kernel hacker
 
Join Date: Jul 2007
Location: Farncombe, Surrey, England
Posts: 15,686
Perhaps posting the relevant code would help here... Sometimes someone else will spot the simple mistake that the person who wrote the code hasn't spotted.

--
Mats
__________________
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
matsp is offline   Reply With Quote
Old 12-16-2008, 01:16 PM   #3
Registered User
 
Join Date: Oct 2006
Posts: 298
this was the problem:

Code:
DIR* d = NULL;
d = opendir("mydir");
if (d == NULL);
{
  switch (errno)
  {
    // print errno to screen here and report the error
  }
}
stupid mistake.
Elkvis is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
New string functions Elysia C Programming 11 03-28-2009 05:03 AM
Syntax Error?? Kennedy C Programming 8 09-06-2006 11:04 AM
Button handler Nephiroth Windows Programming 8 03-12-2006 06:23 AM
Help with yacc/compiler design/seg fault trippeer C Programming 1 04-08-2005 03:43 AM
button 'message' psychopath Windows Programming 12 04-18-2004 09:57 AM


All times are GMT -6. The time now is 09:33 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22