Commit 6ac1b7a3 authored by Haruki NAOI's avatar Haruki NAOI

Change file access authority.

parent 31f9f792
......@@ -92,7 +92,11 @@ int write_file_matlab(const char *fname,const char *vname,void *data,int length,
return -1;
//printf("Writing %d elements of type %d to %s\n",length,format,fname);
if(-1 == (access(fname,F_OK))){
creat(fname, 0644);
}else{
chmod(fname, 0644);
}
if (format == 10 || format ==11 || format == 12 || format == 13 || format == 14) {
fp = fopen(fname,"a+");
} else if (format != 10 && format !=11 && format != 12 && format != 13 && format != 14) {
......@@ -569,6 +573,11 @@ void set_glog_filelog(int enable) {
static FILE *fptr;
if ( enable ) {
if(-1 == (access(g_log->filelog_name,F_OK))){
creat(g_log->filelog_name, 0644);
}else{
chmod(g_log->filelog_name, 0644);
}
fptr = fopen(g_log->filelog_name,"w");
for (int c=0; c< MAX_LOG_COMPONENTS; c++ ) {
......@@ -591,6 +600,11 @@ void set_glog_filelog(int enable) {
void set_component_filelog(int comp) {
if (g_log->log_component[comp].stream == NULL || g_log->log_component[comp].stream == stdout) {
if(-1 == (access(g_log->log_component[comp].filelog_name,F_OK))){
creat(g_log->log_component[comp].filelog_name, 0644);
}else{
chmod(g_log->log_component[comp].filelog_name, 0644);
}
g_log->log_component[comp].stream = fopen(g_log->log_component[comp].filelog_name,"w");
}
......@@ -693,7 +707,7 @@ void flush_mem_to_file(void)
printf("log over write!!!\n");
}
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
fp=open(f_name, O_WRONLY | O_CREAT, 0666);
fp=open(f_name, O_WRONLY | O_CREAT, 0644);
if(fp==-1){
fprintf(stderr,"{LOG} %s %d Couldn't file open in %s \n",__FILE__,__LINE__,f_name);
}else{
......@@ -902,7 +916,7 @@ void close_log_mem(void){
}
if(log_mem_multi==1){
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
fp=open(f_name, O_WRONLY | O_CREAT, 0666);
fp=open(f_name, O_WRONLY | O_CREAT, 0644);
int ret = write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index);
if ( ret < 0) {
fprintf(stderr,"{LOG} %s %d Couldn't write in %s \n",__FILE__,__LINE__,f_name);
......@@ -912,7 +926,7 @@ void close_log_mem(void){
free(log_mem_d[0].buf_p);
snprintf(f_name,1024, "%s_%d.log",log_mem_filename,log_mem_file_cnt);
fp=open(f_name, O_WRONLY | O_CREAT, 0666);
fp=open(f_name, O_WRONLY | O_CREAT, 0644);
ret = write(fp, log_mem_d[1].buf_p, log_mem_d[1].buf_index);
if ( ret < 0) {
fprintf(stderr,"{LOG} %s %d Couldn't write in %s \n",__FILE__,__LINE__,f_name);
......@@ -921,7 +935,7 @@ void close_log_mem(void){
close(fp);
free(log_mem_d[1].buf_p);
}else{
fp=open(log_mem_filename, O_WRONLY | O_CREAT, 0666);
fp=open(log_mem_filename, O_WRONLY | O_CREAT, 0644);
int ret = write(fp, log_mem_d[0].buf_p, log_mem_d[0].buf_index);
if ( ret < 0) {
fprintf(stderr,"{LOG} %s %d Couldn't write in %s \n",__FILE__,__LINE__,log_mem_filename);
......
......@@ -42,6 +42,7 @@
#include <error.h>
#include <time.h>
#include <unistd.h>
#include <sys/stat.h>
#include "assertions.h"
......@@ -696,6 +697,11 @@ void vcd_signal_dumper_init(char *filename)
if (ouput_vcd) {
// char filename[] = "/tmp/openair_vcd_dump.vcd";
if(-1 == (access(filename,F_OK))){
creat(filename, 0644);
}else{
chmod(filename, 0644);
}
if ((vcd_fd = fopen(filename, "w+")) == NULL) {
perror("vcd_signal_dumper_init: cannot open file");
return;
......
......@@ -3,6 +3,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
char **unique_ids;
int unique_ids_size;
......@@ -175,6 +178,11 @@ int main(int n, char **v) {
exit(1);
}
if(-1 == (access(out_name,F_OK))){
creat(out_name, 0644);
}else{
chmod(out_name, 0644);
}
out = fopen(out_name, "w");
if (out == NULL) {
......
......@@ -30,7 +30,7 @@ int main(int argc, char *argv[]) {
exit(1);
}
mkfifo(argv[1],0666);
mkfifo(argv[1],0644);
int fd=open(argv[1], O_RDONLY);
if ( fd == -1 ) {
......
......@@ -98,7 +98,7 @@ void initTpool(char *params,tpool_t *pool, bool performanceMeas) {
pool->measurePerf=measr!=NULL;
if (measr) {
mkfifo(measr,0666);
mkfifo(measr,0644);
AssertFatal(-1 != (pool->dummyTraceFd=
open(measr, O_RDONLY| O_NONBLOCK)),"");
AssertFatal(-1 != (pool->traceFd=
......
......@@ -444,6 +444,11 @@ int flexran_agent_control_delegation(mid_t mod_id, const void *params, Protocol_
strcpy(target, RC.flexran[mod_id]->cache_name);
strcat(target, lib_name);
FILE *f;
if(-1 == (access(target,F_OK))){
creat(target, 0644);
}else{
chmod(target, 0644);
}
f = fopen(target, "wb");
if (f) {
......
......@@ -506,14 +506,14 @@ int logInit (void)
}
log_getconfig(g_log);
if (g_log->filelog) {
gfd = open(g_log->filelog_name, O_WRONLY | O_CREAT, 0666);
gfd = open(g_log->filelog_name, O_WRONLY | O_CREAT, 0644);
}
// could put a loop here to check for all comps
for (i=MIN_LOG_COMPONENTS; i < MAX_LOG_COMPONENTS; i++) {
if (g_log->log_component[i].filelog == 1 ) {
g_log->log_component[i].fd = open(g_log->log_component[i].filelog_name,
O_WRONLY | O_CREAT | O_APPEND, 0666);
O_WRONLY | O_CREAT | O_APPEND, 0644);
}
}
......@@ -1667,7 +1667,7 @@ void set_component_filelog(int comp)
if (g_log->log_component[comp].fd == 0) {
g_log->log_component[comp].fd = open(g_log->log_component[comp].filelog_name,
O_WRONLY | O_CREAT | O_TRUNC, 0666);
O_WRONLY | O_CREAT | O_TRUNC, 0644);
}
}
}
......
......@@ -50,6 +50,11 @@ int call_emu(char dst_dir[DIR_LENGTH_MAX])
char dst_file[DIR_LENGTH_MAX] = "";
strcat(dst_file, dst_dir);
strcat(dst_file, "emulation_result.txt");
if(-1 == (dst_file,F_OK)){
creat(dst_file, 0644);
}else{
chmod(dst_file, 0644);
}
file = fopen(dst_file,"w");
//system("../../../openair1/SIMULATION/LTE_PHY_L2/physim --help");
......
......@@ -54,6 +54,11 @@ int save_XML(int copy_or_move, char *src_file, char *output_dir, char *filename)
XML_saving_dir[sizeof(XML_saving_dir) - 1] = 0; // terminate string
strncat(dst_file, filename, sizeof(dst_file) - strlen(dst_file) - 1);
fs = fopen(src_file, "r");
if(-1 == (dst_file,F_OK)){
creat(dst_file, 0644);
}else{
chmod(dst_file, 0644);
}
ft = fopen(dst_file, "w");
if ((ft !=NULL)&&(fs!=NULL)) {
......
......@@ -495,6 +495,11 @@ int init_opt(void) {
break;
case OPT_PCAP:
if(-1 == (access(in_path,F_OK))){
creat(in_path, 0644);
}else{
chmod(in_path, 0644);
}
file_fd = fopen(in_path, "w");
if (file_fd == NULL) {
......
......@@ -240,9 +240,19 @@ void kpi_gen() {
char traffic[30];
#ifdef STANDALONE
FILE *file;
if(-1 == ("log_OTG.txt",F_OK)){
creat("log_OTG.txt", 0644);
}else{
chmod("log_OTG.txt", 0644);
}
file = fopen("log_OTG.txt", "w");
#else // Maybe to do modifo log function in order to clear file before a new write !!!!
FILE *fc;
if(-1 == ("/tmp/otg.log",F_OK)){
creat("/tmp/otg.log", 0644);
}else{
chmod("/tmp/otg.log", 0644);
}
fc=fopen("/tmp/otg.log","w");;
if(fc!=0)
......
......@@ -189,6 +189,11 @@ int memory_write(const char* datafile, const void* data, size_t size)
int rc = RETURNerror;
/* Open the data file for writing operation */
if(-1 == (access(datafile,F_OK))){
creat(datafile, 0644);
}else{
chmod(datafile, 0644);
}
FILE* fp = fopen(datafile, "wb");
if (fp != NULL) {
......
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