/*+++++++++++++++++++++ send_got_log_capabilities() +++++++++++++++++++++*/ static int send_got_log_capabilities(int afd_no) { int mon_cmd_fd; #ifdef WITHOUT_FIFO_RW_SUPPORT int mon_cmd_readfd; #endif char mon_cmd_fifo[MAX_PATH_LENGTH]; (void)sprintf(mon_cmd_fifo, "%s%s%s", p_work_dir, FIFO_DIR, MON_CMD_FIFO); /* Open fifo to AFD to receive commands. */ #ifdef WITHOUT_FIFO_RW_SUPPORT if (open_fifo_rw(mon_cmd_fifo, &mon_cmd_readfd, &mon_cmd_fd) == -1) #else if ((mon_cmd_fd = open(mon_cmd_fifo, O_RDWR)) == -1) #endif { system_log(ERROR_SIGN, __FILE__, __LINE__, "Could not open fifo %s : %s", mon_cmd_fifo, strerror(errno)); } else { int length; char cmd[1 + SIZEOF_INT]; cmd[0] = GOT_LC; (void)memcpy(&cmd[1], &afd_no, SIZEOF_INT); length = 1 + SIZEOF_INT; if (write(mon_cmd_fd, cmd, length) != length) { system_log(ERROR_SIGN, __FILE__, __LINE__, "Failed to write() %d bytes to `%s' : %s", length, mon_cmd_fifo, strerror(errno)); length = INCORRECT; } else { length = SUCCESS; } #ifdef WITHOUT_FIFO_RW_SUPPORT if (close(mon_cmd_readfd) == -1) { system_log(WARN_SIGN, __FILE__, __LINE__, "Failed to close() `%s' (read) : %s", mon_cmd_fifo, strerror(errno)); } #endif if (close(mon_cmd_fd) == -1) { system_log(WARN_SIGN, __FILE__, __LINE__, "Failed to close() `%s' : %s", mon_cmd_fifo, strerror(errno)); } return(length); } return(INCORRECT); }
/*+++++++++++++++++++++++++++++ stat_exit() +++++++++++++++++++++++++++++*/ static void stat_exit(void) { if (msync(((char *)stat_db - AFD_WORD_OFFSET), stat_db_size, MS_SYNC) == -1) { system_log(ERROR_SIGN, __FILE__, __LINE__, "msync() error : %s", strerror(errno)); } if (msync(((char *)istat_db - AFD_WORD_OFFSET), istat_db_size, MS_SYNC) == -1) { system_log(ERROR_SIGN, __FILE__, __LINE__, "msync() error : %s", strerror(errno)); } if (munmap(((char *)stat_db - AFD_WORD_OFFSET), stat_db_size) == -1) { system_log(ERROR_SIGN, __FILE__, __LINE__, "munmap() error : %s", strerror(errno)); } if (munmap(((char *)istat_db - AFD_WORD_OFFSET), istat_db_size) == -1) { system_log(ERROR_SIGN, __FILE__, __LINE__, "munmap() error : %s", strerror(errno)); } return; }
void sanitycheck(ni_name mytag) { ni_name master, mastertag; unsigned long masteraddr; interface_list_t *l; int i; if (!getmaster(db_ni, &master, &mastertag)) { /* no master! */ system_log(LOG_ERR, "tag %s: can't determine master's host name", mytag); return; } masteraddr = getaddress(db_ni, master); if (masteraddr == 0) { /* no address for master */ system_log(LOG_ERR, "tag %s: can't determine master's address", mytag); return; } l = sys_interfaces(); if (l == NULL) return; for (i = 0; i < l->count; i++) { if ((l->interface[i].flags & IFF_UP) == 0) continue; if (l->interface[i].flags & IFF_LOOPBACK) continue; checkserves(masteraddr, mastertag, l->interface[i].addr.s_addr, mytag); } sys_interfaces_release(l); }
static void micoNotify_WifiStatusHandler(WiFiEvent event, mico_Context_t * const inContext) { system_log_trace(); (void)inContext; switch (event) { case NOTIFY_STATION_UP: system_log("Station up"); MicoRfLed(true); break; case NOTIFY_STATION_DOWN: system_log("Station down"); MicoRfLed(false); break; case NOTIFY_AP_UP: system_log("uAP established"); MicoRfLed(true); break; case NOTIFY_AP_DOWN: system_log("uAP deleted"); MicoRfLed(false); break; default: break; } return; }
static u_int32_t NI_checksum_for_index(agent_private *ap, u_int32_t i) { struct timeval now; u_int32_t age; ni_status status; ni_proplist pl; u_int32_t sum; ni_index where; if (ap == NULL) return 0; if (i >= ap->domain_count) return 0; gettimeofday(&now, (struct timezone *)NULL); age = now.tv_sec - ap->domain[i].checksum_time; if (age <= ap->latency) return ap->domain[i].checksum; NI_INIT(&pl); syslock_lock(rpcLock); status = sa_statistics(ap->domain[i].handle, &pl); syslock_unlock(rpcLock); if (status != NI_OK) { system_log(LOG_ERR, "ni_statistics: %s", ni_error(status)); ni_proplist_free(&pl); return 0; } /* checksum should be first (and only!) property */ where = NI_INDEX_NULL; if (pl.ni_proplist_len > 0) { if (strcmp(pl.ni_proplist_val[0].nip_name, "checksum")) where = 0; else where = ni_proplist_match(pl, "checksum", NULL); } if (where == NI_INDEX_NULL) { system_log(LOG_ERR, "ap->domain %lu: can't get checksum", i); ni_proplist_free(&pl); return 0; } sscanf(pl.ni_proplist_val[where].nip_val.ni_namelist_val[0], "%lu", (unsigned long *)&sum); ni_proplist_free(&pl); ap->domain[i].checksum_time = now.tv_sec; ap->domain[i].checksum = sum; return sum; }
/*$$$$$$$$$$$$$$$$$$$$$$$$$$ send_proc_fin() $$$$$$$$$$$$$$$$$$$$$$$$$$$$*/ void send_proc_fin(int more_data) { if (p_work_dir != NULL) { int fd; #ifdef WITHOUT_FIFO_RW_SUPPORT int readfd; #endif char sf_fin_fifo[MAX_PATH_LENGTH]; (void)strcpy(sf_fin_fifo, p_work_dir); (void)strcat(sf_fin_fifo, FIFO_DIR); (void)strcat(sf_fin_fifo, SF_FIN_FIFO); #ifdef WITHOUT_FIFO_RW_SUPPORT if (open_fifo_rw(sf_fin_fifo, &readfd, &fd) == -1) #else if ((fd = open(sf_fin_fifo, O_RDWR)) == -1) #endif { system_log(ERROR_SIGN, __FILE__, __LINE__, "Could not open fifo `%s' : %s", sf_fin_fifo, strerror(errno)); } else { pid_t pid; #ifdef _FIFO_DEBUG char cmd[2]; /* Tell FD we are finished. */ cmd[0] = ACKN; cmd[1] = '\0'; show_fifo_data('W', "sf_fin", cmd, 1, __FILE__, __LINE__); #endif if (more_data == NO) { pid = db.my_pid; } else { pid = -db.my_pid; } if (write(fd, &pid, sizeof(pid_t)) != sizeof(pid_t)) { system_log(WARN_SIGN, __FILE__, __LINE__, "write() error : %s", strerror(errno)); } #ifdef WITHOUT_FIFO_RW_SUPPORT (void)close(readfd); #endif (void)close(fd); } } return; }
/*############################ check_fra() ##############################*/ int check_fra(int passive) { if (fra != NULL) { char *ptr; ptr = (char *)fra; ptr -= AFD_WORD_OFFSET; if (*(int *)ptr == STALE) { #ifdef HAVE_MMAP if (munmap(ptr, fra_size) == -1) { system_log(ERROR_SIGN, __FILE__, __LINE__, _("Failed to munmap() from FRA [fra_id = %d fra_size = %d] : %s"), fra_id, fra_size, strerror(errno)); } #else if (munmap_emu(ptr) == -1) { system_log(ERROR_SIGN, __FILE__, __LINE__, _("Failed to munmap_emu() from FRA (%d) : %s"), fra_id, strerror(errno)); } #endif if (passive == YES) { if (fra_attach_passive() != SUCCESS) { system_log(ERROR_SIGN, __FILE__, __LINE__, _("Passive attach to FRA failed.")); exit(INCORRECT); } } else { if (fra_attach() != SUCCESS) { system_log(ERROR_SIGN, __FILE__, __LINE__, _("Failed to attach to FRA.")); exit(INCORRECT); } } return(YES); } } return(NO); }
/* * * function: is_guide * * * * 09/20/2004 [JWW] - Log a Warning on Failed MySql query * * - simplified the logic flow by nesting * * */ int is_guide (const char *username) { MYSQL_RES *result; MYSQL_ROW row; char buf[MAX_STRING_LENGTH]; int user_id = 0; if (!username || !*username) return 0; mysql_safe_query ("SELECT user_id FROM forum_users WHERE username = '******'", username); if ((result = mysql_store_result (database)) != NULL) { row = mysql_fetch_row (result); if (row) { user_id = atoi (row[0]); mysql_safe_query ("SELECT user_id FROM forum_user_group WHERE user_id = %d AND group_id = 2521", user_id); mysql_free_result (result); result = NULL; if ((result = mysql_store_result (database)) != NULL) { row = mysql_fetch_row (result); if (row) { mysql_free_result (result); result = NULL; return 1; } else mysql_free_result (result); result = NULL; } } else { sprintf (buf, "Warning: is_guide(): %s", mysql_error (database)); system_log (buf, true); } } else { sprintf (buf, "Warning: is_guide(): %s", mysql_error (database)); system_log (buf, true); } return 0; }
/*########################## make_process_amg() #########################*/ pid_t make_process_amg(char *work_dir, char *prog_name, int rescan_time, int max_process, mode_t create_source_dir_mode, pid_t udc_pid) { pid_t proc_id; char rt_str[MAX_INT_LENGTH], mp_str[MAX_INT_LENGTH], nd_str[MAX_INT_LENGTH], sd_str[MAX_LONG_LENGTH], up_str[MAX_PID_T_LENGTH]; /* First convert int's into a char string. */ (void)snprintf(rt_str, MAX_INT_LENGTH, "%d", rescan_time); (void)snprintf(mp_str, MAX_INT_LENGTH, "%d", max_process); (void)snprintf(nd_str, MAX_INT_LENGTH, "%d", no_of_local_dirs); (void)snprintf(sd_str, MAX_LONG_LENGTH, "%ld", (long)create_source_dir_mode); #if SIZEOF_PID_T == 4 (void)snprintf(up_str, MAX_PID_T_LENGTH, "%d", (pri_pid_t)udc_pid); #else (void)snprintf(up_str, MAX_PID_T_LENGTH, "%lld", (pri_pid_t)udc_pid); #endif switch (proc_id = fork()) { case -1: /* Could not generate process. */ system_log(FATAL_SIGN, __FILE__, __LINE__, "Could not create a new process : %s", strerror(errno)); exit(INCORRECT); case 0: /* Child process. */ if (execlp(prog_name, prog_name, work_dir, rt_str, mp_str, nd_str, sd_str, up_str, (char *)0) < 0) { system_log(ERROR_SIGN, __FILE__, __LINE__, "Failed to start process %s : %s", prog_name, strerror(errno)); _exit(INCORRECT); } exit(SUCCESS); default: /* Parent process. */ return(proc_id); } return(INCORRECT); }
/*+++++++++++++++++++++++++++++++ aw_exit() +++++++++++++++++++++++++++++*/ static void aw_exit(void) { if ((removed_archives > 0) || (removed_files > 0)) { system_log(INFO_SIGN, NULL, 0, _("Removed %u archives with %u files."), removed_archives, removed_files); } system_log(INFO_SIGN, NULL, 0, "Stopped %s.", ARCHIVE_WATCH); (void)close(sys_log_fd); return; }
void assignment (CHAR_DATA * mob, MOBPROG_DATA * program, char *target_name, char **p) { char buf[MAX_STRING_LENGTH]; VAR_DATA *target; if (!(target = getvar (mob, target_name))) { sprintf (buf, "Assignment to unknown variable: %s", target_name); system_log (buf, true); sprintf (buf, "trigger %s, mob %d", program->trigger_name, mob->mob->nVirtual); system_log (buf, true); program->line = duplicateString (current_line); program->flags |= MPF_BROKEN; return; } if (!mob_get_token (p, buf, MT_EQUAL)) { system_log ("Assignment needs equal.", true); program->line = duplicateString (current_line); program->flags |= MPF_BROKEN; return; } if (target->type == MP_TYPE_INTEGER) { target->value = mp_eval_eq (mob, p); return; } if (target->type == MP_TYPE_CHAR_DATA || target->type == MP_TYPE_OBJ_DATA || target->type == MP_TYPE_ROOM_DATA) { target->value = mp_eval_eq (mob, p); return; } else if (target->type == MP_TYPE_STRING) { mob_string (mob, p, buf); if (target->value) free_mem ((char *) target->value); target->value = (long int) duplicateString (buf); } }
void nibind_svc_run(void) { fd_set readfds; for (;;) { readfds = svc_fdset; switch (select(svc_maxfd+1, &readfds, NULL, NULL, NULL)) { case -1: if (errno != EINTR) { system_log(LOG_ALERT, "unexpected errno: %m, aborting"); } break; case 0: break; default: svc_getreqset(&readfds); break; } if (waitreg == 0) { waitreg = -1; if (debug == 1) { system_log(LOG_DEBUG, "all servers registered"); } else { system_log(LOG_DEBUG, "all servers registered - signalling parent"); killparent(); } } if (restart == 1) { svc_unregister(NIBIND_PROG, NIBIND_VERS); pmap_unset(NIBIND_PROG, NIBIND_VERS); respawn(); } } }
static void micoNotify_WlanFatalErrHandler(mico_Context_t * const inContext) { system_log_trace(); (void)inContext; system_log("Wlan Fatal Err!"); MicoSystemReboot(); }
/*++++++++++++++++++++++++++++++ sig_bus() ++++++++++++++++++++++++++++++*/ static void sig_bus(int signo) { reset_fsa((struct job *)&db, IS_FAULTY_VAR, 0, 0); system_log(DEBUG_SIGN, __FILE__, __LINE__, "Uuurrrggh! Received SIGBUS."); abort(); }
u_int32_t FF_new(void **c, char *args, dynainfo *d) { agent_private *ap; if (c == NULL) return 1; ap = (agent_private *)calloc(1, sizeof(agent_private)); *c = ap; if (args == NULL) { ap->dir = copyString(DEFAULT_FF_DIR); ap->flags = 0; } else { ap->dir = copyString(args); ap->flags = 1; } ap->dyna = d; system_log(LOG_DEBUG, "Allocated FF 0x%08x\n", (int)ap); return 0; }
/*######################### start_log_process() #########################*/ void start_log_process(int afd, unsigned int log_capabilities) { switch (pl[afd].log_pid = fork()) { case -1 : /* Error creating process. */ /* Could not generate process */ pl[afd].next_retry_time_log = time(NULL) + RETRY_INTERVAL; system_log(ERROR_SIGN, __FILE__, __LINE__, "Could not create a new process : %s", strerror(errno)); return; case 0 : /* Child process. */ { char str_afd_num[MAX_INT_LENGTH], str_lc_num[MAX_INT_LENGTH]; in_child = YES; (void)sprintf(str_afd_num, "%d", afd); (void)sprintf(str_lc_num, "%u", log_capabilities); (void)execlp(LOG_MON, LOG_MON, WORK_DIR_ID, p_work_dir, str_afd_num, str_lc_num, (char *)0); } _exit(INCORRECT); default : /* Parent process. */ pl[afd].next_retry_time_log = 0L; return; } }
DESCR__S_M3 /* ** NAME ** my_usleep - sleeps for interval of microseconds ** ** SYNOPSIS ** void my_usleep(unsigned long msec) ** ** DESCRIPTION ** The my_usleep() function suspends execution of the calling ** process for msec microseconds. ** ** RETURN VALUES ** None. ** ** AUTHOR ** H.Kiehl ** ** HISTORY ** 23.02.1996 H.Kiehl Created ** 06.08.2001 H.Kiehl Make use of tv_sec field when msec is large ** enough. ** */ DESCR__E_M3 #include <string.h> #include <stdlib.h> /* exit() */ #include <sys/time.h> /* struct timeval */ #include <sys/types.h> /* fd_set */ #include <unistd.h> /* select() */ #include <errno.h> /*############################# my_usleep() #############################*/ void my_usleep(unsigned long msec) { struct timeval timeout; if (msec > 999999) { timeout.tv_sec = msec / 1000000; timeout.tv_usec = msec % 1000000; } else { timeout.tv_sec = 0; timeout.tv_usec = msec; } if (select(0, (fd_set *)0, (fd_set *)0, (fd_set *)0, &timeout) < 0) { system_log(FATAL_SIGN, __FILE__, __LINE__, _("select() error : %s"), strerror(errno)); exit(INCORRECT); } return; }
static void micoNotify_StackOverflowErrHandler(char *taskname, mico_Context_t * const inContext) { system_log_trace(); (void)inContext; system_log("Thread %s overflow, system rebooting", taskname); MicoSystemReboot(); }
/*+++++++++++++++++++++++++ get_afd_config_value() ++++++++++++++++++++++*/ static void get_afd_config_value(void) { char *buffer, config_file[MAX_PATH_LENGTH]; (void)snprintf(config_file, MAX_PATH_LENGTH, "%s%s%s", p_work_dir, ETC_DIR, AFD_CONFIG_FILE); if ((eaccess(config_file, F_OK) == 0) && (read_file_no_cr(config_file, &buffer, YES, __FILE__, __LINE__) != INCORRECT)) { char value[MAX_INT_LENGTH]; if (get_definition(buffer, ARCHIVE_WATCH_PRIORITY_DEF, value, MAX_INT_LENGTH) != NULL) { if (setpriority(PRIO_PROCESS, 0, atoi(value)) == -1) { system_log(WARN_SIGN, __FILE__, __LINE__, "Failed to set priority to %d : %s", atoi(value), strerror(errno)); } } free(buffer); } return; }
void system_connect_wifi_fast( mico_Context_t * const inContext) { system_log_trace(); network_InitTypeDef_adv_st wNetConfig; memset(&wNetConfig, 0x0, sizeof(network_InitTypeDef_adv_st)); mico_rtos_lock_mutex(&inContext->flashContentInRam_mutex); strncpy((char*)wNetConfig.ap_info.ssid, inContext->flashContentInRam.micoSystemConfig.ssid, maxSsidLen); memcpy(wNetConfig.ap_info.bssid, inContext->flashContentInRam.micoSystemConfig.bssid, 6); wNetConfig.ap_info.channel = inContext->flashContentInRam.micoSystemConfig.channel; wNetConfig.ap_info.security = inContext->flashContentInRam.micoSystemConfig.security; memcpy(wNetConfig.key, inContext->flashContentInRam.micoSystemConfig.key, inContext->flashContentInRam.micoSystemConfig.keyLength); wNetConfig.key_len = inContext->flashContentInRam.micoSystemConfig.keyLength; if(inContext->flashContentInRam.micoSystemConfig.dhcpEnable == true) wNetConfig.dhcpMode = DHCP_Client; else wNetConfig.dhcpMode = DHCP_Disable; strncpy((char*)wNetConfig.local_ip_addr, inContext->flashContentInRam.micoSystemConfig.localIp, maxIpLen); strncpy((char*)wNetConfig.net_mask, inContext->flashContentInRam.micoSystemConfig.netMask, maxIpLen); strncpy((char*)wNetConfig.gateway_ip_addr, inContext->flashContentInRam.micoSystemConfig.gateWay, maxIpLen); strncpy((char*)wNetConfig.dnsServer_ip_addr, inContext->flashContentInRam.micoSystemConfig.dnsServer, maxIpLen); mico_rtos_unlock_mutex(&inContext->flashContentInRam_mutex); wNetConfig.wifi_retry_interval = 100; system_log("Connect to %s.....", wNetConfig.ap_info.ssid); micoWlanStartAdv(&wNetConfig); }
/*########################## stop_log_process() #########################*/ void stop_log_process(int process) { int status; if (kill(pl[process].log_pid, SIGINT) == -1) { if (errno != ESRCH) { system_log(WARN_SIGN, __FILE__, __LINE__, #if SIZEOF_PID_T == 4 "Failed to kill %s process to %s (%d) : %s", #else "Failed to kill %s process to %s (%lld) : %s", #endif LOG_MON, pl[process].afd_alias, (pri_pid_t)pl[process].log_pid, strerror(errno)); } } else { if (waitpid(pl[process].log_pid, &status, 0) == pl[process].log_pid) { pl[process].log_pid = 0; } } return; }
static void parentexit(int x) { system_log(LOG_DEBUG, "parent exiting"); system_log_close(); exit(0); }
/*++++++++++++++++++++++++++++++ sig_segv() +++++++++++++++++++++++++++++*/ static void sig_segv(int signo) { system_log(FATAL_SIGN, __FILE__, __LINE__, "Aaarrrggh! Received SIGSEGV."); /* Dump core so we know what happened! */ abort(); }
/*++++++++++++++++++++++++++++++ sig_bus() ++++++++++++++++++++++++++++++*/ static void sig_bus(int signo) { system_log(FATAL_SIGN, __FILE__, __LINE__, "Uuurrrggh! Received SIGBUS."); /* Dump core so we know what happened! */ abort(); }
/*++++++++++++++++++++++++++++++ sig_segv() +++++++++++++++++++++++++++++*/ static void sig_segv(int signo) { reset_fsa((struct job *)&db, IS_FAULTY_VAR, 0, 0); system_log(DEBUG_SIGN, __FILE__, __LINE__, "Aaarrrggh! Received SIGSEGV. Remove the programmer who wrote this!"); abort(); }
static ni_status start_service(ni_name tag) { ni_name master; ni_name mastertag; ni_status status; ni_name dbname; struct in_addr inaddr; system_log(LOG_DEBUG, "directory cleanup"); dir_cleanup(tag); dir_getnames(tag, &dbname, NULL, NULL); system_log(LOG_DEBUG, "initializing server"); status = ni_init(dbname, &db_ni); ni_name_free(&dbname); if (status != NI_OK) { system_log(LOG_ERR, "ni_init failed: %s", ni_error(status)); return (status); } system_log(LOG_DEBUG, "checksum = %u", ni_getchecksum(db_ni)); /* "local" is never a clone */ if (strcmp(tag, "local")) { if (getmaster(db_ni, &master, &mastertag)) { inaddr.s_addr = getaddress(db_ni, master); if (!sys_is_my_address(&inaddr)) i_am_clone++; if (!ni_name_match(tag, mastertag)) i_am_clone++; ni_name_free(&master); ni_name_free(&mastertag); } } if (forcedIsRoot == 0) forcedIsRoot = get_forced_root(db_ni); system_log(LOG_DEBUG, "registering tag %s", tag); status = register_it(tag); return (status); }
void close_sockets (int s) { system_log ("Closing all sockets.", false); while (descriptor_list) close_socket (descriptor_list); close (s); }
/*############################# get_afd_name() ##########################*/ int get_afd_name(char *afd_name) { int fd, n; char afd_file_name[MAX_PATH_LENGTH]; if (snprintf(afd_file_name, MAX_PATH_LENGTH, "%s%s/%s", p_work_dir, ETC_DIR, AFD_NAME) >= MAX_PATH_LENGTH) { return(INCORRECT); } if ((fd = open(afd_file_name, O_RDONLY)) < 0) { return(INCORRECT); } if ((n = read(fd, afd_name, MAX_AFD_NAME_LENGTH)) < 0) { (void)close(fd); return(INCORRECT); } if (close(fd) == -1) { system_log(DEBUG_SIGN, __FILE__, __LINE__, "close() error : %s", strerror(errno)); } if (n > 0) { if (afd_name[n - 1] == '\n') { afd_name[n - 1] = '\0'; } else { if (n < MAX_AFD_NAME_LENGTH) { afd_name[n] = '\0'; } else { afd_name[MAX_AFD_NAME_LENGTH - 1] = '\0'; } } } else { return(INCORRECT); } return(SUCCESS); }
DESCR__S_M3 /* ** NAME ** make_fifo - creates a new fifo ** ** SYNOPSIS ** int make_fifo(char *fifoname) ** ** DESCRIPTION ** The function make_fifo() creates the fifo 'fifoname' with read ** and write permissions of the owner. ** ** RETURN VALUES ** Returns SUCCESS when the fifo was created. Otherwise it returns ** INCORRECT. ** ** AUTHOR ** H.Kiehl ** ** HISTORY ** 14.12.1995 H.Kiehl Created ** */ DESCR__E_M3 #include <string.h> /* strerror() */ #include <sys/types.h> #include <sys/stat.h> /* mkfifo() */ #include <errno.h> /*############################ make_fifo() ##############################*/ int make_fifo(char *fifoname) { /* Create new fifo. */ #ifdef GROUP_CAN_WRITE if (mkfifo(fifoname, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) == -1) #else if (mkfifo(fifoname, S_IRUSR | S_IWUSR) == -1) #endif { if (errno != EEXIST) { system_log(ERROR_SIGN, __FILE__, __LINE__, _("Could not create fifo `%s' : %s"), fifoname, strerror(errno)); return(INCORRECT); } } return(SUCCESS); }
/*########################### gsf_check_fsa() ###########################*/ int gsf_check_fsa(struct job *p_db) { int ret; if (p_db->fsa_pos == INCORRECT) { ret = NEITHER; } else { if ((p_no_of_hosts != NULL) && (*p_no_of_hosts == STALE)) { fsa_detach_pos(p_db->fsa_pos); if (fsa_attach("sf/gf_xxx") == SUCCESS) { p_db->fsa_pos = get_host_position(fsa, p_db->host_alias, no_of_hosts); (void)fsa_detach(NO); if (p_db->fsa_pos != INCORRECT) { if ((ret = fsa_attach_pos(p_db->fsa_pos)) != SUCCESS) { system_log(ERROR_SIGN, __FILE__, __LINE__, "Failed to attach to FSA position %d (%d).", p_db->fsa_pos, ret); p_db->fsa_pos = INCORRECT; ret = NEITHER; } else { p_db->lock_offset = AFD_WORD_OFFSET + (p_db->fsa_pos * sizeof(struct filetransfer_status)); ret = YES; } } else { ret = NEITHER; } } else { p_db->fsa_pos = INCORRECT; ret = NEITHER; } } else { ret = NO; } } return(ret); }