changed the private *at functions to the official ones for openat and

mkdirat, but not for opendirat, as there is no official version of it.
This commit is contained in:
celinemercier
2015-07-20 11:38:43 +02:00
parent 802f9983c2
commit 484fcca557
4 changed files with 74 additions and 73 deletions

View File

@ -47,43 +47,6 @@ char* get_full_path(int directory_file_descriptor, const char* path_name)
}
int private_openat(int directory_file_descriptor, const char* path_name, int flags)
{
char* full_path;
int file_descriptor;
full_path = get_full_path(directory_file_descriptor, path_name);
if (full_path == NULL)
return -1;
file_descriptor = open(full_path, flags);
free(full_path);
return file_descriptor;
}
int private_mkdirat(int directory_file_descriptor, const char* path_name, mode_t mode)
{
char* full_path;
full_path = get_full_path(directory_file_descriptor, path_name);
if (full_path == NULL)
return -1;
if (mkdir(full_path, mode) < 0)
{
free(full_path);
return -1;
}
free(full_path);
return 0;
}
DIR* private_opendirat(int directory_file_descriptor, const char* path_name)
{
char* full_path;
@ -100,3 +63,40 @@ DIR* private_opendirat(int directory_file_descriptor, const char* path_name)
return directory;
}
//int private_openat(int directory_file_descriptor, const char* path_name, int flags)
//{
// char* full_path;
// int file_descriptor;
//
// full_path = get_full_path(directory_file_descriptor, path_name);
// if (full_path == NULL)
// return -1;
//
// file_descriptor = open(full_path, flags);
//
// free(full_path);
//
// return file_descriptor;
//}
//
//
//int private_mkdirat(int directory_file_descriptor, const char* path_name, mode_t mode)
//{
// char* full_path;
//
// full_path = get_full_path(directory_file_descriptor, path_name);
// if (full_path == NULL)
// return -1;
//
// if (mkdir(full_path, mode) < 0)
// {
// free(full_path);
// return -1;
// }
//
// free(full_path);
//
// return 0;
//}