Linux does not see existing file on mounted drive

Posted on 2003-03-04
Medium Priority
Last Modified: 2010-04-21
Hi I have linked a linux directory to my Windows 2000
machine using samba. I have a cgi-script that calls
a program on my windows 2000 machine which in turn creates
a file in the linked directory. My CGI script loops after
calling the windows program checking if the file exists
in the directory using
if (-e $filename1){....}
but it seems to the Linux system that even when the file is created by the Win2000 program  it does not exist.

ie using ls $dir.$filename returns
"This file or directory does not exist" (My system is Japanese so I am translating roughly)

But if I manually list the directory contents using the
"ls" command, the Linux server seems to update it's directory listing and lists my created file and at the exact same time my still running CGI program "sees" the file.

If I call from the Command Line
>ls /myprog/3ddone.txt
the message is returned
"Cannot Find this file or directory"
But if I type
>ls /myprog/
it shows
and if I again call
>ls /myprog/3ddone.txt
its shows

Just calling a "ls" on the directory seems to force
the Linux System to update it's File Tree Listing.

Is there a way via perl to cause the Linux system to
refresh it listing of the shared directory so that
my cgi can "see" the newly craeted file?

sync;sync doesn't work

Question by:brian_sweeney
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Author Comment

ID: 8069811
Sorry I was trying to keep the problem simple by not mentioning the fact that the CGIs are actually on a different server to the Server where the outputted file is
physically stored. But the problem could be NFS related rather than Samba related so I reveal all (~_~;

Windows Server = Windows2000 (Linked via Samba to DataDirectory )
WWW Server = Unix   (Linked via NFS to Data Directory)
DataServer = Linux ( Contains Data Directory)

The WWW Server CGI calls an application on the Windows  Server and loops checking the NFS mounted Data Directory for the existence of 3ddone.txt.
The Windows Server writes the file 3ddone.txt to the Samba Linked Data Directory.

The WWW Server cannot see the created file ie
WWW Server CGI :
function -e "/myprog/3ddone.txt" is always false

WWW Server Command Prompt :
>ls /myprog/3ddone.txt
Cannot see file  

ls /myprog/
ls /myprog/3ddone.txt
file has magically appeared
CGI function -e "/myprog/3ddone.txt" returns true


Expert Comment

ID: 8124657
It's a good thing you added that information, because this is a classic NFS weakness.  I believe if you wait 30 seconds, the file will show up.  Or, you can do the same thing as the 'ls' in the perl program with opendir() and readdir().

Author Comment

ID: 8124756
Thnks for your reply.
Could you give me any reference where this weakness is

Accepted Solution

bryanh earned 200 total points
ID: 8129533
I don't know of one, but any detailed description of NFS should mention that clients typically cache metadata for up to 30 seconds because going to the server every time metadata is needed would make the client too slow.  Hence, the client's view of e.g. the contents of a directory could be out of date.

Another thing to watch out for is that an NFS client caches file data and assumes the file does not change while a user has the file open.  So if Client 1 and Client 2 both have file abc open and Client 1 reads the first block abc, then Client 2 updates the first block of abc, then Client 1 reads the first block again, Client 1 sees the original contents of the block, not what Client 2 wrote.

CIFS (Windows/Samba file sharing), AFS, and NFS 4 (Not to be confused with regular NFS) are some responses to this inadequacy of NFS.

Author Comment

ID: 8214723
Thanks for the information. Sorry for choosing average but
although the information was good it did not help me
fix the problem. It seemed to be specific to the environment setup I used and did not occur on the customers

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question