Example #1
0
static int _mount(vfs_mount_t *mountp)
{
    /* if one of the lines below fail to compile you probably need to adjust
       vfs buffer sizes ;) */
    BUILD_BUG_ON(VFS_DIR_BUFFER_SIZE < sizeof(DIR));
    BUILD_BUG_ON(VFS_FILE_BUFFER_SIZE < sizeof(fatfs_file_desc_t));

    fatfs_desc_t *fs_desc = (fatfs_desc_t *)mountp->private_data;

    char volume_str[FATFS_MAX_VOL_STR_LEN];
    snprintf(volume_str, sizeof(volume_str), "%d:/", fs_desc->vol_idx);

    memset(&fs_desc->fat_fs, 0, sizeof(fs_desc->fat_fs));

    DEBUG("mounting file system of volume '%s'\n", volume_str);
    FRESULT res = f_mount(&fs_desc->fat_fs, volume_str, 1);

    if (res == FR_OK) {
        DEBUG("[OK]");
    }
    else {
        DEBUG("[ERROR]");
    }

    return fatfs_err_to_errno(res);
}
void printSolution(char* program, char* input, Solution solution, Node **nodeArray)
{
    ofstream resultFile;
    string programName = trimDirectory(program);
    string inputName = trimDirectory(input);
    // stringstream fileName;
    // fileName << "" << programName << "_" << inputName << "_out";
    // DEBUG("Outputting to file %s.", fileName.str());
    // resultFile.open(fileName.str().c_str());
    char fileName[512];
    sprintf(fileName, "%s_%s_out", programName.c_str(), inputName.c_str());
    resultFile.open(fileName);

    pthread_mutex_lock(&done_mutex);
    if (solution == SOLVEABLE)
    {
        cout << "true" << endl;
        resultFile << "true" << endl;
        for (unsigned int cntr = 0; cntr < g_count; cntr++)
        {
            cout << nodeArray[cntr]->getName() << ": " << fixColor(colorSolution[cntr]) << "\n";
            resultFile << nodeArray[cntr]->getName() << ": " << fixColor(colorSolution[cntr]) << "\n";
        }
    }
    else
    {
        cout << "false" << endl;
        resultFile << "false" << endl;
        DEBUG("Solution is set to %d.", solution);
    }
    pthread_mutex_unlock(&done_mutex);
    resultFile.close();
    DEBUG("Done");
}
Example #3
0
/**
 * lh7a40x_in_epn - handle IN interrupt
 */
static void lh7a40x_in_epn(struct lh7a40x_udc *dev, u32 ep_idx, u32 intr)
{
	u32 csr;
	struct lh7a40x_ep *ep = &dev->ep[ep_idx];
	struct lh7a40x_request *req;

	usb_set_index(ep_idx);

	csr = usb_read(ep->csr1);
	DEBUG("%s: %d, csr %x\n", __FUNCTION__, ep_idx, csr);

	if (csr & USB_IN_CSR1_SENT_STALL) {
		DEBUG("USB_IN_CSR1_SENT_STALL\n");
		usb_set(USB_IN_CSR1_SENT_STALL /*|USB_IN_CSR1_SEND_STALL */ ,
			ep->csr1);
		return;
	}

	if (!ep->desc) {
		DEBUG("%s: NO EP DESC\n", __FUNCTION__);
		return;
	}

	if (list_empty(&ep->queue))
		req = 0;
	else
		req = list_entry(ep->queue.next, struct lh7a40x_request, queue);

	DEBUG("req: %p\n", req);

	if (!req)
		return;

	write_fifo(ep, req);
}
Example #4
0
/* pxa_pcmcia_task_handler()
 * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 * Processes serviceable socket events using the "eventd" thread context.
 *
 * Event processing (specifically, the invocation of the Card Services event
 * callback) occurs in this thread rather than in the actual interrupt
 * handler due to the use of scheduling operations in the PCMCIA core.
 */
static void pxa_pcmcia_task_handler(void *data) {
  struct pcmcia_state state[PXA_PCMCIA_MAX_SOCK];
  struct pcmcia_state_array state_array;
  int i, events, all_events, irq_status;

  DEBUG(2, "%s(): entering PCMCIA monitoring thread\n", __FUNCTION__);

  state_array.size=pxa_pcmcia_socket_count;
  state_array.state=state;

  do {

    DEBUG(3, "%s(): interrogating low-level PCMCIA service\n", __FUNCTION__);

    if((irq_status=pcmcia_low_level->socket_state(&state_array))<0)
      printk(KERN_ERR "Error in kernel low-level PCMCIA service.\n");

    all_events=0;

    if(irq_status>0){

      for(i=0; i<state_array.size; ++i, all_events|=events)
	if((events=
	    pxa_pcmcia_events(&state[i],
				 &pxa_pcmcia_socket[i].k_state,
				 pxa_pcmcia_socket[i].cs_state.csc_mask,
				 pxa_pcmcia_socket[i].cs_state.flags)))
	  if(pxa_pcmcia_socket[i].handler!=NULL)
	    pxa_pcmcia_socket[i].handler(pxa_pcmcia_socket[i].handler_info,
					    events);
    }

  } while(all_events);
}  /* pxa_pcmcia_task_handler() */
Example #5
0
NTSTATUS idmap_sid_to_uid(DOM_SID *sid, uid_t *uid)
{
    NTSTATUS ret;
    struct id_map map;
    struct id_map *maps[2];

    DEBUG(10,("idmap_sid_to_uid: sid = [%s]\n", sid_string_dbg(sid)));

    map.sid = sid;
    map.xid.type = ID_TYPE_UID;

    maps[0] = &map;
    maps[1] = NULL;

    ret = idmap_sids_to_unixids(maps);
    if ( ! NT_STATUS_IS_OK(ret)) {
        DEBUG(10, ("error mapping sid [%s] to uid\n",
                   sid_string_dbg(sid)));
        return ret;
    }

    if ((map.status != ID_MAPPED) || (map.xid.type != ID_TYPE_UID)) {
        DEBUG(10, ("sid [%s] not mapped to an uid [%u,%u,%u]\n",
                   sid_string_dbg(sid),
                   map.status,
                   map.xid.type,
                   map.xid.id));
        return NT_STATUS_NONE_MAPPED;
    }

    *uid = map.xid.id;

    return NT_STATUS_OK;
}
Example #6
0
struct sss_domain_info *
find_domain_by_object_name(struct sss_domain_info *domain,
                           const char *object_name)
{
    TALLOC_CTX *tmp_ctx;
    struct sss_domain_info *dom = NULL;
    char *domainname = NULL;
    errno_t ret;

    tmp_ctx = talloc_new(NULL);
    if (tmp_ctx == NULL) {
        DEBUG(SSSDBG_CRIT_FAILURE, "talloc_new() failed\n");
        return NULL;
    }

    ret = sss_parse_name(tmp_ctx, domain->names, object_name,
                         &domainname, NULL);
    if (ret != EOK) {
        DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse name '%s' [%d]: %s\n",
                                    object_name, ret, sss_strerror(ret));
        goto done;
    }

    if (domainname == NULL) {
        dom = domain;
    } else {
        dom = find_domain_by_name(domain, domainname, true);
    }

done:
    talloc_free(tmp_ctx);
    return dom;
}
static void
identity_state_changed_cb (GDBusProxy *proxy,
                           gint state,
                           gpointer user_data)
{
    g_return_if_fail (SIGNON_IS_IDENTITY (user_data));
    SignonIdentity *self = SIGNON_IDENTITY (user_data);

    switch (state) {
        case DATA_UPDATED:
            DEBUG ("State changed to DATA_UPDATED");
            identity_process_updated (self);
            break;
        case IDENTITY_REMOVED:
            DEBUG ("State changed to IDENTITY_REMOVED");
            identity_process_removed (self);
            break;
        case IDENTITY_SIGNED_OUT:
            DEBUG ("State changed to IDENTITY_SIGNED_OUT");
            identity_process_signout (self);
            break;
        default:
            g_critical ("wrong state value obtained from signon daemon");
    };
}
Example #8
0
STATIC
EFI_STATUS
EFIAPI
EmmcGetDeviceState (
  IN  MMC_HOST_INSTANCE    *MmcHostInstance,
  OUT EMMC_DEVICE_STATE    *State
  )
{
  EFI_MMC_HOST_PROTOCOL *Host;
  EFI_STATUS Status;
  UINT32     Data, RCA;

  if (State == NULL) {
    return EFI_INVALID_PARAMETER;
  }

  Host = MmcHostInstance->MmcHost;
  RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
  Status = Host->SendCommand (Host, MMC_CMD13, RCA);
  if (EFI_ERROR (Status)) {
    DEBUG ((EFI_D_ERROR, "EmmcGetDeviceState(): Failed to get card status, Status=%r.\n", Status));
    return Status;
  }
  Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R1, &Data);
  if (EFI_ERROR (Status)) {
    DEBUG ((EFI_D_ERROR, "EmmcGetDeviceState(): Failed to get response of CMD13, Status=%r.\n", Status));
    return Status;
  }
  if (Data & EMMC_SWITCH_ERROR) {
    DEBUG ((EFI_D_ERROR, "EmmcGetDeviceState(): Failed to switch expected mode, Status=%r.\n", Status));
    return EFI_DEVICE_ERROR;
  }
  *State = DEVICE_STATE(Data);
  return EFI_SUCCESS;
}
Example #9
0
string Basename::new_basename() const {
    stringstream result;
    std::auto_ptr<stringstream> varname;
    enum State { Free, InVariable };

    DEBUG("Expanding " << basename());

    State s = Free;
    for (size_t i = 0; i < basename().size(); i++)
    {
        const char c = basename()[i];
        if ( c != '$' )
            ( (s == Free) ? result : *varname ) << c;
        else if ( s == Free ) {
            s = InVariable;
            varname.reset( new std::stringstream() );
        } else {
            string var = varname->str();
            ReplaceMap::const_iterator j = replacements.find(var);
            
            if ( j == replacements.end() ) {
                throw runtime_error("Undefined variable '" + var + "'");
            } else
                result << j->second;
            s = Free;
        }
    }

    DEBUG("Expanded " << basename() << " to " << result.str());
    return result.str();
}
Example #10
0
/**********************************************************************
 Register with the idmap and idmap_nss subsystems. We have to protect
 against the idmap and nss_info interfaces being in a half-registered
 state.
 **********************************************************************/
NTSTATUS samba_module_init(void)
{
	static NTSTATUS idmap_status = NT_STATUS_UNSUCCESSFUL;
	static NTSTATUS nss_status = NT_STATUS_UNSUCCESSFUL;
	if (!NT_STATUS_IS_OK(idmap_status)) {
		idmap_status =
		    smb_register_idmap(SMB_IDMAP_INTERFACE_VERSION,
				       "adex", &adex_idmap_methods);
		if (!NT_STATUS_IS_OK(idmap_status)) {
			DEBUG(0,
			      ("idmap_centeris_init: Failed to register the adex"
			       "idmap plugin.\n"));
			return idmap_status;
		}
	}

	if (!NT_STATUS_IS_OK(nss_status)) {
		nss_status =
		    smb_register_idmap_nss(SMB_NSS_INFO_INTERFACE_VERSION,
					   "adex", &adex_nss_methods);
		if (!NT_STATUS_IS_OK(nss_status)) {
			DEBUG(0,
			      ("idmap_adex_init: Failed to register the adex"
			       "nss plugin.\n"));
			return nss_status;
		}
	}

	return NT_STATUS_OK;
}
Example #11
0
STATIC
EFI_STATUS
EFIAPI
EmmcSetEXTCSD (
  IN MMC_HOST_INSTANCE     *MmcHostInstance,
  UINT32                   ExtCmdIndex,
  UINT32                   Value
  )
{
  EFI_MMC_HOST_PROTOCOL *Host;
  EMMC_DEVICE_STATE     State;
  EFI_STATUS Status;
  UINT32     Argument;

  Host  = MmcHostInstance->MmcHost;
  Argument = EMMC_CMD6_ARG_ACCESS(3) | EMMC_CMD6_ARG_INDEX(ExtCmdIndex) |
             EMMC_CMD6_ARG_VALUE(Value) | EMMC_CMD6_ARG_CMD_SET(1);
  Status = Host->SendCommand (Host, MMC_CMD6, Argument);
  if (EFI_ERROR (Status)) {
    DEBUG ((EFI_D_ERROR, "EmmcSetEXTCSD(): Failed to send CMD6, Status=%r.\n", Status));
    return Status;
  }
  // Make sure device exiting prog mode
  do {
    Status = EmmcGetDeviceState (MmcHostInstance, &State);
    if (EFI_ERROR (Status)) {
      DEBUG ((EFI_D_ERROR, "EmmcSetEXTCSD(): Failed to get device state, Status=%r.\n", Status));
      return Status;
    }
  } while (State == EMMC_PRG_STATE);
  return EFI_SUCCESS;
}
Decode_Status VaapiDecoderVP8::start(VideoConfigBuffer * buffer)
{
    DEBUG("VP8: start() buffer size: %d x %d", buffer->width,
          buffer->height);
    Decode_Status status;

    if ((buffer->flag & HAS_SURFACE_NUMBER)
        && (buffer->flag & HAS_VA_PROFILE)) {
    }

    buffer->profile = VAProfileVP8Version0_3;
    buffer->surfaceNumber = 3 + VP8_EXTRA_SURFACE_NUMBER;

    vp8_parse_init_default_multi_frame_data(&m_lastFrameContext);

    DEBUG("disable native graphics buffer");
    buffer->flag &= ~USE_NATIVE_GRAPHIC_BUFFER;
    m_configBuffer = *buffer;
    m_configBuffer.data = NULL;
    m_configBuffer.size = 0;

    // it is a good timing to report resolution change (gst-omx does), however, it fails on chromeos
    // so we force to update resolution on first key frame
    m_configBuffer.width = 0;
    m_configBuffer.height = 0;

    return DECODE_SUCCESS;
}
Example #13
0
static void _send(ng_pktsnip_t *pkt)
{
    ng_udp_hdr_t *hdr;
    ng_pktsnip_t *udp_snip;
    ng_netreg_entry_t *sendto;

    /* get udp snip and hdr */
    LL_SEARCH_SCALAR(pkt, udp_snip, type, NG_NETTYPE_UDP);
    udp_snip = ng_pktbuf_start_write(udp_snip);
    if (udp_snip == NULL) {
        DEBUG("udp: cannot send packet: unable to allocate packet\n");
        ng_pktbuf_release(pkt);
        return;
    }
    hdr = (ng_udp_hdr_t *)udp_snip->data;
    /* fill in size field */
    hdr->length = byteorder_htons(ng_pkt_len(udp_snip));

    /* and forward packet to the network layer */
    sendto = ng_netreg_lookup(pkt->type, NG_NETREG_DEMUX_CTX_ALL);
    /* throw away packet if no one is interested */
    if (sendto == NULL) {
        DEBUG("udp: cannot send packet: network layer not found\n");
        ng_pktbuf_release(pkt);
        return;
    }
    /* send packet to network layer */
    ng_pktbuf_hold(pkt, ng_netreg_num(pkt->type, NG_NETREG_DEMUX_CTX_ALL) - 1);
    while (sendto != NULL) {
        ng_netapi_send(sendto->pid, pkt);
        sendto = ng_netreg_getnext(sendto);
    }
}
Example #14
0
void	AI_AStar::__AppendChildren(Node* n)
{
	int		vX;
	int		vY;

	vY = -1;
	DEBUG("n("<< n->x <<";"<< n->y <<")<" << n->f <<
		" = " << n->g << " + " << n->h <<
		"\n")
	while (vY <= 1)
	{
		vX = -1;
		while (vX <= 1)
		{
			if (vY == 0 && vX == 0)
			{
				DEBUG("		")
				vX = 1;
			}
			if (n->x + vX >= 0 &&
			    n->x + vX < this->map->w &&
			    n->y + vY >= 0 &&
			    n->y + vY < this->map->h &&
			    this->__CheckDiag(n, vX, vY) &&
			    this->unit->GetMoveHandler()->CanMove(n->x + vX, n->y + vY))
			{
				this->__AddNode(n, n->x + vX, n->y + vY);
				++this->n;
				DEBUG("		")
			}
			else
				DEBUG("X		")
			++vX;
		}
Example #15
0
void msg_close_file(struct messaging_context *msg_ctx,
			void *private_data,
			uint32_t msg_type,
			struct server_id server_id,
			DATA_BLOB *data)
{
	files_struct *fsp = NULL;
	struct share_mode_entry e;
	struct smbd_server_connection *sconn =
		talloc_get_type_abort(private_data,
		struct smbd_server_connection);

	message_to_share_mode_entry(&e, (char *)data->data);

	if(DEBUGLVL(10)) {
		char *sm_str = share_mode_str(NULL, 0, &e);
		if (!sm_str) {
			smb_panic("talloc failed");
		}
		DEBUG(10,("msg_close_file: got request to close share mode "
			"entry %s\n", sm_str));
		TALLOC_FREE(sm_str);
	}

	fsp = file_find_dif(sconn, e.id, e.share_file_id);
	if (!fsp) {
		DEBUG(10,("msg_close_file: failed to find file.\n"));
		return;
	}
	close_file(NULL, fsp, NORMAL_CLOSE);
}
Example #16
0
static void
log_window_calendar_chats_month_changed_cb (GtkWidget       *calendar,
					    EmpathyLogWindow *window)
{
	EmpathyAccount     *account;
	gchar         *chat_id;
	gboolean       is_chatroom;
	guint          year_selected;
	guint          month_selected;

	GList         *dates;
	GList         *l;

	gtk_calendar_clear_marks (GTK_CALENDAR (calendar));

	if (!log_window_chats_get_selected (window, &account,
					    &chat_id, &is_chatroom)) {
		DEBUG ("No chat selected to get dates for...");
		return;
	}

	g_object_get (calendar,
		      "month", &month_selected,
		      "year", &year_selected,
		      NULL);

	/* We need this hear because it appears that the months start from 0 */
	month_selected++;

	/* Get the log object for this contact */
	dates = empathy_log_manager_get_dates (window->log_manager, account,
					       chat_id, is_chatroom);
	g_object_unref (account);
	g_free (chat_id);

	for (l = dates; l; l = l->next) {
		const gchar *str;
		guint        year;
		guint        month;
		guint        day;

		str = l->data;
		if (!str) {
			continue;
		}

		sscanf (str, "%4d%2d%2d", &year, &month, &day);

		if (year == year_selected && month == month_selected) {
			DEBUG ("Marking date:'%s'", str);
			gtk_calendar_mark_day (GTK_CALENDAR (window->calendar_chats), day);
		}
	}

	g_list_foreach (dates, (GFunc) g_free, NULL);
	g_list_free (dates);

	DEBUG ("Currently showing month %d and year %d", month_selected,
		year_selected);
}
Example #17
0
static int
fetch_domains(virConnectPtr conn)
{
    int num_domains, ret = -1;
    virDomainPtr *domains = NULL;
    ssize_t i;
    const int list_flags = VIR_CONNECT_LIST_DOMAINS_ACTIVE;

    DEBUG("Fetching list of running domains");
    num_domains = virConnectListAllDomains(conn, &domains, list_flags);

    DEBUG("num_domains=%d", num_domains);
    if (num_domains < 0) {
        ERROR("Unable to fetch list of running domains");
        goto cleanup;
    }

    printf("Running domains:\n");
    printf("----------------\n");
    for (i = 0; i < num_domains; i++) {
        virDomainPtr dom = domains[i];
        const char *dom_name = virDomainGetName(dom);
        printf("%s\n", dom_name);
        virDomainFree(dom);
    }

    ret = 0;
 cleanup:
    free(domains);
    return ret;
}
Example #18
0
/**
  FSP Init continuation function.
  Control will be returned to this callback function after FspInit API call.

  @param[in] Status      Status of the FSP INIT API
  @param[in] HobListPtr  Pointer to the HOB data structure defined in the PI specification.

**/
VOID
ContinuationFunc (
  IN EFI_STATUS Status,
  IN VOID       *HobListPtr
  )
{
  EFI_BOOT_MODE             BootMode;
  UINT64                    StackSize;
  EFI_PHYSICAL_ADDRESS      StackBase;

  DEBUG ((DEBUG_INFO, "ContinuationFunc - %r\n", Status));
  DEBUG ((DEBUG_INFO, "HobListPtr - 0x%x\n", HobListPtr));

  if (Status != EFI_SUCCESS) {
    CpuDeadLoop ();
  }

  //
  // Can not call any PeiServices
  //
  BootMode = GetBootMode ();

  GetStackInfo (BootMode, TRUE, &StackBase, &StackSize);
  DEBUG ((DEBUG_INFO, "StackBase - 0x%x\n", StackBase));
  DEBUG ((DEBUG_INFO, "StackSize - 0x%x\n", StackSize));
  CallPeiCoreEntryPoint (
    HobListPtr,
    (VOID *)(UINTN)StackBase,
    (VOID *)(UINTN)(StackBase + StackSize)
    );
}
Example #19
0
errno_t sssd_domain_init(TALLOC_CTX *mem_ctx,
                         struct confdb_ctx *cdb,
                         const char *domain_name,
                         const char *db_path,
                         struct sss_domain_info **_domain)
{
    int ret;
    struct sss_domain_info *dom;
    struct sysdb_ctx *sysdb;

    ret = confdb_get_domain(cdb, domain_name, &dom);
    if (ret != EOK) {
        DEBUG(SSSDBG_OP_FAILURE, "Error retrieving domain configuration.\n");
        return ret;
    }

    if (dom->sysdb != NULL) {
        DEBUG(SSSDBG_OP_FAILURE, "Sysdb context already initialized.\n");
        return EEXIST;
    }

    ret = sysdb_domain_init(mem_ctx, dom, db_path, &sysdb);
    if (ret != EOK) {
        DEBUG(SSSDBG_OP_FAILURE, "Error opening cache database.\n");
        return ret;
    }

    dom->sysdb = talloc_steal(dom, sysdb);

    *_domain = dom;

    return EOK;
}
Example #20
0
static int sc_hdlr_open(void *_p){
	char path[((sc_fs_t*)(_p))->data_len];
	sc_fs_t *p;
	fs_node_t *root;
	process_t *this_p;


	this_p = sched_running()->parent;

	/* initials */
	p = (sc_fs_t*)_p;
	copy_from_user(path, p->data, p->data_len, this_p);

	/* identify file system and call its open callback */
	mutex_lock(&this_p->mtx);
	root = (path[0] == '/') ? (fs_root) : this_p->cwd;
	mutex_unlock(&this_p->mtx);

	if(root->ops->open == 0x0)
		return_errno(E_NOIMP);

	DEBUG("path \"%s\", mode %#x\n", path, p->mode);

	fs_lock();
	p->fd = root->ops->open(root, path, p->mode, this_p);
	fs_unlock();

	DEBUG("created fd with id %d, \"%s\"\n", p->fd, strerror(errno));

	return E_OK;
}
Example #21
0
void task_powerdown_init()
{
	//Lower F_CPU
	ClockSetSource(x2MHz);
	//disable other oscilators
	OSC.CTRL = 0b00000001;

	buttons_deinit();

	uart_stop();
	_delay_ms(10);

	turnoff_subsystems();

	uart_low_speed();
	_delay_ms(10);

	DEBUG(" *** POWER DOWN INIT ***\n");

	test_memory();

	//we do not want to enter sleep
	powerdown_loop_break = false;
	powerdown_lock.Lock();

	task_timer_setup(false);

	SD_EN_OFF;

	DEBUG("Using low speed uart\n");
}
Example #22
0
/* TODO: check if this can be made generic for all responders */
static void pac_dp_reconnect_init(struct sbus_connection *conn,
                                  int status, void *pvt)
{
    struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn);
    int ret;

    /* Did we reconnect successfully? */
    if (status == SBUS_RECONNECT_SUCCESS) {
        DEBUG(SSSDBG_OP_FAILURE, "Reconnected to the Data Provider.\n");

        /* Identify ourselves to the data provider */
        ret = rdp_register_client(be_conn, "PAC");
        /* all fine */
        if (ret == EOK) {
            handle_requests_after_reconnect(be_conn->rctx);
            return;
        }
    }

    /* Failed to reconnect */
    DEBUG(SSSDBG_FATAL_FAILURE, "Could not reconnect to %s provider.\n",
              be_conn->domain->name);

    /* FIXME: kill the frontend and let the monitor restart it ? */
    /* nss_shutdown(rctx); */
}
Example #23
0
NTSTATUS idmap_gid_to_sid(DOM_SID *sid, gid_t gid)
{
    NTSTATUS ret;
    struct id_map map;
    struct id_map *maps[2];

    DEBUG(10,("gid = [%lu]\n", (unsigned long)gid));

    map.sid = sid;
    map.xid.type = ID_TYPE_GID;
    map.xid.id = gid;

    maps[0] = &map;
    maps[1] = NULL;

    ret = idmap_unixids_to_sids(maps);
    if ( ! NT_STATUS_IS_OK(ret)) {
        DEBUG(10, ("error mapping gid [%lu]\n", (unsigned long)gid));
        return ret;
    }

    if (map.status != ID_MAPPED) {
        DEBUG(10, ("gid [%lu] not mapped\n", (unsigned long)gid));
        return NT_STATUS_NONE_MAPPED;
    }

    return NT_STATUS_OK;
}
Example #24
0
static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
{
	MD5_CTX ctx;
        unsigned char hash[16];
	SMB_INO_T result;
	char *upper_sname;

	DEBUG(10, ("stream_inode called for %lu/%lu [%s]\n",
		   (unsigned long)sbuf->st_ex_dev,
		   (unsigned long)sbuf->st_ex_ino, sname));

	upper_sname = talloc_strdup_upper(talloc_tos(), sname);
	SMB_ASSERT(upper_sname != NULL);

        MD5Init(&ctx);
        MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_dev),
		  sizeof(sbuf->st_ex_dev));
        MD5Update(&ctx, (const unsigned char *)&(sbuf->st_ex_ino),
		  sizeof(sbuf->st_ex_ino));
        MD5Update(&ctx, (unsigned char *)upper_sname,
		  talloc_get_size(upper_sname)-1);
        MD5Final(hash, &ctx);

	TALLOC_FREE(upper_sname);

        /* Hopefully all the variation is in the lower 4 (or 8) bytes! */
	memcpy(&result, hash, sizeof(result));

	DEBUG(10, ("stream_inode returns %lu\n", (unsigned long)result));

	return result;
}
int getOptionsForColor(Color color)
{
    switch(color)
    {
    case UNKNOWN:
        return 3;
    case RED:
    case GREEN:
    case BLUE:
        return 1;
    case NOT_RED:
    case NOT_GREEN:
    case NOT_BLUE:
        return 2;
    case NOT_RED_OR_GREEN:
    case NOT_RED_OR_BLUE:
    case NOT_GREEN_OR_BLUE:
        return 1;
    case IMPOSSIBLE:
        DEBUG("Got an impossible coloring in getOptionsForColor");
        throw colorex;
    default:
        DEBUG("Got an unknown coloring in getOptionsForColor");
        throw colorex;
    }
}
Example #26
0
/****************************************************************************
 prints a struct security_token to debug output.
****************************************************************************/
void security_token_debug(int dbg_lev, const struct security_token *token)
{
	TALLOC_CTX *mem_ctx;
	int i;

	if (!token) {
		DEBUG(dbg_lev, ("Security token: (NULL)\n"));
		return;
	}

	mem_ctx = talloc_init("security_token_debug()");
	if (!mem_ctx) {
		return;
	}

	DEBUG(dbg_lev, ("Security token of user %s\n",
				    dom_sid_string(mem_ctx, token->user_sid) ));
	DEBUGADD(dbg_lev, (" SIDs (%lu):\n", 
				       (unsigned long)token->num_sids));
	for (i = 0; i < token->num_sids; i++) {
		DEBUGADD(dbg_lev, ("  SID[%3lu]: %s\n", (unsigned long)i, 
			   dom_sid_string(mem_ctx, token->sids[i])));
	}

	security_token_debug_privileges(dbg_lev, token);

	talloc_free(mem_ctx);
}
Example #27
0
/*
 *	done - retire a request; caller blocked irqs
 *  INDEX register is preserved to keep same
 */
static void done(struct lh7a40x_ep *ep, struct lh7a40x_request *req, int status)
{
	unsigned int stopped = ep->stopped;
	u32 index;

	DEBUG("%s, %p\n", __FUNCTION__, ep);
	list_del_init(&req->queue);

	if (likely(req->req.status == -EINPROGRESS))
		req->req.status = status;
	else
		status = req->req.status;

	if (status && status != -ESHUTDOWN)
		DEBUG("complete %s req %p stat %d len %u/%u\n",
		      ep->ep.name, &req->req, status,
		      req->req.actual, req->req.length);

	/* don't modify queue heads during completion callback */
	ep->stopped = 1;
	/* Read current index (completion may modify it) */
	index = usb_read(USB_INDEX);

	spin_unlock(&ep->dev->lock);
	req->req.complete(&ep->ep, &req->req);
	spin_lock(&ep->dev->lock);

	/* Restore index */
	usb_set_index(index);
	ep->stopped = stopped;
}
Example #28
0
File: utf8.c Project: Exim/exim
uschar *
string_address_utf8_to_alabel(const uschar * utf8, uschar ** err)
{
uschar * l, * d;

if (!*utf8) return string_copy(utf8);

DEBUG(D_expand) debug_printf("addr from utf8 <%s>", utf8);

for (const uschar * s = utf8; *s; s++)
  if (*s == '@')
    {
    l = string_copyn(utf8, s - utf8);
    if (  !(l = string_localpart_utf8_to_alabel(l, err))
       || !(d = string_domain_utf8_to_alabel(++s, err))
       )
      return NULL;
    l = string_sprintf("%s@%s", l, d);
    DEBUG(D_expand) debug_printf(" -> <%s>\n", l);
    return l;
    }

l =  string_localpart_utf8_to_alabel(utf8, err);
DEBUG(D_expand) debug_printf(" -> <%s>\n", l);
return l;
}
Example #29
0
NTSTATUS printer_list_get_last_refresh(time_t *last_refresh)
{
    struct db_context *db;
    TDB_DATA data;
    uint32_t time_h, time_l;
    NTSTATUS status;
    int ret;

    db = get_printer_list_db();
    if (db == NULL) {
        return NT_STATUS_INTERNAL_DB_CORRUPTION;
    }

    ZERO_STRUCT(data);

    status = dbwrap_fetch_bystring(db, talloc_tos(), PL_TIMESTAMP_KEY, &data);
    if (!NT_STATUS_IS_OK(status)) {
        DEBUG(1, ("Failed to fetch record!\n"));
        goto done;
    }

    ret = tdb_unpack(data.dptr, data.dsize,
                     PL_TSTAMP_FORMAT, &time_h, &time_l);
    if (ret == -1) {
        DEBUG(1, ("Failed to un pack printer data"));
        status = NT_STATUS_INTERNAL_DB_CORRUPTION;
        goto done;
    }

    *last_refresh = (time_t)(((uint64_t)time_h << 32) + time_l);
    status = NT_STATUS_OK;

done:
    return status;
}
/*
 *	Thread function
 *		Each thread on the pool will be running this function since creation
 *		The idea is that each one of them will be waiting for some job to be
 *		added to the queue. When that happens, one of them will acquire the job
 *		and execute it
 */
static void* thread_func(void *args) {
	thread_pool_t* pool =(thread_pool_t*) args;

	while(1) {
		pthread_mutex_lock(&pool->mutex);
		while(pool->queue.length == 0) {
			DEBUG("Wating for jobs...");
			pthread_cond_wait(&pool->has_jobs, &pool->mutex);
		}
		pool->n_threads_working++;
		DEBUG("Got a Job!");

		job_t* job = next_job(&pool->queue);
		if(job == NULL)
			continue;

		pthread_mutex_unlock(&pool->mutex);
		job->func(job->arg);

		pthread_mutex_lock(&pool->mutex);
		pool->n_threads_working--;
		pthread_mutex_unlock(&pool->mutex);
	}

	return NULL;
}