Last active
October 8, 2015 17:15
-
-
Save matwey/3d905ce0d3405d770e21 to your computer and use it in GitHub Desktop.
name_to_handle_at system call example (found mnt_id by path)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <sys/types.h> | |
#include <sys/stat.h> | |
#include <fcntl.h> | |
int main(int argc, char** argv) { | |
struct file_handle* handle; | |
int mnt_id; | |
if(argc < 2) | |
return 1; | |
handle = (struct file_handle*)malloc(sizeof(struct file_handle) + MAX_HANDLE_SZ); | |
handle->handle_bytes = MAX_HANDLE_SZ; | |
if(name_to_handle_at(AT_FDCWD, argv[1], handle, &mnt_id, AT_EMPTY_PATH | AT_SYMLINK_FOLLOW)<0) { | |
perror("name_to_handle_at"); | |
return 1; | |
} | |
printf("%s %d\n", argv[1], mnt_id); | |
free(handle); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment