Commit 33127043 by Brodie Rao

fileops/posix: replace usage of "int mode" with "mode_t mode"

Note: Functions exported from fileops take const mode_t, while the
underlying POSIX wrappers take mode_t.
parent 1776f5ab
......@@ -33,7 +33,7 @@ int git_futils_mv_atomic(const char *from, const char *to)
int git_futils_mkpath2file(const char *file_path)
{
const int mode = 0755; /* or 0777 ? */
const mode_t mode = 0755; /* or 0777 ? */
int error = GIT_SUCCESS;
char target_folder_path[GIT_PATH_MAX];
......@@ -67,7 +67,7 @@ int git_futils_mktmp(char *path_out, const char *filename)
return fd;
}
int git_futils_creat_withpath(const char *path, int mode)
int git_futils_creat_withpath(const char *path, const mode_t mode)
{
if (git_futils_mkpath2file(path) < GIT_SUCCESS)
return git__throw(GIT_EOSERR, "Failed to create file %s", path);
......@@ -75,13 +75,13 @@ int git_futils_creat_withpath(const char *path, int mode)
return p_creat(path, mode);
}
int git_futils_creat_locked(const char *path, int mode)
int git_futils_creat_locked(const char *path, const mode_t mode)
{
int fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY | O_EXCL, mode);
return fd >= 0 ? fd : git__throw(GIT_EOSERR, "Failed to create locked file. Could not open %s", path);
}
int git_futils_creat_locked_withpath(const char *path, int mode)
int git_futils_creat_locked_withpath(const char *path, const mode_t mode)
{
if (git_futils_mkpath2file(path) < GIT_SUCCESS)
return git__throw(GIT_EOSERR, "Failed to create locked file %s", path);
......@@ -289,7 +289,7 @@ int git_futils_direach(
return GIT_SUCCESS;
}
int git_futils_mkdir_r(const char *path, int mode)
int git_futils_mkdir_r(const char *path, const mode_t mode)
{
int error, root_path_offset;
char *pp, *sp;
......
......@@ -48,18 +48,18 @@ extern int git_futils_exists(const char *path);
* Create and open a file, while also
* creating all the folders in its path
*/
extern int git_futils_creat_withpath(const char *path, int mode);
extern int git_futils_creat_withpath(const char *path, const mode_t mode);
/**
* Create an open a process-locked file
*/
extern int git_futils_creat_locked(const char *path, int mode);
extern int git_futils_creat_locked(const char *path, const mode_t mode);
/**
* Create an open a process-locked file, while
* also creating all the folders in its path
*/
extern int git_futils_creat_locked_withpath(const char *path, int mode);
extern int git_futils_creat_locked_withpath(const char *path, const mode_t mode);
/**
* Check if the given path points to a directory
......@@ -74,7 +74,7 @@ extern int git_futils_isfile(const char *path);
/**
* Create a path recursively
*/
extern int git_futils_mkdir_r(const char *path, int mode);
extern int git_futils_mkdir_r(const char *path, const mode_t mode);
/**
* Create all the folders required to contain
......
......@@ -17,7 +17,7 @@ int p_open(const char *path, int flags)
return open(path, flags | O_BINARY);
}
int p_creat(const char *path, int mode)
int p_creat(const char *path, mode_t mode)
{
return open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, mode);
}
......
......@@ -42,7 +42,7 @@ extern int p_write(git_file fd, const void *buf, size_t cnt);
#define p_close(fd) close(fd)
extern int p_open(const char *path, int flags);
extern int p_creat(const char *path, int mode);
extern int p_creat(const char *path, mode_t mode);
extern int p_getcwd(char *buffer_out, size_t size);
#ifndef GIT_WIN32
......
......@@ -609,7 +609,7 @@ static int repo_init_createhead(git_repository *repo)
static int repo_init_structure(const char *git_dir, int is_bare)
{
const int mode = 0755; /* or 0777 ? */
const mode_t mode = 0755; /* or 0777 ? */
int error;
char temp_path[GIT_PATH_MAX];
......
......@@ -19,7 +19,7 @@ GIT_INLINE(int) p_link(const char *GIT_UNUSED(old), const char *GIT_UNUSED(new))
return -1;
}
GIT_INLINE(int) p_mkdir(const char *path, int GIT_UNUSED(mode))
GIT_INLINE(int) p_mkdir(const char *path, mode_t GIT_UNUSED(mode))
{
wchar_t* buf = conv_utf8_to_utf16(path);
int ret = _wmkdir(buf);
......@@ -41,12 +41,12 @@ extern int p_mkstemp(char *tmp_path);
extern int p_setenv(const char* name, const char* value, int overwrite);
extern int p_stat(const char* path, struct stat* buf);
extern int p_chdir(const char* path);
extern int p_chmod(const char* path, int mode);
extern int p_chmod(const char* path, mode_t mode);
extern int p_rmdir(const char* path);
extern int p_access(const char* path, int mode);
extern int p_access(const char* path, mode_t mode);
extern int p_fsync(int fd);
extern int p_open(const char *path, int flags);
extern int p_creat(const char *path, int mode);
extern int p_creat(const char *path, mode_t mode);
extern int p_getcwd(char *buffer_out, size_t size);
#endif
......@@ -230,7 +230,7 @@ int p_open(const char *path, int flags)
return fd;
}
int p_creat(const char *path, int mode)
int p_creat(const char *path, mode_t mode)
{
int fd;
wchar_t* buf = conv_utf8_to_utf16(path);
......@@ -268,7 +268,7 @@ int p_chdir(const char* path)
return ret;
}
int p_chmod(const char* path, int mode)
int p_chmod(const char* path, mode_t mode)
{
wchar_t* buf = conv_utf8_to_utf16(path);
int ret = _wchmod(buf, mode);
......@@ -355,7 +355,7 @@ int p_snprintf(char *buffer, size_t count, const char *format, ...)
return r;
}
extern int p_creat(const char *path, int mode);
extern int p_creat(const char *path, mode_t mode);
int p_mkstemp(char *tmp_path)
{
......@@ -378,7 +378,7 @@ int p_setenv(const char* name, const char* value, int overwrite)
return (SetEnvironmentVariableA(name, value) == 0 ? GIT_EOSERR : GIT_SUCCESS);
}
int p_access(const char* path, int mode)
int p_access(const char* path, mode_t mode)
{
wchar_t *buf = conv_utf8_to_utf16(path);
int ret;
......
......@@ -431,7 +431,7 @@ END_TEST
BEGIN_TEST(pack0, "create a packfile for an empty folder")
git_repository *repo;
char temp_path[GIT_PATH_MAX];
const int mode = 0755; /* or 0777 ? */
const mode_t mode = 0755; /* or 0777 ? */
must_pass(open_temp_repo(&repo, REPOSITORY_FOLDER));
......
......@@ -173,7 +173,7 @@ END_TEST
BEGIN_TEST(init2, "Initialize and open a bare repo with a relative path escaping out of the current working directory")
char path_repository[GIT_PATH_MAX];
char current_workdir[GIT_PATH_MAX];
const int mode = 0755; /* or 0777 ? */
const mode_t mode = 0755; /* or 0777 ? */
git_repository* repo;
must_pass(p_getcwd(current_workdir, sizeof(current_workdir)));
......@@ -232,7 +232,7 @@ BEGIN_TEST(open2, "Open a bare repository with a relative path escaping out of t
char current_workdir[GIT_PATH_MAX];
char path_repository[GIT_PATH_MAX];
const int mode = 0755; /* or 0777 ? */
const mode_t mode = 0755; /* or 0777 ? */
git_repository* repo;
/* Setup the repository to open */
......@@ -384,7 +384,7 @@ BEGIN_TEST(discover0, "test discover")
char repository_path[GIT_PATH_MAX];
char sub_repository_path[GIT_PATH_MAX];
char found_path[GIT_PATH_MAX];
int mode = 0755;
mode_t mode = 0755;
git_futils_mkdir_r(DISCOVER_FOLDER, mode);
must_pass(append_ceiling_dir(ceiling_dirs, TEMP_REPO_FOLDER));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment