bt_open.c File Reference

#include <sys/param.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "../include/db.h"
#include "btree.h"

Include dependency graph for bt_open.c:

Go to the source code of this file.

Functions

int __bt_fd (DB *dbp) const
DB__bt_open (char *fname, int flags, int mode, const BTREEINFO *openinfo, int dflags) const
static int nroot __P ((BTREE *))
static int byteorder __P ((void))
static int byteorder ()
static int nroot (BTREE *t)
static int tmp ()


Function Documentation

int __bt_fd ( DB dbp  )  const

Definition at line 439 of file bt_open.c.

References B_INMEM, _btree::bt_fd, _btree::bt_mp, _btree::bt_pinned, errno, F_ISSET, mpool_put, and NULL.

Referenced by __bt_open().

00441 {
00442    BTREE *t;
00443 
00444    t = dbp->internal;
00445 
00446    /* Toss any page pinned across calls. */
00447    if (t->bt_pinned != NULL) {
00448       mpool_put(t->bt_mp, t->bt_pinned, 0);
00449       t->bt_pinned = NULL;
00450    }
00451 
00452    /* In-memory database can't have a file descriptor. */
00453    if (F_ISSET(t, B_INMEM)) {
00454       errno = ENOENT;
00455       return (-1);
00456    }
00457    return (t->bt_fd);
00458 }

DB* __bt_open ( char *  fname,
int  flags,
int  mode,
const BTREEINFO openinfo,
int  dflags 
) const

Definition at line 90 of file bt_open.c.

References __bt_close(), __bt_defcmp(), __bt_defpfx(), __bt_delete(), __bt_fd(), __bt_get(), __bt_pgin(), __bt_pgout(), __bt_put(), __bt_seq(), __bt_sync(), b, B_DB_LOCK, B_DB_SHMEM, B_DB_TXN, B_INMEM, B_METADIRTY, B_NEEDSWAP, B_NODUPS, B_RDONLY, BIG_ENDIAN, _btree::bt_dbp, _btree::bt_fd, _btree::bt_free, _btree::bt_lorder, _btree::bt_mp, _btree::bt_nrecs, _btree::bt_order, _btree::bt_ovflsize, _btree::bt_psize, _btree::bt_rfd, BTDATAOFF, BTREEMAGIC, BTREEVERSION, byteorder(), BTREEINFO::cachesize, DB_BTREE, DB_LOCK, DB_SHMEM, DB_TXN, dbp, DEFMINKEYPAGE, EFTYPE, errno, F_CLR, F_ISSET, F_SET, _btree::flags, BTREEINFO::flags, free, __db::internal, LITTLE_ENDIAN, BTREEINFO::lorder, malloc, MAX_PAGE_OFFSET, MINCACHE, BTREEINFO::minkeypage, MINPSIZE, mpool_filter, mpool_open, NBLEAFDBT, NOVFLSIZE, nroot(), NULL, P_INVALID, BTREEINFO::psize, R_DUP, RET_ERROR, SAVEMETA, tmp(), and __db::type.

Referenced by __rec_open(), and dbopen().

00094 {
00095    struct stat sb;
00096    BTMETA m;
00097    BTREE *t;
00098    BTREEINFO b;
00099    DB *dbp;
00100    pgno_t ncache;
00101    ssize_t nr;
00102    int machine_lorder;
00103 
00104    t = NULL;
00105 
00106    /*
00107     * Intention is to make sure all of the user's selections are okay
00108     * here and then use them without checking.  Can't be complete, since
00109     * we don't know the right page size, lorder or flags until the backing
00110     * file is opened.  Also, the file's page size can cause the cachesize
00111     * to change.
00112     */
00113    machine_lorder = byteorder();
00114    if (openinfo) {
00115       b = *openinfo;
00116 
00117       /* Flags: R_DUP. */
00118       if (b.flags & ~(R_DUP))
00119          goto einval;
00120 
00121       /*
00122        * Page size must be indx_t aligned and >= MINPSIZE.  Default
00123        * page size is set farther on, based on the underlying file
00124        * transfer size.
00125        */
00126       if (b.psize &&
00127           (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 ||
00128           b.psize & (sizeof(indx_t) - 1)))
00129          goto einval;
00130 
00131       /* Minimum number of keys per page; absolute minimum is 2. */
00132       if (b.minkeypage) {
00133          if (b.minkeypage < 2)
00134             goto einval;
00135       } else
00136          b.minkeypage = DEFMINKEYPAGE;
00137 
00138       /* If no comparison, use default comparison and prefix. */
00139       if (b.compare == NULL) {
00140          b.compare = __bt_defcmp;
00141          if (b.prefix == NULL)
00142             b.prefix = __bt_defpfx;
00143       }
00144 
00145       if (b.lorder == 0)
00146          b.lorder = machine_lorder;
00147    } else {
00148       b.compare = __bt_defcmp;
00149       b.cachesize = 0;
00150       b.flags = 0;
00151       b.lorder = machine_lorder;
00152       b.minkeypage = DEFMINKEYPAGE;
00153       b.prefix = __bt_defpfx;
00154       b.psize = 0;
00155    }
00156 
00157    /* Check for the ubiquitous PDP-11. */
00158    if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN)
00159       goto einval;
00160 
00161    /* Allocate and initialize DB and BTREE structures. */
00162    if ((t = (BTREE *)malloc(sizeof(BTREE))) == NULL)
00163       goto err;
00164    memset(t, 0, sizeof(BTREE));
00165    t->bt_fd = -1;       /* Don't close unopened fd on error. */
00166    t->bt_lorder = b.lorder;
00167    t->bt_order = NOT;
00168    t->bt_cmp = b.compare;
00169    t->bt_pfx = b.prefix;
00170    t->bt_rfd = -1;
00171 
00172    if ((t->bt_dbp = dbp = (DB *)malloc(sizeof(DB))) == NULL)
00173       goto err;
00174    memset(t->bt_dbp, 0, sizeof(DB));
00175    if (t->bt_lorder != machine_lorder)
00176       F_SET(t, B_NEEDSWAP);
00177 
00178    dbp->type = DB_BTREE;
00179    dbp->internal = t;
00180    dbp->close = __bt_close;
00181    dbp->del = __bt_delete;
00182    dbp->fd = __bt_fd;
00183    dbp->get = __bt_get;
00184    dbp->put = __bt_put;
00185    dbp->seq = __bt_seq;
00186    dbp->sync = __bt_sync;
00187 
00188    /*
00189     * If no file name was supplied, this is an in-memory btree and we
00190     * open a backing temporary file.  Otherwise, it's a disk-based tree.
00191     */
00192    if (fname) {
00193       switch (flags & O_ACCMODE) {
00194       case O_RDONLY:
00195          F_SET(t, B_RDONLY);
00196          break;
00197       case O_RDWR:
00198          break;
00199       case O_WRONLY:
00200       default:
00201          goto einval;
00202       }
00203 
00204       if ((t->bt_fd = open(fname, flags, mode)) < 0)
00205          goto err;
00206 
00207    } else {
00208       if ((flags & O_ACCMODE) != O_RDWR)
00209          goto einval;
00210       if ((t->bt_fd = tmp()) == -1)
00211          goto err;
00212       F_SET(t, B_INMEM);
00213    }
00214 
00215    if (fcntl(t->bt_fd, F_SETFD, 1) == -1)
00216       goto err;
00217 
00218    if (fstat(t->bt_fd, &sb))
00219       goto err;
00220    if (sb.st_size) {
00221       if ((nr = read(t->bt_fd, &m, sizeof(BTMETA))) < 0)
00222          goto err;
00223       if (nr != sizeof(BTMETA))
00224          goto eftype;
00225 
00226       /*
00227        * Read in the meta-data.  This can change the notion of what
00228        * the lorder, page size and flags are, and, when the page size
00229        * changes, the cachesize value can change too.  If the user
00230        * specified the wrong byte order for an existing database, we
00231        * don't bother to return an error, we just clear the NEEDSWAP
00232        * bit.
00233        */
00234       if (m.magic == BTREEMAGIC)
00235          F_CLR(t, B_NEEDSWAP);
00236       else {
00237          F_SET(t, B_NEEDSWAP);
00238          M_32_SWAP(m.magic);
00239          M_32_SWAP(m.version);
00240          M_32_SWAP(m.psize);
00241          M_32_SWAP(m.free);
00242          M_32_SWAP(m.nrecs);
00243          M_32_SWAP(m.flags);
00244       }
00245       if (m.magic != BTREEMAGIC || m.version != BTREEVERSION)
00246          goto eftype;
00247       if (m.psize < MINPSIZE || m.psize > MAX_PAGE_OFFSET + 1 ||
00248           m.psize & (sizeof(indx_t) - 1))
00249          goto eftype;
00250       if (m.flags & ~SAVEMETA)
00251          goto eftype;
00252       b.psize = m.psize;
00253       F_SET(t, m.flags);
00254       t->bt_free = m.free;
00255       t->bt_nrecs = m.nrecs;
00256    } else {
00257       /*
00258        * Set the page size to the best value for I/O to this file.
00259        * Don't overflow the page offset type.
00260        */
00261       if (b.psize == 0) {
00262 #ifdef _STATBUF_ST_BLKSIZE
00263          b.psize = sb.st_blksize;
00264 #endif
00265          if (b.psize < MINPSIZE)
00266             b.psize = MINPSIZE;
00267          if (b.psize > MAX_PAGE_OFFSET + 1)
00268             b.psize = MAX_PAGE_OFFSET + 1;
00269       }
00270 
00271       /* Set flag if duplicates permitted. */
00272       if (!(b.flags & R_DUP))
00273          F_SET(t, B_NODUPS);
00274 
00275       t->bt_free = P_INVALID;
00276       t->bt_nrecs = 0;
00277       F_SET(t, B_METADIRTY);
00278    }
00279 
00280    t->bt_psize = b.psize;
00281 
00282    /* Set the cache size; must be a multiple of the page size. */
00283    if (b.cachesize && b.cachesize & (b.psize - 1))
00284       b.cachesize += (~b.cachesize & (b.psize - 1)) + 1;
00285    if (b.cachesize < b.psize * MINCACHE)
00286       b.cachesize = b.psize * MINCACHE;
00287 
00288    /* Calculate number of pages to cache. */
00289    ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize;
00290 
00291    /*
00292     * The btree data structure requires that at least two keys can fit on
00293     * a page, but other than that there's no fixed requirement.  The user
00294     * specified a minimum number per page, and we translated that into the
00295     * number of bytes a key/data pair can use before being placed on an
00296     * overflow page.  This calculation includes the page header, the size
00297     * of the index referencing the leaf item and the size of the leaf item
00298     * structure.  Also, don't let the user specify a minkeypage such that
00299     * a key/data pair won't fit even if both key and data are on overflow
00300     * pages.
00301     */
00302    t->bt_ovflsize = (t->bt_psize - BTDATAOFF) / b.minkeypage -
00303        (sizeof(indx_t) + NBLEAFDBT(0, 0));
00304    if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t))
00305       t->bt_ovflsize =
00306           NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t);
00307 
00308    /* Initialize the buffer pool. */
00309    if ((t->bt_mp =
00310        mpool_open(NULL, t->bt_fd, t->bt_psize, ncache)) == NULL)
00311       goto err;
00312    if (!F_ISSET(t, B_INMEM))
00313       mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t);
00314 
00315    /* Create a root page if new tree. */
00316    if (nroot(t) == RET_ERROR)
00317       goto err;
00318 
00319    /* Global flags. */
00320    if (dflags & DB_LOCK)
00321       F_SET(t, B_DB_LOCK);
00322    if (dflags & DB_SHMEM)
00323       F_SET(t, B_DB_SHMEM);
00324    if (dflags & DB_TXN)
00325       F_SET(t, B_DB_TXN);
00326 
00327    return (dbp);
00328 
00329 einval:  errno = EINVAL;
00330    goto err;
00331 
00332 eftype:  errno = EFTYPE;
00333    goto err;
00334 
00335 err:  if (t) {
00336       if (t->bt_dbp)
00337          free(t->bt_dbp);
00338       if (t->bt_fd != -1)
00339          (void)close(t->bt_fd);
00340       free(t);
00341    }
00342    return (NULL);
00343 }

static int nroot __P ( (BTREE *)   )  [static]

static int tmp __P ( (void)   )  [static]

static int byteorder (  )  [static]

Definition at line 421 of file bt_open.c.

References BIG_ENDIAN, and LITTLE_ENDIAN.

Referenced by __bt_open().

00422 {
00423    u_int32_t x;
00424    u_char *p;
00425 
00426    x = 0x01020304;
00427    p = (u_char *)&x;
00428    switch (*p) {
00429    case 1:
00430       return (BIG_ENDIAN);
00431    case 4:
00432       return (LITTLE_ENDIAN);
00433    default:
00434       return (0);
00435    }
00436 }

static int nroot ( BTREE t  )  [static]

Definition at line 355 of file bt_open.c.

References BTDATAOFF, errno, _page::flags, _page::lower, MPOOL_DIRTY, mpool_get, mpool_new, mpool_put, _page::nextpg, NULL, P_BLEAF, P_INVALID, P_ROOT, _page::pgno, _page::prevpg, RET_ERROR, RET_SUCCESS, and _page::upper.

Referenced by __bt_open().

00357 {
00358    PAGE *meta, *root;
00359    pgno_t npg;
00360 
00361    if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) {
00362       mpool_put(t->bt_mp, meta, 0);
00363       return (RET_SUCCESS);
00364    }
00365    if (errno != EINVAL)    /* It's OK to not exist. */
00366       return (RET_ERROR);
00367    errno = 0;
00368 
00369    if ((meta = mpool_new(t->bt_mp, &npg)) == NULL)
00370       return (RET_ERROR);
00371 
00372    if ((root = mpool_new(t->bt_mp, &npg)) == NULL)
00373       return (RET_ERROR);
00374 
00375    if (npg != P_ROOT)
00376       return (RET_ERROR);
00377    root->pgno = npg;
00378    root->prevpg = root->nextpg = P_INVALID;
00379    root->lower = BTDATAOFF;
00380    root->upper = t->bt_psize;
00381    root->flags = P_BLEAF;
00382    memset(meta, 0, t->bt_psize);
00383    mpool_put(t->bt_mp, meta, MPOOL_DIRTY);
00384    mpool_put(t->bt_mp, root, MPOOL_DIRTY);
00385    return (RET_SUCCESS);
00386 }

static int tmp (  )  [static]

Examples:
/tmp/asterisk-trunk/trunk/main/app.c.

Definition at line 389 of file bt_open.c.

References free, malloc, and NULL.

Referenced by __aco_option_register(), __ast_channel_alloc_ap(), __ast_channel_internal_alloc(), __ast_context_destroy(), __ast_format_def_register(), __ast_internal_context_destroy(), __ast_read(), __ast_register_translator(), __bt_open(), _build_port_config(), _macro_exec(), _parse(), _sip_tcp_helper_thread(), acf_curlopt_write(), acf_odbc_read(), acf_rand_exec(), action_originate(), add_date(), add_digit(), add_expires(), add_menu_entry(), add_rpid(), adpcmtolin_framein(), adsi_process(), aes_helper(), alsa_new(), alsa_request(), aMYSQL_set(), append_date(), append_event(), append_int(), ast_add_extension2_lockopt(), ast_app_group_split_group(), ast_append_acl(), ast_append_ha(), ast_ari_asterisk_get_global_var(), ast_bucket_alloc(), ast_bucket_file_alloc(), ast_callerid_parse(), ast_callerid_split(), ast_callid_threadstorage_auto(), ast_channel_get_manager_vars(), ast_cli_command_full(), ast_config_hook_unregister(), ast_config_option(), ast_context_find(), ast_context_find_or_create(), ast_dummy_channel_alloc(), ast_format_def_unregister(), ast_get_enum(), ast_get_hint(), ast_get_txt(), ast_hashtab_hash_string(), ast_hashtab_hash_string_nocase(), ast_iax2_new(), ast_jb_read_conf(), ast_loader_register(), ast_merge_contexts_and_delete(), ast_mkdir(), ast_mktime(), ast_monitor_stop(), ast_privacy_check(), ast_privacy_set(), ast_read_image(), ast_register_application2(), ast_register_switch(), ast_remotecontrol(), ast_sched_add_variable(), ast_sched_context_create(), ast_sip_create_dialog_uac(), ast_sip_create_rdata(), ast_sip_set_outbound_proxy(), ast_sorcery_changeset_create(), ast_sorcery_objectset_create2(), ast_sorcery_objectset_json_create(), ast_srtp_policy_alloc(), ast_str_encode_mime(), ast_str_get_hint(), ast_str_substring(), AST_TEST_DEFINE(), ast_unregister_translator(), ast_uri_decode(), ast_variables_dup(), auth_exec(), background_detect_exec(), bucket_file_wizard_retrieve(), bucket_wizard_retrieve(), build_contact(), build_extension(), build_peer(), build_radius_record(), build_rand_pad(), build_secret(), cache_lookup(), caldav_add_event(), calendar_join_attendees(), cdr_handler(), chanavail_exec(), channel_spy(), chanspy_exec(), check_peer_ok(), check_user_full(), check_via(), cli_fax_show_session(), cli_prompt(), common_exec(), complete_queue_remove_member(), conf_get_pin(), config_module(), console_dial(), console_transfer(), controlplayback_exec(), copy_all_header(), copy_header(), copy_rules(), copy_vars(), cpeid_setstatus(), create_client(), create_followme_number(), create_jb(), create_outgoing_sdp_stream(), create_queue_member(), custom_presence_callback(), dahdi_new(), dahdi_request(), data_add_codec(), dial_exec_full(), dialgroup_read(), disa_exec(), do_monitor(), do_pktccops(), dump_answer(), dump_ies(), dump_prov_ies(), dump_samprate(), dundi_do_lookup(), dundi_do_precache(), dundi_do_query(), dundi_ie_append_answer(), dundi_ie_append_cause(), dundi_ie_append_encdata(), dundi_ie_append_hint(), dundi_ie_append_raw(), dundi_lookup_local(), dundi_parse_ies(), dundi_reject(), dundi_showframe(), eivr_comm(), epoch_to_exchange_time(), extenspy_exec(), exts_compare(), fetch_response_reader(), find_by_mark(), find_channel(), find_queue_by_name_rt(), find_result(), find_subchannel_and_lock(), find_table(), function_enum(), g722tolin16_new(), g722tolin_framein(), g722tolin_new(), g726aal2tolin_framein(), g726tolin_framein(), generate_fmtp_attr(), generate_rtpmap_attr(), generator_force(), get_also_info(), get_destination(), get_multiple_fields_as_var_list(), get_name_from_variable(), get_rdnis(), get_rpid(), get_single_field_as_var_list(), get_token(), gr_say_number_female(), gsm_destroy_stuff(), gsm_new(), gsmtolin_framein(), handle_call_forward(), handle_characters(), handle_cli_check_permissions(), handle_cli_confbridge_show_bridge_profile(), handle_cli_database_get(), handle_cli_iax2_show_cache(), handle_cli_keys_init(), handle_minivm_show_users(), handle_request_info(), handle_select_option(), handle_setcallerid(), handle_speechrecognize(), hash_string(), hashkeys_read2(), heap_swap(), iax2_call(), iax2_datetime(), iax2_devicestate(), iax2_transfer(), iax2_trunk_queue(), iax_ie_append_raw(), iax_parse_ies(), iax_provision_build(), iax_provision_version(), iax_showframe(), iax_template_parse(), icalendar_add_event(), ilbctolin_framein(), ilbctolin_new(), init_acf_query(), init_phone_step2(), internal_format_cap_identical(), io_context_create(), io_grow(), jingle_add_ice_udp_candidates_to_transport(), jingle_add_payloads_to_description(), launch_script(), leave_voicemail(), lin16tog722_new(), lintoadpcm_framein(), lintoadpcm_frameout(), lintog722_framein(), lintog722_new(), lintog726_framein(), lintog726_new(), lintog726aal2_framein(), lintogsm_framein(), lintogsm_frameout(), lintoilbc_framein(), lintoilbc_frameout(), lintoilbc_new(), lintolpc10_framein(), lintolpc10_frameout(), lintospeex_framein(), lintospeex_frameout(), load_config(), load_module(), load_password(), load_users(), local_read(), loopback_subst(), lpc10_dec_new(), lpc10_enc_new(), lpc10tolin_framein(), lua_pbx_exec(), main(), manage_calls(), manager_action(), manager_dbget(), manager_login(), mgcp_devicestate(), mgcp_new(), mgcp_request(), mgcp_senddigit_end(), minivm_accmess_exec(), minivm_greet_exec(), minivm_mwi_exec(), minivm_notify_exec(), minivm_record_exec(), misdn_cfg_get_ports_string(), mixmonitor_save_prep(), mkif(), mkintf(), moh_files_write_format_change(), my_load_config_number(), my_load_config_string(), nbs_new(), nbs_request(), new_iax(), normalise_history(), odbc_load_module(), odbc_log(), ogg_vorbis_rewrite(), ooh323_request(), open_history(), optimize_transactions(), osp_create_uuid(), osp_get_varfloat(), osp_get_varint(), osp_lookup(), osp_report_qos(), ospauth_exec(), ospfinished_exec(), osplookup_exec(), ospnext_exec(), outbound_proxy_validate(), P2(), page_exec(), parse_hint_device(), parse_hint_presence(), parse_tag(), pbx_builtin_importvar(), pbx_builtin_saynumber(), pbx_extension_helper(), pbx_find_extension(), pbx_load_users(), peer_set_srcaddr(), phone_new(), phone_request(), phoneprov_callback(), playback_exec(), pp_each_user_helper(), presence_write(), process_my_load_module(), process_sdp_a_audio(), prov_ver_calc(), pw_cb(), rcv_mac_addr(), read_config_maps(), read_exec(), realtime_directory(), realtime_ldap_base_ap(), realtime_ldap_result_to_vars(), realtime_peer(), realtime_peer_by_name(), realtime_user(), rebuild_channels(), record_exec(), register_verify(), reload_config(), reload_followme(), reload_single_member(), reply_digest(), reqprep(), request(), rxqcheck(), save_secret(), sched_alloc(), send_eivr_event(), send_raw_client(), send_request(), send_response(), sendmail(), sendurl_exec(), set_config(), show_phone_number(), sip_devicestate(), sip_dialog_create_contact(), sip_dialog_create_from(), sip_new(), sip_outbound_publish_client_alloc(), sip_outbound_registration_regc_alloc(), sip_prune_realtime(), sip_request_call(), sip_tcptls_write(), skel_exec(), smb_pitch_shift(), socket_receive_file_to_buff(), softmix_mixing_array_grow(), sorcery_config_open(), sort_items(), speech_background(), speech_read(), speech_score(), speex_decoder_construct(), speex_encoder_construct(), speextolin_framein(), sqlite3_escape_column_op(), sqlite3_escape_string_helper(), start_monitor_exec(), start_resource(), StateConstructW(), StateSearchW(), store_tone_zone_ring_cadence(), term_alloc(), time1(), time2(), time2sub(), to_string(), transfer_redirect(), transfer_refer(), transmit_connect(), transmit_connect_with_sdp(), transmit_modify_request(), transmit_modify_with_sdp(), transmit_notify_with_sipfrag(), transmit_register(), transmit_response_with_auth(), transmit_response_with_minexpires(), transmit_state_notify(), try_calling(), try_redirect(), unistim_line_copy(), unistim_new(), unistim_request(), unistim_sendtext(), unistim_sp(), unistimsock_read(), uri_parse_and_default(), ustmtext(), vm_change_password(), vq(), wav_open(), wav_read(), wav_rewrite(), wav_write(), while_continue_exec(), write_history(), writefile(), and xml_encode_str().

00390 {
00391    sigset_t set, oset;
00392    int fd;
00393    const char *envtmp;
00394    char *path;
00395    static const char fmt[] = "%s/bt.XXXXXX";
00396    size_t n;
00397 
00398    envtmp = getenv("TMPDIR");
00399    if (!envtmp)
00400      envtmp = "/tmp";
00401    n = strlen (envtmp) + sizeof fmt;
00402 #ifdef   __GNUC__
00403    path = __builtin_alloca(n);
00404 #else
00405    path = malloc(n);
00406 #endif
00407    (void)snprintf(path, n, fmt, envtmp ? envtmp : "/tmp");
00408 
00409    (void)sigfillset(&set);
00410    (void)sigprocmask(SIG_BLOCK, &set, &oset);
00411    if ((fd = mkstemp(path)) != -1)
00412       (void)unlink(path);
00413    (void)sigprocmask(SIG_SETMASK, &oset, NULL);
00414 #ifndef  __GNUC__
00415    free(path);
00416 #endif
00417    return(fd);
00418 }


Generated on Thu Apr 16 06:29:15 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6