Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6995445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:01:34+00:00 2026-05-27T20:01:34+00:00

I am using libhal to detect device events. I am able to detect a

  • 0

I am using libhal to detect device events. I am able to detect a device added or removed but I can not detect device’s mount point. The function libhal_volume_get_mount_point(volume) does not work.

I have a callback function to detect device add:

static void handle_device_added(LibHalContext *ctx, const char *udi) {

    dbus_bool_t is_storage;
    dbus_bool_t is_volume;

    is_storage = libhal_device_query_capability(ctx, udi, "storage", NULL);
    is_volume = libhal_device_query_capability(ctx, udi, "volume", NULL);

    if (is_storage) {
        drive = libhal_drive_from_udi(ctx, udi);

        if (libhal_drive_is_hotpluggable(drive) || libhal_drive_uses_removable_media(drive)) {
            printf("Storage device added %s model %s\n",
                    libhal_drive_get_device_file(drive),
                    libhal_drive_get_model(drive));
        }

        libhal_drive_free(drive);
    }

    if(is_volume) {
        volume = libhal_volume_from_udi(ctx, udi);
        printf("Mount point = %s\n", libhal_volume_get_mount_point(volume));
        libhal_volume_free(volume);
    }
}

libhal_volume_from_udi, returns NULL.

Do you know any suitable way to detect the mount point of a storage device in C?

UPDATE

I have managed to find mount point of the device by searching /etc/mtab but there is still one little problem. I am assuming the device has one partition only.

How can I get the list of the partition on a storage device? So I can found mount points of each.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T20:01:35+00:00Added an answer on May 27, 2026 at 8:01 pm

    First, if you provide more details on what fails when you try to use the libhal function, you may get answers that help fix that issue. But to answer your question directly, a C program can determine what is mounted where by reading /etc/mtab. The format is fairly self-explanatory, each line typically lists the name of the storage device, the directory where it is mounted, the filesystem type, and mount options.

    To map a specific directory in the filesystem to the mount point it belongs to it can be a little tricky — remember if you’re looping through /etc/mtab that mount points can have other mount points beneath them.

    You may find looking at the source for programs that do this correctly, like “df” will help you get it right, or if your program doesn’t need to look up this information often, you might decide to simply call popen(3) on a df command to do it for you. For example, the command:df /media/my-volume/some/path does a nice job displaying both the name of the storage device and the mount point where that device is mounted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the current request I can get the URL hostname with: HttpContext.Current.Request.Url.Host But -
Using Delphi 2010. I am looking for (possibly) a function or procedure which can
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using VS2008, C#, .Net 2 and Winforms how can I make a regular Button
Using the navigator.geolocation object in JavaScript. Trying to establish accurate ranges, but wondering exactly
Using jQuery, one can easily find out whether a particular element is visible using
Using the HTML5 File API I can get the Binary String representation of a
Using NSDateComponents I know how to get the day component, but this gives me
Using Tsql, how can I find out when MS SQL server was installed?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.