forked from acouzens/open5gs
minor update
This commit is contained in:
parent
cb4893c36b
commit
95b2f5a951
|
@ -244,7 +244,8 @@ status_t d_msg_file_init(const char *file)
|
|||
FILE_UREAD | FILE_UWRITE | FILE_GREAD);
|
||||
if (rv != CORE_OK)
|
||||
{
|
||||
d_error("Cannot open log file '%s'", file);
|
||||
d_error("CHECK PERMISSION of Installation Directory...");
|
||||
d_error("Cannot create LOG file '%s'", file);
|
||||
return CORE_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,8 @@ status_t file_open(file_t **new,
|
|||
os_file_t fd;
|
||||
int oflags = 0;
|
||||
|
||||
d_assert(fname, return CORE_ERROR,);
|
||||
|
||||
if ((flag & FILE_READ) && (flag & FILE_WRITE))
|
||||
{
|
||||
oflags = O_RDWR;
|
||||
|
@ -177,6 +179,8 @@ status_t file_close(file_t *file)
|
|||
{
|
||||
status_t rv = CORE_OK;
|
||||
|
||||
d_assert(file, return CORE_ERROR,);
|
||||
|
||||
if (close(file->filedes) == 0)
|
||||
{
|
||||
file->filedes = -1;
|
||||
|
@ -200,6 +204,8 @@ status_t file_close(file_t *file)
|
|||
|
||||
status_t file_remove(const char *path)
|
||||
{
|
||||
d_assert(path, return CORE_ERROR,);
|
||||
|
||||
if (unlink(path) == 0)
|
||||
{
|
||||
return CORE_OK;
|
||||
|
@ -219,6 +225,9 @@ static status_t file_transfer_contents(
|
|||
file_info_t finfo;
|
||||
file_perms_t perms;
|
||||
|
||||
d_assert(from_path, return CORE_ERROR,);
|
||||
d_assert(to_path, return CORE_ERROR,);
|
||||
|
||||
/* Open source file. */
|
||||
status = file_open(&s, from_path, FILE_READ, FILE_OS_DEFAULT);
|
||||
if (status)
|
||||
|
@ -296,6 +305,9 @@ static status_t file_transfer_contents(
|
|||
|
||||
status_t file_rename(const char *from_path, const char *to_path)
|
||||
{
|
||||
d_assert(from_path, return CORE_ERROR,);
|
||||
d_assert(to_path, return CORE_ERROR,);
|
||||
|
||||
if (rename(from_path, to_path) != 0)
|
||||
{
|
||||
return errno;
|
||||
|
@ -305,6 +317,9 @@ status_t file_rename(const char *from_path, const char *to_path)
|
|||
|
||||
status_t file_link(const char *from_path, const char *to_path)
|
||||
{
|
||||
d_assert(from_path, return CORE_ERROR,);
|
||||
d_assert(to_path, return CORE_ERROR,);
|
||||
|
||||
if (link(from_path, to_path) == -1)
|
||||
{
|
||||
return errno;
|
||||
|
@ -329,6 +344,8 @@ status_t file_append(
|
|||
|
||||
status_t file_eof(file_t *fptr)
|
||||
{
|
||||
d_assert(fptr, return CORE_ERROR,);
|
||||
|
||||
if (fptr->eof_hit == 1)
|
||||
{
|
||||
return CORE_EOF;
|
||||
|
@ -341,6 +358,9 @@ status_t file_read(file_t *thefile, void *buf, size_t *nbytes)
|
|||
ssize_t rv;
|
||||
size_t bytes_read;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(nbytes, return CORE_ERROR,);
|
||||
|
||||
if (*nbytes <= 0)
|
||||
{
|
||||
*nbytes = 0;
|
||||
|
@ -372,6 +392,10 @@ status_t file_write(
|
|||
{
|
||||
size_t rv;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(buf, return CORE_ERROR,);
|
||||
d_assert(nbytes, return CORE_ERROR,);
|
||||
|
||||
do
|
||||
{
|
||||
rv = write(thefile->filedes, buf, *nbytes);
|
||||
|
@ -392,6 +416,11 @@ status_t file_writev(file_t *thefile,
|
|||
status_t rv;
|
||||
ssize_t bytes;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(vec, return CORE_ERROR,);
|
||||
d_assert(nvec, return CORE_ERROR,);
|
||||
d_assert(nbytes, return CORE_ERROR,);
|
||||
|
||||
if ((bytes = writev(thefile->filedes, vec, nvec)) < 0)
|
||||
{
|
||||
*nbytes = 0;
|
||||
|
@ -429,6 +458,9 @@ status_t file_read_full(file_t *thefile, void *buf,
|
|||
status_t status;
|
||||
size_t total_read = 0;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(buf, return CORE_ERROR,);
|
||||
|
||||
do {
|
||||
size_t amt = nbytes;
|
||||
|
||||
|
@ -449,6 +481,9 @@ status_t file_write_full(file_t *thefile,
|
|||
status_t status;
|
||||
size_t total_written = 0;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(buf, return CORE_ERROR,);
|
||||
|
||||
do {
|
||||
size_t amt = nbytes;
|
||||
|
||||
|
@ -472,6 +507,11 @@ status_t file_writev_full(file_t *thefile,
|
|||
size_t amt = 0;
|
||||
size_t total = 0;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(vec, return CORE_ERROR,);
|
||||
d_assert(nvec, return CORE_ERROR,);
|
||||
d_assert(bytes_written, return CORE_ERROR,);
|
||||
|
||||
for (i = 0; i < nvec; i++)
|
||||
{
|
||||
total += vec[i].iov_len;
|
||||
|
@ -521,12 +561,16 @@ status_t file_putc(char ch, file_t *thefile)
|
|||
{
|
||||
size_t nbytes = 1;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
return file_write(thefile, &ch, &nbytes);
|
||||
}
|
||||
status_t file_getc(char *ch, file_t *thefile)
|
||||
{
|
||||
size_t nbytes = 1;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
return file_read(thefile, ch, &nbytes);
|
||||
}
|
||||
|
||||
|
@ -537,6 +581,9 @@ status_t file_gets(char *str, int len, file_t *thefile)
|
|||
const char *str_start = str;
|
||||
char *final = str + len - 1;
|
||||
|
||||
d_assert(str, return CORE_ERROR,);
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
if (len <= 1)
|
||||
{
|
||||
/* sort of like fgets(), which returns NULL and stores no bytes
|
||||
|
@ -576,6 +623,9 @@ status_t file_gets(char *str, int len, file_t *thefile)
|
|||
|
||||
status_t file_puts(const char *str, file_t *thefile)
|
||||
{
|
||||
d_assert(str, return CORE_ERROR,);
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
return file_write_full(thefile, str, strlen(str), NULL);
|
||||
}
|
||||
|
||||
|
@ -583,6 +633,8 @@ status_t file_sync(file_t *thefile)
|
|||
{
|
||||
status_t rv = CORE_OK;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
if (fsync(thefile->filedes))
|
||||
{
|
||||
rv = get_os_error();
|
||||
|
@ -596,6 +648,9 @@ status_t file_seek(file_t *thefile,
|
|||
{
|
||||
off_t rv;
|
||||
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
d_assert(offset, return CORE_ERROR,);
|
||||
|
||||
thefile->eof_hit = 0;
|
||||
|
||||
rv = lseek(thefile->filedes, *offset, where);
|
||||
|
@ -613,6 +668,9 @@ status_t file_seek(file_t *thefile,
|
|||
|
||||
status_t file_name_get(const char **fname, file_t *thefile)
|
||||
{
|
||||
d_assert(fname, return CORE_ERROR,);
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
*fname = thefile->fname;
|
||||
return CORE_OK;
|
||||
}
|
||||
|
@ -621,6 +679,8 @@ status_t file_perms_set(const char *fname, file_perms_t perms)
|
|||
{
|
||||
mode_t mode = unix_perms2mode(perms);
|
||||
|
||||
d_assert(fname, return CORE_ERROR,);
|
||||
|
||||
if (chmod(fname, mode) == -1)
|
||||
return errno;
|
||||
return CORE_OK;
|
||||
|
@ -632,6 +692,8 @@ status_t file_attrs_set(const char *fname,
|
|||
status_t status;
|
||||
file_info_t finfo;
|
||||
|
||||
d_assert(fname, return CORE_ERROR,);
|
||||
|
||||
/* Don't do anything if we can't handle the requested attributes */
|
||||
if (!(attr_mask & (ATTR_READONLY | ATTR_EXECUTABLE)))
|
||||
return CORE_OK;
|
||||
|
@ -683,6 +745,8 @@ status_t file_mtime_set(const char *fname, c_time_t mtime)
|
|||
status_t status;
|
||||
file_info_t finfo;
|
||||
|
||||
d_assert(fname, return CORE_ERROR,);
|
||||
|
||||
status = file_stat(&finfo, fname, FILE_INFO_ATIME);
|
||||
if (status)
|
||||
{
|
||||
|
@ -726,6 +790,8 @@ status_t dir_make(const char *path, file_perms_t perm)
|
|||
{
|
||||
mode_t mode = unix_perms2mode(perm);
|
||||
|
||||
d_assert(path, return CORE_ERROR,);
|
||||
|
||||
if (mkdir(path, mode) == 0)
|
||||
{
|
||||
return CORE_OK;
|
||||
|
@ -741,6 +807,8 @@ status_t dir_make(const char *path, file_perms_t perm)
|
|||
/* Remove trailing separators that don't affect the meaning of PATH. */
|
||||
static void path_canonicalize (char *dir)
|
||||
{
|
||||
d_assert(dir, return,);
|
||||
|
||||
/* At some point this could eliminate redundant components. For
|
||||
* now, it just makes sure there is no trailing slash. */
|
||||
size_t len = strlen (dir);
|
||||
|
@ -759,6 +827,9 @@ static void path_remove_last_component (char *dir, const char *path)
|
|||
int i;
|
||||
int len = 0;
|
||||
|
||||
d_assert(dir, return,);
|
||||
d_assert(path, return,);
|
||||
|
||||
strcpy(dir, path);
|
||||
path_canonicalize (dir);
|
||||
for (i = (strlen(dir) - 1); i >= 0; i--) {
|
||||
|
@ -774,6 +845,8 @@ status_t dir_make_recursive(const char *path, file_perms_t perm)
|
|||
{
|
||||
status_t err = 0;
|
||||
|
||||
d_assert(path, return CORE_ERROR,);
|
||||
|
||||
err = dir_make(path, perm); /* Try to make PATH right out */
|
||||
|
||||
if (err == EEXIST) /* It's OK if PATH exists */
|
||||
|
@ -800,6 +873,8 @@ status_t dir_make_recursive(const char *path, file_perms_t perm)
|
|||
}
|
||||
status_t dir_remove(const char *path)
|
||||
{
|
||||
d_assert(path, return CORE_ERROR,);
|
||||
|
||||
if (rmdir(path) == 0)
|
||||
{
|
||||
return CORE_OK;
|
||||
|
@ -859,6 +934,9 @@ static filetype_e filetype_from_mode(mode_t mode)
|
|||
static void fill_out_finfo(file_info_t *finfo, struct_stat *info,
|
||||
c_int32_t wanted)
|
||||
{
|
||||
d_assert(finfo, return,);
|
||||
d_assert(info, return,);
|
||||
|
||||
finfo->valid = FILE_INFO_MIN | FILE_INFO_IDENT | FILE_INFO_NLINK
|
||||
| FILE_INFO_OWNER | FILE_INFO_PROT;
|
||||
finfo->protection = unix_mode2perms(info->st_mode);
|
||||
|
@ -923,6 +1001,9 @@ status_t file_info_get(file_info_t *finfo,
|
|||
{
|
||||
struct_stat info;
|
||||
|
||||
d_assert(finfo, return CORE_ERROR,);
|
||||
d_assert(thefile, return CORE_ERROR,);
|
||||
|
||||
if (fstat(thefile->filedes, &info) == 0)
|
||||
{
|
||||
strcpy(finfo->fname, thefile->fname);
|
||||
|
@ -936,6 +1017,8 @@ status_t file_info_get(file_info_t *finfo,
|
|||
|
||||
status_t file_trunc(file_t *fp, off_t offset)
|
||||
{
|
||||
d_assert(fp, return CORE_ERROR,);
|
||||
|
||||
if (ftruncate(fp->filedes, offset) == -1)
|
||||
{
|
||||
return errno;
|
||||
|
@ -945,6 +1028,8 @@ status_t file_trunc(file_t *fp, off_t offset)
|
|||
|
||||
c_int32_t file_flags_get(file_t *f)
|
||||
{
|
||||
d_assert(f, return CORE_ERROR,);
|
||||
|
||||
return f->flags;
|
||||
}
|
||||
|
||||
|
@ -954,6 +1039,9 @@ status_t file_stat(file_info_t *finfo,
|
|||
struct_stat info;
|
||||
int srv;
|
||||
|
||||
d_assert(finfo, return CORE_ERROR,);
|
||||
d_assert(fname, return CORE_ERROR,);
|
||||
|
||||
if (wanted & FILE_INFO_LINK)
|
||||
srv = lstat(fname, &info);
|
||||
else
|
||||
|
@ -1005,6 +1093,8 @@ status_t file_stat(file_info_t *finfo,
|
|||
|
||||
status_t temp_dir_get(char *temp_dir)
|
||||
{
|
||||
d_assert(temp_dir, return CORE_ERROR,);
|
||||
|
||||
strcpy(temp_dir, "/tmp");
|
||||
return CORE_OK;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,10 @@
|
|||
#define PORT2 7778
|
||||
#define PPID 12345
|
||||
|
||||
#ifndef AI_PASSIVE
|
||||
#define AI_PASSIVE 1
|
||||
#endif
|
||||
|
||||
static void sctp_test1(abts_case *tc, void *data)
|
||||
{
|
||||
sock_id sctp;
|
||||
|
|
|
@ -106,7 +106,8 @@ status_t app_log_pid(const char *pid_path)
|
|||
FILE_WRITE | FILE_CREATE | FILE_TRUNCATE,
|
||||
FILE_UREAD | FILE_UWRITE | FILE_GREAD | FILE_WREAD)) != CORE_OK)
|
||||
{
|
||||
d_error("could not create %s", pid_path);
|
||||
d_error("CHECK PERMISSION of Installation Directory...");
|
||||
d_error("Cannot create PID file:`%s`", pid_path);
|
||||
return CORE_ERROR;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%" C_PID_T_FMT "\r\n", mypid);
|
||||
|
|
Loading…
Reference in New Issue