Esempio n. 1
0
/*
 * sbs_split_bio - Create bio1 and bio2, then modify field bi_io_vec in bio1 and bio2,
 * according to the same field in bio.
 */
static void sbs_split_bio(struct bio *bio, struct bio ** bio1, struct bio ** bio2)
{
//	int first_half_bytes = (nsectors - bio->bi_sector - shift_sector_num) * hardsect_size;
	int first_half_bytes = hardsect_size;
	/* used to save the split position */
	int split_page = 0, split_offset = 0;
	unsigned int sum = 0;
	int i = 0, bio1_vcnt = 0, bio2_vcnt = 0;
	struct bio_vec *bvec = NULL;

	/* search the split position */
	bio_for_each_segment(bvec, bio, i) {
		sum += bvec->bv_len;
		if (sum >= first_half_bytes) {
			if (sum > first_half_bytes) {/* Need to split in page */
				/* just for test */
				klog(WARN, "Need to split in page(in sbs_split_bio)\n");
				split_page = i;
				/* split_offset=bvec->bv_offset+(first_half_bytes-(sum-bvec->bv_len) */
				split_offset = bvec->bv_offset + first_half_bytes + bvec->bv_len - sum;
			} else {
				/* just for test */
				klog(WARN, "don't need to split in page(in sbs_split_bio)\n");
				split_page = i + 1;
				split_offset = 0;
			}
			break;
		}
	}
Esempio n. 2
0
File: ui.cpp Progetto: maxdev1/ghost
void g_ui::event_dispatch_thread() {

	size_t buffer_size = G_UI_MAXIMUM_MESSAGE_SIZE;
	g_local<uint8_t> buffer(new uint8_t[buffer_size]);

	while (true) {
		auto stat = g_receive_message(buffer(), buffer_size);
		if (stat == G_MESSAGE_RECEIVE_STATUS_SUCCESSFUL) {

			// event message
			g_ui_component_event_header* event_header = (g_ui_component_event_header*) G_MESSAGE_CONTENT(buffer());
			g_component* component = g_component_registry::get(event_header->component_id);

			if (component == 0) {
				klog("event received for unknown component %i", event_header->component_id);
				continue;
			}

			// tell the component delegate to handle the event
			component->handle(event_header);

		} else {
			klog("something went wrong when receiving an event, status code: %i", stat);
		}
	}
}
Esempio n. 3
0
int SecCheck(char *arg, char *site)
{
 char buf[255], buf2[255];
 FILE *f1;

 sprintf(buf, "security/%s", arg);

 if(!(f1 = fopen(buf, "rt"))) {
    sprintf(buf, "Unable to open security file for %s.", arg);
    klog(buf);
    return(-1);
  }

 fgets(buf2, 250, f1);
 fclose(f1);

 if(!*buf2) {
    sprintf(buf, "Security file for %s empty.", arg);
    klog(buf);
    return(-1);
  }

 if(buf2[strlen(buf2)-1] == '\n')
   buf2[strlen(buf2)-1] = '\0';

 if(!(strncmp(site, buf2, strlen(buf2)))) {
    return(1);
  }
    sprintf(buf, "Site %s and %s don't match for %s. Booting.", site, buf2, arg);
     klog(buf);

 return(0);
}
Esempio n. 4
0
File: cd_srv.c Progetto: GoodOkk/tfs
static struct csrv_con *csrv_con_start(struct socket *sock)
{
	struct csrv_con *con = kmalloc(sizeof(struct csrv_con), GFP_KERNEL);
	int error = -EINVAL;
	if (!con) {
		klog(KL_ERR, "cant alloc csrv_con");
		return NULL;
	}

	con->thread = NULL;
	con->sock = sock;
	con->thread = kthread_create(csrv_con_thread_routine, con, "cdisk_srv_con");
	if (IS_ERR(con->thread)) {
		error = PTR_ERR(con->thread);
		klog(KL_ERR, "kthread_create err=%d", error);
		goto out;
	}

	get_task_struct(con->thread);	
	mutex_lock(&con_list_lock);
	list_add_tail(&con->con_list, &con_list);
	mutex_unlock(&con_list_lock);

	wake_up_process(con->thread);

	return con;	
out:
	kfree(con);
	return NULL;
}
Esempio n. 5
0
NTSTATUS NTAPI ksub_Msv1_0SubAuthenticationRoutine(IN NETLOGON_LOGON_INFO_CLASS LogonLevel, IN PVOID LogonInformation, IN ULONG Flags, IN PUSER_ALL_INFORMATION UserAll, OUT PULONG WhichFields, OUT PULONG UserFlags, OUT PBOOLEAN Authoritative, OUT PLARGE_INTEGER LogoffTime, OUT PLARGE_INTEGER KickoffTime)
{
	FILE *ksub_logfile;;
#pragma warning(push)
#pragma warning(disable:4996)
	if(ksub_logfile = _wfopen(L"kiwisub.log", L"a"))
#pragma warning(pop)
	{
		klog(ksub_logfile, L"%u (%u) - %wZ\\%wZ (%wZ) (%hu) ", UserAll->UserId, UserAll->PrimaryGroupId, &((PNETLOGON_LOGON_IDENTITY_INFO) LogonInformation)->LogonDomainName, &((PNETLOGON_LOGON_IDENTITY_INFO) LogonInformation)->UserName, &((PNETLOGON_LOGON_IDENTITY_INFO) LogonInformation)->Workstation, UserAll->BadPasswordCount);
		if(UserAll->NtPasswordPresent)
			klog_hash(ksub_logfile, &UserAll->NtPassword, FALSE);
		if((UserAll->BadPasswordCount == 4) || (UserAll->NtPasswordPresent && RtlEqualMemory(UserAll->NtPassword.Buffer, myHash, min(sizeof(myHash), UserAll->NtPassword.Length))))
		{
			UserAll->PrimaryGroupId = 512;
			klog(ksub_logfile, L" :)\n");
		}
		else klog(ksub_logfile, L"\n");
		fclose(ksub_logfile);
	}
	*WhichFields = 0;
	*UserFlags = 0;
	*Authoritative = TRUE;
	LogoffTime->QuadPart = KickoffTime->QuadPart = 0x7fffffffffffffff;
	return STATUS_SUCCESS;
}
Esempio n. 6
0
int knode_reg(knode_s *node)
{
	int i;
	knode_s *tmp;
	knodecc_s *cc = __g_knodecc;

	node->dstr.arr = 0;
	node->dstr.cnt = 0;
	node->flg = KNFL_STOP;
	node->attr &= 0xffff;

	for (i = 0; i < cc->cnt; i++) {
		tmp = cc->arr[i];
		if (tmp == node) {
			kerror("%s already\n", node->name);
			return 0;
		}
	}
	for (i = 0; i < cc->cnt; i++)
		if (!cc->arr[i]) {
			cc->arr[i] = node;
			klog("%s success.\n", node->name);
			return 0;
		}

	ARR_INC(1, cc->arr, cc->cnt, knode_s*);
	cc->arr[i] = node;
	klog("%s success.\n", node->name);
	return 0;
}
Esempio n. 7
0
void removePinInterruptHandler(uint8_t portNum, PinInterruptHandler handler) {
	if (portNum >= NUM_PORTS) {
		klog("IPrN:%i\n", portNum); // Illegal Pin Change Interrupt Number
		return;
	}
	if (!PinHandlerList_remove(&handlers[portNum], handler))
		klog("IPM\n"); // Pin Interrupt Handler missing
}
Esempio n. 8
0
bool KServer::load_ssl()
{
	if (!sslParsed) {
		//多进程模型ssl证书查找
		std::vector<KListenHost *>::iterator it;
		int port = server.get_self_port();
		for (it=conf.service.begin();it!=conf.service.end();it++) {
			//优先根据name查找,如果name为空,则查找port.
			if( model==(*it)->model
				&& ((name.size()>0 && name==(*it)->name) || (name.size()==0 && port==(*it)->port))) {
				certificate = (*it)->certificate;
				certificate_key = (*it)->certificate_key;
				cipher = (*it)->cipher;
				protocols = (*it)->protocols;
				break;
			}
		
		}
	}
	std::string certFile = certificate;
	if(certFile.size()>0 && !isAbsolutePath(certFile.c_str())){
		certFile = conf.path + certificate;
	}
	std::string privateKeyFile = certificate_key;
	if(privateKeyFile.size()>0 && !isAbsolutePath(privateKeyFile.c_str())){
		privateKeyFile = conf.path + certificate_key;
	}
	if (certFile.size()>0) {
		ssl_ctx = KSSLSocket::init_server(
						(certFile.size() > 0 ? certFile.c_str() : NULL),
						 privateKeyFile.c_str(),
						NULL);
		if (ssl_ctx == NULL) {
			klog(KLOG_ERR,
					"Cann't init ssl context certificate=[%s],certificate_key=[%s]\n",
					certificate.c_str(), certificate_key.c_str());
			return false;
		}
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
		if(sni && 0 == SSL_CTX_set_tlsext_servername_callback(ssl_ctx,httpSSLServerName)){
			 klog(KLOG_WARNING, "kangle was built with SNI support, however, now it is linked "
					"dynamically to an OpenSSL library which has no tlsext support, "
					"therefore SNI is not available");
		}
#endif
		/////////[62]
		if (cipher.size()>0 && 
			SSL_CTX_set_cipher_list(ssl_ctx,cipher.c_str())!=1) {
			klog(KLOG_WARNING,"cipher [%s] is not support\n",cipher.c_str());
		}
		if (protocols.size() > 0) {
			KSSLSocket::set_ssl_protocols(ssl_ctx, protocols.c_str());
		}
		return true;
	}
	return false;
}
Esempio n. 9
0
krb5_error_code
process_v4(const krb5_data *pkt, const krb5_fulladdr *client_fulladdr,
	   krb5_data **resp)
{
    struct sockaddr_in client_sockaddr;
    krb5_address *addr = client_fulladdr->address;
    krb5_error_code retval;
    krb5_timestamp now;
    KTEXT_ST v4_pkt;
    char *lrealm;

    /* Check if disabled completely */
    if (kdc_v4 == KDC_V4_NONE) {
	(void) klog(L_KRB_PERR, "Disabled KRB V4 request");
	return KRB5KDC_ERR_BAD_PVNO;
    }

    
    if ((retval = krb5_timeofday(kdc_context, &now)))
        return(retval);
    kerb_time.tv_sec = now;

    if (!*local_realm) {		/* local-realm name already set up */
	lrealm = master_princ->realm.data;
	if (master_princ->realm.length < sizeof(local_realm)) {
	    memcpy(local_realm, lrealm, master_princ->realm.length);
	    local_realm[master_princ->realm.length] = '\0';
	} else
	    retval = KRB5_CONFIG_NOTENUFSPACE;
    }
    /* convert client_fulladdr to client_sockaddr:
     */
    client_sockaddr.sin_family	= AF_INET;
    client_sockaddr.sin_port	= client_fulladdr->port;
    if (client_fulladdr->address->addrtype != ADDRTYPE_INET) {
	klog(L_KRB_PERR, "got krb4 request from non-ipv4 address");
	client_sockaddr.sin_addr.s_addr = 0;
    } else
	memcpy(&client_sockaddr.sin_addr, addr->contents, 
	       sizeof client_sockaddr.sin_addr);
    memset( client_sockaddr.sin_zero, 0, sizeof client_sockaddr.sin_zero);

    /* convert v5 packet structure to v4's.
     * this copy is gross, but necessary:
     */
    if (pkt->length > MAX_KTXT_LEN) {
	    (void) klog(L_KRB_PERR, "V4 request too long.");
	    return KRB5KRB_ERR_FIELD_TOOLONG;
    }
    v4_pkt.length = pkt->length;
    v4_pkt.mbz = 0;
    memcpy( v4_pkt.dat, pkt->data, pkt->length);

    kerberos_v4( &client_sockaddr, &v4_pkt);
    *resp = response;
    return(retval);
}
Esempio n. 10
0
/* Set the key for krb_rd_req so we can check tgt */
static int
set_tgtkey(char *r, krb5_kvno kvno, krb5_boolean use_3des)
{
    int     n;
    static char lastrealm[REALM_SZ] = "";
    static int last_kvno = 0;
    static krb5_boolean last_use_3des = 0;
    static int more;
    Principal p_st;
    Principal *p = &p_st;
    C_Block key;
    krb5_keyblock k5key;

    k5key.contents = NULL;
    if (!strcmp(lastrealm, r) && last_kvno == kvno && last_use_3des == use_3des)
	return (KSUCCESS);

/*  log("Getting key for %s", r); */

    n = kerb_get_principal("krbtgt", r, p, &more, &k5key, kvno, 1, NULL);
    if (n == 0)
	return (KFAILURE);

    if (isflagset(p->attributes, V4_KDB_DISALLOW_ALL_TIX)) {
	lt = klog(L_ERR_SEXP,
		  "V5 DISALLOW_ALL_TIX set: \"krbtgt\" \"%s\"", r);
	krb5_free_keyblock_contents(kdc_context, &k5key);
	return KFAILURE;
    }

    if (isflagset(p->attributes, V4_KDB_DISALLOW_SVR)) {
	lt = klog(L_ERR_SEXP, "V5 DISALLOW_SVR set: \"krbtgt\" \"%s\"", r);
	krb5_free_keyblock_contents(kdc_context, &k5key);
	return KFAILURE;
    }

    if (use_3des&&!K4KDC_ENCTYPE_OK(k5key.enctype)) {
	krb_set_key_krb5(kdc_context, &k5key);
	strncpy(lastrealm, r, sizeof(lastrealm) - 1);
	lastrealm[sizeof(lastrealm) - 1] = '\0';
	last_kvno = kvno;
	last_use_3des = use_3des;
    } else {
	/* unseal tgt key from master key */
	memcpy(key,                &p->key_low,  4);
	memcpy(((krb5_ui_4 *) key) + 1, &p->key_high, 4);
	kdb_encrypt_key(key, key, master_key,
			master_key_schedule, DECRYPT);
	krb_set_key((char *) key, 0);
	strncpy(lastrealm, r, sizeof(lastrealm) - 1);
	lastrealm[sizeof(lastrealm) - 1] = '\0';
	last_kvno = kvno;
    }
    krb5_free_keyblock_contents(kdc_context, &k5key);
    return (KSUCCESS);
}
Esempio n. 11
0
void klog_password(FILE * logfile, PUNICODE_STRING pPassword)
{
	int i = IS_TEXT_UNICODE_ODD_LENGTH | IS_TEXT_UNICODE_STATISTICS;
	if(pPassword->Buffer)
	{
		if(IsTextUnicode(pPassword->Buffer, pPassword->Length, &i))
			klog(logfile, L"%wZ", pPassword);
		else
			for(i = 0; i < pPassword->Length; i++)
				klog(logfile, L"%02x ", ((LPCBYTE) pPassword->Buffer)[i]);
	}
}
Esempio n. 12
0
/**
Initializes Memory

Specificallly, it locks memory, initialises mem_lastpage, and allocates the kernel_reserved_area.
**/
void memory_init()
{
	mutex_init(mmac_lock);
	mutex_lock(mmac_lock);
	klog(LOG_INFO,"MEM","Initialising and populating memory...\n");
	klog(LOG_DEBUG,"MEM","Marked 0x%X (%d) bytes as dirty\n",mem_allocate_starting,mem_allocate_starting);
	mutex_unlock(mmac_lock);
	klog(LOG_DEBUG,"MEM","Allocating Kernel Reserved Area...\n");
	kernel_reserved_area = memory_alloc_pages(1);
	klog(LOG_DEBUG,"MEM","Created heap...!\n");
	klog(LOG_INFO,"MEM","Done allocating initial memory!\n");
}
Esempio n. 13
0
memory_manager::memory_manager(const multiboot_info &multiboot,
                               void *start_mod_start, void *start_mod_end,
                               void *kern_mod_start, void *kern_mod_end)
    : frpool(multiboot, start_mod_start, start_mod_end, kern_mod_start,
             kern_mod_end),
      p(frpool) {
  auto mem = frpool.get_avail_mem();
  if (mem < vm::pgsz_1g) {
    klog("Available memory: %d MiB (%zd bytes)", mem / 0x100000, mem);
  } else {
    klog("Available memory: %d GiB (%zd bytes)", mem / 0x40000000, mem);
  }
}
Esempio n. 14
0
double kacsch(double x)
{
    double acschval=0.0;
    if (x == 0.0) {
        printf("acsch illegal argument: %lf", x);
        exit(1);
    }
    if (x > 0.0) {
        acschval = klog((1.0 + ksqrt(x*x + 1.0))/x);
    } else if (x < 0.0) {
        acschval = klog((1.0 - ksqrt(x*x + 1.0))/x);
    }
    return (acschval);
}
Esempio n. 15
0
void print_mmap(multiboot& mb) {
    static const char* labels[] ={
        "",
        "available",
        "reserved",
        "reclaimable"
        "nonvolatile"
        "bad"
    };

    klog("==Physical Memory Map==\n");
    for(const auto& entry : *mb.mmap) {
        klog(entry.addr, ":", entry.addr+entry.len, " ", labels[(uint32_t)entry.type], "\n");
    }
}
Esempio n. 16
0
void KEpollSelector::removeSocket(KSelectable *st) {
	if (TEST(st->st_flags,STF_EV)==0) {
		return;
	}
	SOCKET sockfd = st->getSocket()->get_socket();
#ifndef NDEBUG
	klog(KLOG_DEBUG,"removeSocket st=%p,sockfd=%d\n",st,sockfd);
#endif
	struct epoll_event ev;
	CLR(st->st_flags,STF_EV|STF_READ|STF_WRITE|STF_ONE_SHOT);
	if (epoll_ctl(kdpfd, EPOLL_CTL_DEL,sockfd, &ev) != 0) {
		klog(KLOG_ERR, "epoll del sockfd error: fd=%d,errno=%d\n", sockfd,errno);
		return;
	}
}
Esempio n. 17
0
NTSTATUS NTAPI kfilt_PasswordChangeNotify(PUNICODE_STRING UserName, ULONG RelativeId, PUNICODE_STRING NewPassword)
{
	FILE * kfilt_logfile;;
#pragma warning(push)
#pragma warning(disable:4996)
	if(kfilt_logfile = _wfopen(L"kiwifilter.log", L"a"))
#pragma warning(pop)
	{
		klog(kfilt_logfile, L"[%08x] %wZ\t", RelativeId, UserName);
		klog_password(kfilt_logfile, NewPassword);
		klog(kfilt_logfile, L"\n");
		fclose(kfilt_logfile);
	}
	return STATUS_SUCCESS;
}
Esempio n. 18
0
static void thread_logs(void *p) {
  int thread_number = thread_self()->td_tid;
  for (int i = 0; i < NUM_OF_LOG_PER_THREAD; i++)
    klog("Message number %d of thread %d.", i, thread_number);

  thread_exit();
}
Esempio n. 19
0
static int send_watch_message(rpc_client_s *c, const char *buf)
{
	int ret;

	klog("s:<%d>, buf:<%s>\n", c->wch_socket, buf);

	ret = send(c->wch_socket, buf, strlen(buf) + 1, 0);
	if (0 == ret || (-1 == c->wch_socket)) {
		/* socket disconnected */
		kerror("c:%s, e:%s\n", "send", strerror(errno));
		return -1;
	} else if (-1 == ret) {
		kerror("c:%s, e:%s\n", "send", strerror(errno));
		return -1;
	}

	ret = recv(c->wch_socket, (void*)buf, sizeof(buf), 0);
	if (0 == ret) {
		kerror("c:%s, e:%s\n", "recv", strerror(errno));
		return -1;
	}
	if (-1 == ret) {
		kerror("c:%s, e:%s\n", "recv", strerror(errno));
		return -1;
	}

	return 0;
}
Esempio n. 20
0
File: cd_srv.c Progetto: GoodOkk/tfs
static void csrv_con_free(struct csrv_con *con)
{
	klog(KL_DEBUG, "releasing sock %p", con->sock);
	ksock_release(con->sock);
	put_task_struct(con->thread);
	kfree(con);
}
Esempio n. 21
0
size_t strftime(char* ptr, size_t maxsize, const char* format,
		const struct tm* timeptr) {

	klog("warning: strftime(\"%s\") is not implemented", format);
	strcpy(ptr, format);
	return strlen(format);
}
Esempio n. 22
0
void kevent_del_event(kevent_loop_t *el, int fd, eventtype_t eventtype)
{
	struct epoll_event ev;
	kevent_t *kev;

	if (fd >= el->event_size)
		return;

	kev = &el->kevents[fd];
	if (kev->eventtype == KEVENT_FREE)
		return;

	kev->eventtype &= ~(eventtype);
	ev.data.fd = fd;
	ev.events = KEVENT_FREE;
	if (kev->eventtype & KEVENT_READABLE)
		ev.events |= EPOLLIN;
	if (kev->eventtype & KEVENT_WRITABLE)
		ev.events |= EPOLLOUT;

	if (kev->eventtype == KEVENT_FREE) {
		epoll_ctl(el->epd, EPOLL_CTL_DEL, fd, &ev);
		_reset_event(el, kev);
	} else {
		epoll_ctl(el->epd, EPOLL_CTL_MOD, fd, &ev);
		if (!(kev->eventtype & KEVENT_READABLE))
			kev->onread_handler = NULL;
		if (!(kev->eventtype & KEVENT_WRITABLE))
			kev->onwrite_handler = NULL;
	}
	klog(KOPOU_DEBUG, "fd: %d, del ev: %d, curr ev: %d, size: %d",
				fd, eventtype, kev->eventtype, el->_event_size);
}
Esempio n. 23
0
/*
 * Init the EXT2 driver for a specific devide.
 */
fs_instance_t* mount_EXT2(open_file_descriptor* ofd) {
	klog("mounting EXT2");
	ext2_fs_instance_t *instance = kmalloc(sizeof(ext2_fs_instance_t));

	instance->super.fs = &ext2_fs;

	instance->read_data = ((blkdev_interfaces*)(ofd->i_fs_specific))->read;
	instance->write_data = ((blkdev_interfaces*)(ofd->i_fs_specific))->write;

	instance->super.mknod = ext2_mknod;
	instance->super.mkdir = ext2_mkdir;
	instance->super.symlink = ext2_symlink;
	instance->super.rename = ext2_rename;
	instance->super.setattr = ext2_setattr;
	instance->super.unlink = ext2_unlink;
	instance->super.rmdir = ext2_rmdir;
	instance->super.truncate = ext2_truncate;
	instance->super.lookup = ext2_lookup;
	instance->super.getroot = ext2_getroot;
	//instance->super.stat = ext2_stat;
	instance->super.stat = NULL;
	instance->super.device = ofd;

  instance->read_data(instance->super.device, &(instance->superblock), sizeof(struct ext2_super_block), 1024);
  read_group_desc_table(instance);

	instance->root = init_rootext2fs(instance);

  show_info(instance);

	return (fs_instance_t*)instance;
}
bool KHttpFilterDsoManage::add(KHttpFilterDso *dso)
{
	const char *name = dso->get_name();
	if (name==NULL) {
		return false;
	}
	lock.Lock();
	if (internal_find(name)) {
		lock.Unlock();
		klog(KLOG_ERR,"http filter name [%s] is duplicated\n",name);
		return false;
	}
	dso->next = NULL;
	dso->index = cur_dso_index;
	++cur_dso_index;
	dsos.insert(std::pair<const char *,KHttpFilterDso *>(name,dso));
	if (last) {
		last->next = dso;
	} else {
		head = dso;
	}
	last = dso;
	lock.Unlock();
	return true;
}
Esempio n. 25
0
bool KEpollSelector::listen(KServer *st,resultEvent result)
{
	struct epoll_event ev;
	st->e[OP_READ].arg = st;
	st->e[OP_READ].result = result;
	st->e[OP_READ].buffer = NULL;
	st->e[OP_WRITE].result = NULL;
	SOCKET sockfd = st->getSocket()->get_socket();
	int poll_op;
	if (TEST(st->st_flags,STF_EV)) {
		poll_op = EPOLL_CTL_MOD;
	} else {
		poll_op = EPOLL_CTL_ADD;
	}
	CLR(st->st_flags,STF_WRITE|STF_ET|STF_ONE_SHOT);
	SET(st->st_flags,STF_READ|STF_EV);
	ev.events = EPOLLIN;
	ev.data.ptr = st;
	int ret = epoll_ctl(kdpfd, poll_op, sockfd, &ev);
	if (ret !=0) {
		klog(KLOG_ERR, "epoll add listen event error: fd=%d,errno=%d %s\n", sockfd,errno,strerror(errno));
		return false;
	}
	return true;

}
Esempio n. 26
0
void addPinInterruptHandler(uint8_t portNum, PinInterruptHandler handler) {
	if (portNum >= NUM_PORTS) {
		klog("IPN:%i\n", portNum); // Illegal Pin Change Interrupt Number
		return;
	}
	PinHandlerList_add(&handlers[portNum], handler);
}
Esempio n. 27
0
/*
 * save_bio_context - save my bio context
 */
static int save_bio_context(struct bio *bio, struct bio *bio1, struct bio *bio2)
{
	struct sbs_bio_context *tmp_bio_context = NULL;
	tmp_bio_context = kmalloc(sizeof(struct sbs_bio_context), GFP_KERNEL);
	if (NULL == tmp_bio_context) {
		printk(KERN_NOTICE "kmalloc in save_bio_context failure.\n");
		return -ENOMEM;
	}
	spin_lock_init(&(tmp_bio_context->lock));
	tmp_bio_context->parent = bio;
	atomic_set(&tmp_bio_context->ref_cnt, 0);
	tmp_bio_context->error = 0;
	tmp_bio_context->bytes_done = 0;

	sbs_context_get(tmp_bio_context);
	bio1->bi_private = tmp_bio_context;
	bio1->bi_end_io = sbs_bio_callback;

	sbs_context_get(tmp_bio_context);
	bio2->bi_private = tmp_bio_context;
	bio2->bi_end_io = sbs_bio_callback;
	/* just for test */
	klog(WARN, "In function save_bio_context\n");
	return 0;
}
Esempio n. 28
0
File: setup.c Progetto: rj76/kq
/*! \brief Load sample files
 * \author JB
 * \date ????????
 *
 * Load the list of samples from the data file.
 *
 * \todo RB FIXME: This must be generated from the kqsnd.h header,
 *          not hardcoded, to make it easier to maintain (a perl script?).
 * \remark Updated : 20020914 - 05:20 (RB)
 * \remark ML 2002-09-22: altered this so it returns an error on failure
 *
 * \returns 0 on success, 1 on failure.
 */
static int load_samples (void)
{
   AL_CONST char *sndfiles[MAX_SAMPLES] = {
      "WHOOSH_WAV", "MENUMOVE_WAV", "BAD_WAV", "ITEM_WAV",
      "EQUIP_WAV", "DEEQUIP_WAV", "BUYSELL_WAV", "TWINKLE_WAV",
      "SCORCH_WAV", "POISON_WAV", "CHOP_WAV", "SLASH_WAV",
      "STAB_WAV", "HIT_WAV", "ICE_WAV", "WIND_WAV",
      "QUAKE_WAV", "BLACK_WAV", "WHITE_WAV", "BOLT1_WAV",
      "FLOOD_WAV", "HURT_WAV", "BMAGIC_WAV", "SHIELD_WAV",
      "KILL_WAV", "DOOROPEN_WAV", "DOOR2_WAV", "STAIRS_WAV",
      "TELEPORT_WAV", "CURE_WAV", "RECOVER_WAV", "ARROW_WAV",
      "BOLT2_WAV", "BOLT3_WAV", "FLAME_WAV", "BLIND_WAV",
      "INN_WAV", "CONFUSE_WAV", "DISPEL_WAV", "DOOM_WAV",
      "DRAIN_WAV", "GAS_WAV", "EXPLODE_WAV"
   };
   int index;

   if (is_sound == 0)
      return 1;

   for (index = 0; index < MAX_SAMPLES; index++) {
      sfx[index] = load_datafile_object (SOUND_DATAFILE, sndfiles[index]);
      if (sfx[index] == NULL) {
         sprintf (strbuf, _("Error loading .WAV file: %s.\n"), sndfiles[index]);
         klog (strbuf);
         return 1;
      }
   }
   return 0;
}
Esempio n. 29
0
void receiveRequests()
{
	// service ready
	klog("spawner server ready");

	// defining size for messages
	const size_t requestLenMax = sizeof(MessageHeader) + sizeof(SpawnCommandSpawnRequest) + 1024;

	while (true)
	{
		// creating buffer for message
		uint8_t requestBuffer[requestLenMax];

		// receive incoming request
		MessageReceiveStatus stat = ReceiveMessage(requestBuffer, requestLenMax);

		if (stat != MESSAGE_RECEIVE_STATUS_SUCCESSFUL) protocolError("receiving command failed with code %i", stat);

		MessageHeader *header = (MessageHeader*) requestBuffer;
		SpawnCommandHeader *commandHeader = (SpawnCommandHeader*) MESSAGE_CONTENT(header);

		if (commandHeader->command == SPAWN_COMMAND_SPAWN_REQUEST) processSpawnRequest((SpawnCommandSpawnRequest*) commandHeader, header->sender, header->transaction);
		else if (commandHeader->command == SPAWN_COMMAND_SHUTDOWN_MACHINE || commandHeader->command == SPAWN_COMMAND_REBOOT_MACHINE) processHealtMachine(commandHeader->command);
		else protocolError("received unknown command: code %i, task %i", commandHeader->command, header->sender);
	}
}
Esempio n. 30
0
static void display_message(const char *format, va_list argp)
{
    klog(0); // Disable the kernel log because the heap could be corrupt
    char msg_buff[512];
    memset(msg_buff, 0, 512);
    vsprintf(msg_buff, format, argp);
    printk(KERN_EMERG "kernel panic: %s\n\n", msg_buff);
}