Find the answer to your Linux question:
Results 1 to 2 of 2
This is an odd one. I have a C program that calls umount to unmount a volume. A simplified case looks like this: Code: int main() { int rc = ...
  1. #1
    Just Joined!
    Join Date
    Nov 2010
    Posts
    11

    Calling umount2() unmounts volume but df entry still visible

    This is an odd one. I have a C program that calls umount to unmount a volume. A simplified case looks like this:

    Code:
    int main()
    {
        int rc = umount2("/v0", MNT_FORCE);
        if (rc != 0)
        {
            printf("Unable to unmount volume /v0, err='%s'", strerror(errno));
        }
    }
    When I run this code, the "/v0" volume is unmount, but it still shows up in df:

    Code:
    # mount /dev/sda7 /v0
    # touch /v0/xxx
    # df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1              8254240   3554504   4280444  46% /
    /dev/sda7             20954552      4260  20950292   1% /v0
    /dev/sdb7             20954552      4256  20950296   1% /v1
    /dev/sda2              4127108    180232   3737228   5% /var
    #./a.out
    #df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1              8254240   3554504   4280444  46% /
    /dev/sda7             20954552      4260  20950292   1% /v0
    /dev/sdb7             20954552      4256  20950296   1% /v1
    /dev/sda2              4127108    180232   3737228   5% /var
    As you can see, df still shows that /v0 is mount. However, it's not *really* mounted. If I try to access it, the commands fail:

    Code:
    # ls /v0/xxx
    ls: cannot access /v0/xxx: No such file or directory
    If I run a umount, it fails as well, but this removes the /v0 entry as well:

    Code:
    # umount -f /v0
    umount2: Invalid argument
    umount: /v0: not mounted
    umount2: Invalid argument
    
    # df
    Filesystem           1K-blocks      Used Available Use% Mounted on
    /dev/sda1              8254240   3554504   4280444  46% /
    /dev/sdb7             20954552      4256  20950296   1% /v1
    /dev/sda2              4127108    180232   3737228   5% /var
    So, the question is, why does calling umount2() in my code not completely unmount the volume?

  2. #2
    Just Joined!
    Join Date
    Nov 2010
    Posts
    11
    I've discovered the opposite problem with the mount() function call. I have code that makes the call:

    Code:
     mount(drive, volume, "xfs", MS_NOATIME, NULL);
    After making this call, a df command does not show an entry for the newly mounted volume. However, accessing the volume through other commands confirms that in fact the volume *is* mounted, and issuing a umount command from the command line unmounts the volume without any errors.

    So, why is my C code behaving differently than running the mount/umount commands from the command line?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...