Menu

#887 Trying to GET FILE or COPY FILE under /proc unpredicatable

Unix::Linux
open
nobody
5
2008-12-11
2007-01-30
No

On RHEL4, there are many files under /proc directory, such as /proc/version, but trying to GET FILE of it will get return code 22.
Trying to copy the file will result in the command hanging indefinitely.

On a RHEL3 base version, there are no error messages, but the GET FILE will return nothing, and COPY will end up with a 0 byte file.

The workaround with use is launching a process `cp` isntead of COPY FILE or running `cat` instead of GET FILE.

Discussion

  • Sharon Lucas

    Sharon Lucas - 2007-01-30

    Logged In: YES
    user_id=285070
    Originator: NO

    If you're not using STAF V3.2.0 on your machines (on both ends of a FS COPY FILE request), then please upgrade to STAF V3.2.0 and verify if that resolves the problem.

    What is the architecture of your machines where you're having a problem (e.g. i386, AMD64, PPC64, IA64, etc)?

     
  • prziborowski

    prziborowski - 2007-01-30

    Logged In: YES
    user_id=1535417
    Originator: YES

    STAF V3.2.0 is used on all of our machines.

    It has been reproduced on i386, IA64, AMD64.

    I tried this first with 'local' (staf local fs get file /proc/version, staf local fs copy file /proc/version tofile /tmp/version).
    I also tried 'get file' from a remote machine.

     
  • Sharon Lucas

    Sharon Lucas - 2007-01-30

    Logged In: YES
    user_id=285070
    Originator: NO

    The proc filesystem is a pseudo-filesystem rooted at /proc that contains user-accessible objects that pertain to the runtime state of the kernel and, by extension, the executing processes that run on top of it. "Pseudo" is used because the proc filesystem exists only as a reflection of the in-memory kernel data structures it displays. This is why most files and directories within /proc are 0 bytes in size.
    File /proc/version contains revision information relevant to the running kernel image. Note that it's size is shown as 0 bytes.

    [root@client1 proc]# ls -ls version
    0 -r--r--r-- 1 root root 0 Jan 30 16:30 version

    It appears that these types of files with size appearing as 0 is causing some issues with the STAF FS (FileSystem) service. We'll investigate further.

     
  • Sharon Lucas

    Sharon Lucas - 2007-01-31
    • assigned_to: nobody --> slucas
     
  • Sharon Lucas

    Sharon Lucas - 2007-02-05

    Logged In: YES
    user_id=285070
    Originator: NO

    The reason FS COPY/GET requests for files in the /proc directory on Linux was failing in different ways was because the FS service determines the size of a file using C++ ifstream::seekg and tellg methods. When copying a file, the FS service first determines the size of the file to see how many bytes to copy. It does this by doing:

    inFile.seekg(0, ios::end);
    unsigned int fileLength = (unsigned int)inFile.tellg();

    On Linux RHEL3, tellg() returns 0 for the file length of file/proc/version. However, on Linux RHEL4, tellg() returns -1 for file /proc/version. As STAF wasn't expecting a negative number (and thus, wasn't handling it correctly), this resulted in a hang on the FS COPY and a RC 22 on the GET FILE.

    In STAF V3.2.1 (planned to be released at the end of February 2007), I changed how the FS service determines the file size. Instead of using the ifstream::tellg() C++ method, we now use operating system functions to get the file size. That is, we're now using the same file size data as is provided by a FS QUERY ENTRY request: upperSize and lowerSize. Note that this change was needed for Bug #1522599 to allow the FS Service to copy files whose size is > INT_MAX (e.g. 2G) in STAF V3.2.1 on 32-bit Windows machines. files.

    So, in STAF V3.2.1, FS COPY and FS GET FILE requests involving a file in /proc on any Linux machine will have the same behavior. The request will be successful, RC=0. However, if the file size is 0, a FS COPY request of the /proc/version file for example will result in the copied file having size 0 and not containing anything. Also, a FS GET FILE request of /proc/version file will show nothing as the content.

    In a future version of STAF, we could add real support for these "pseudo" files on Linux with file size 0. This will require a different way for the FS service to read these files however. Some more code would need to be added that does something like the following:

    On a FS COPY or FS GET request, if fileLength is 0 and the file resides on a Linux machine, any it's a regular file, not a symbolic link, then check if the number of blocks (st_blocks in the data set by running the stat command) is also 0 as this appears to indicate that it's one of these "pseuodo" files:

    if ((fileEntry->type() & kSTAFFSFile) && data.st_size == 0)
    {
    rc = stat(thePath.toCurrentCodePage()->buffer(), &data);

    if (data.st_blocks == 0)
    {
    // Could be a psuedo file
    // Read through the file and and count how many bytes can read and if
    // > 0 save the entire file's contents in a string.
    }
    }

    Then in the COPY FILE/DIRECTORY and GET FILE code, change to use this as the real fileLength and change to read from this string (instead of reading from the file), as the contents in many psuedo files continually change. Then the content of a psuedo file (at that point in time) will actually be copied on a FS COPY request and returned on a FS GET FILE request.

     
  • Sharon Lucas

    Sharon Lucas - 2008-12-11
    • assigned_to: slucas --> nobody
     

Log in to post a comment.