예제 #1
0
파일: driver.c 프로젝트: looncraz/haiku
static void et6000UnmapDevice(ET6000DeviceInfo *di) {
ET6000SharedInfo *si = di->si;

    ddprintf(("et6000UnmapDevice(%08lx) begins...\n", (uint32)di));
    ddprintf((" memoryArea: %ld\n", si->memoryArea));

    if (si->memoryArea >= 0)
        delete_area(si->memoryArea);
    si->memoryArea = -1;
    si->framebuffer = NULL;
    si->physFramebuffer = NULL;
    si->memory = NULL;
    si->physMemory = NULL;

    ddprintf(("et6000UnmapDevice() ends.\n"));
}
예제 #2
0
파일: servo.c 프로젝트: GLTsoftware/antenna
void WaitTickGetTime(void) {
    static int oldusec = -1;
    int stat;

    ReadCntr();                   /* Wait for the 48 ms heartbeat */
#if USE_SYSTEM_TIME
    gettimeofday(&tv, &tz);
    tmp = gmtime(&tv.tv_sec);
    tsshm->msec = ((tmp->tm_hour * 60 + tmp->tm_min) * 60 + tmp->tm_sec) *
                  1000 + (tv.tv_usec + 500) / 1000;
    tsshm->day = tmp->tm_yday;
#else /* USE_SYSTEM_TIME */
    /* get the current time in any case */
    if((stat = read(ttfd, &ttime, sizeof(ttime))) < 0) {
        ErrPrintf("Error %d reading TrueTime\n", stat);
    }
    if(ttime.input_reference_error || (ttime.phase_locked ^ 1)) {
        irig_error_seen = 1;
    }
    lastTimeStep = (ttime.usec - oldusec) / 1e6;	/* Time step (sec) */
    if(lastTimeStep < 0) {
        lastTimeStep += 1;
    }
    oldusec = ttime.usec;

    /* Convert the time now */
    tsshm->msec = ((ttime.hour * 60 + ttime.min) * 60 + ttime.sec) * 1000 +
                  (ttime.usec + 500) / 1000;
    tsshm->day = ttime.yday;
#endif /* USE_SYSTEM_TIME */
    ddprintf("day %d msec %d\n", tsshm->day, tsshm->msec);
}
예제 #3
0
/* return 1 if we should change, 0 if not. */
char random_eval(int diff, int cloud_count)
{
    char result = 0;
    long int r = random();
    double u = (r / (double) RAND_MAX);
    int i;

    for (i = 0; i < IMPROVE_MAX - 1; i++) {
        if (diff <= improve_vec[i]) {
            break;
        }
    }

    /* if we are taking into account the number of cloud boxes, adjust
     * improvement probability based on our current idea of the number of
     * cloud boxes in our cloud.
     */
    if (db[39].d) { improve_prob_init(cloud_count); }

    result = (u <= improve_prob[i]);
    if (db[11].d) {
        ddprintf("random_eval:  diff of %d; u %f <? improve_prob %f:  %d\n",
                diff, u, improve_prob[i], (int) result);
    }

    return result;
}
예제 #4
0
static int
ntfs_vptofh(
	struct vnode *vp,
	struct fid *fhp,
	size_t *fh_size)
{
	struct ntnode *ntp;
	struct ntfid ntfh;
	struct fnode *fn;

	if (*fh_size < sizeof(struct ntfid)) {
		*fh_size = sizeof(struct ntfid);
		return E2BIG;
	}
	*fh_size = sizeof(struct ntfid);

	ddprintf(("ntfs_fhtovp(): %s: %p\n", vp->v_mount->mnt_stat.f_mntonname,
		vp));

	fn = VTOF(vp);
	ntp = VTONT(vp);
	memset(&ntfh, 0, sizeof(ntfh));
	ntfh.ntfid_len = sizeof(struct ntfid);
	ntfh.ntfid_ino = ntp->i_number;
	ntfh.ntfid_attr = fn->f_attrtype;
#ifdef notyet
	ntfh.ntfid_gen = ntp->i_gen;
#endif
	memcpy(fhp, &ntfh, sizeof(ntfh));
	return (0);
}
예제 #5
0
static void quoted2plain(char **quoted, char *plain) 
{
	int quote_on = 0;
	char *p, *s = *quoted;	
	for (p = plain; *s; s++) {
		if (isspace(*s) && !quote_on)
			break;
		if ((!pattern_type || *s != '\\') && 
		    *s != '"' && *s != '\'') {
			*p++ = *s;
			continue;
		}	     				
		if ((*s == '"' || *s == '\'') &&
		    (!quote_on || quote_on == *s)) {
			if (quote_on)
				quote_on = 0;
			else 
				quote_on = *s;
			continue;
		}
		if (pattern_type && !*++s) {
			*plain = 0;
			ddprintf("%s", errstr[TS_INCORRECT_PARAMS]);
			return;
		}
		*p++ = *s;
	}
	*p = 0;
	*quoted = s;
}
예제 #6
0
/*ARGSUSED*/
static int
ntfs_fhtovp(
	struct mount *mp,
	struct fid *fhp,
	struct vnode **vpp)
{
	struct ntfid ntfh;
	int error;

	if (fhp->fid_len != sizeof(struct ntfid))
		return EINVAL;
	memcpy(&ntfh, fhp, sizeof(ntfh));
	ddprintf(("ntfs_fhtovp(): %s: %llu\n", mp->mnt_stat.f_mntonname,
	    (unsigned long long)ntfh.ntfid_ino));

	error = ntfs_vgetex(mp, ntfh.ntfid_ino, ntfh.ntfid_attr, NULL,
			LK_EXCLUSIVE, 0, vpp);
	if (error != 0) {
		*vpp = NULLVP;
		return (error);
	}

	/* XXX as unlink/rmdir/mkdir/creat are not currently possible
	 * with NTFS, we don't need to check anything else for now */
	return (0);
}
예제 #7
0
/* create the pipe we use to send interrupts to ourselves. */
void timer_init()
{
    if (pipe(interrupt_pipe) == -1) {
        ddprintf("main; pipe creation failed:  %s\n", strerror(errno));
        exit(1);
    }
}
예제 #8
0
static int visit_bbs(int m)
{
	time_t aika;
	char *aikas;
	char puskur[300];

	lrp = lsp = oldlrp = oldlsp = 0;
	lrpdatname[0] = 0;
	ffilestagged = filestagged = bytestagged = fbytestagged = 0;
	*reason = 0;
	memset(&clog, 0, sizeof(struct callerslog));
	memset(&user, 0, sizeof(struct userbase));
	onlinestat = 0;
	display = 0;
	clearlist(olms);
	clearlist(flaggedfiles);

	carrier = 1;
	aika = time(0);
	aikas = ctime(&aika);
	aikas[24] = 0;

	snprintf(puskur, sizeof puskur, "===============================================[ %s ]===\n%d BPS connection on line #%d\n\n", aikas, bpsrate, node);
	writelog(puskur);

	changenodestatus("Logging in...");

	ddprintf("DayDream BBS/UNiX %s\nProgramming by Antti Häyrynen 1996, 1997,\n    DayDream Development Team 1998, 1999, 2000, 2001, 2002, 2003, 2004,\n    Bo Simonsen 2008, 2009, 2010\nCurrently maintained by Ryan Fantus\nYou are connected to node #%d at %d BPS.\n\n", versionstring, node, bpsrate);

	rundoorbatch("data/frontends.dat", NULL);

	if (!display)
		if (getdisplaymode(0, 0) < 1) {
			DDPut("Failed to load displaymode... disconnecting!\n\n");
			return 0;
		}
	if (!syspw()) {
		DDPut(sd[disconnectingstr]);
		return 0;
	}

	TypeFile("banner", TYPE_MAKE | TYPE_WARN);

	if (m) {
		switch (checklogon("sysop")) {
		case 1:
			sleep(2);
			getin();
			break;
		}
		return 1;
	}
	login_loop();

	DDPut(sd[disconnectingstr]);
	dropcarrier();
	return 1;
}
예제 #9
0
/* send a sequence number message.  this is an addition to the protocol
 * to attempt to improve message delivery robustness at the link level,
 * at the expense of bandwidth.
 */
void send_seq(int stp_ind, byte *message, int msg_len)
{
    message_t seq_msg;

    if (!db[22].d) { return; }

    if (db[23].d) {
        ddprintf("send_seq sending <%d %d> to ",
                stp_list[stp_ind].box.send_sequence,
                msg_len);
        mac_dprint(eprintf, stderr, stp_list[stp_ind].box.name);
    }

    #if 0
    /* test-harness code; don't send a sequence message, to test the
     * protocol when a sequence message gets dropped.
     */
    if (db[24].d) {
        ddprintf("send_seq intentionally dropping packet..\n");
        db[24].d = false;
        return;
    }
    #endif

    seq_msg.message_type = sequence_msg;
    seq_msg.v.seq.sequence_num = stp_list[stp_ind].box.send_sequence;
    stp_list[stp_ind].box.awaiting_ack = true;

    if (msg_len > CLOUD_BUF_LEN) {
        seq_msg.v.seq.message_len = 0;
        stp_list[stp_ind].box.message_len = 0;
        ddprintf("send_seq got message with invalid length %d\n", msg_len);

    } else {
        seq_msg.v.seq.message_len = msg_len;
        stp_list[stp_ind].box.message_len = msg_len;
        memmove((void *) &stp_list[stp_ind].box.message, message, msg_len);
    }

    mac_copy(seq_msg.dest, stp_list[stp_ind].box.name);
    send_cloud_message(&seq_msg);

    update_ack_timer();

} /* send_seq */
예제 #10
0
/* put mac into mac_list if it's not already there. */
static void add_mac_addr(mac_address_t mac)
{
    int i;

    for (i = 0; i < mac_count; i++) {
        if (mac_equal(mac, mac_list[i])) {
            ddprintf("add_mac_addr warning: duplicat mac addresses.\n");
            // return;
        }
    }

    if (mac_count >= MAX_CLOUD) {
        ddprintf("add_mac_addr; too many mac addresses.\n");
        return;
    }

    mac_copy(mac_list[mac_count++], mac);
}
예제 #11
0
/* print array of cloud boxes.  this is usually called with "nbr_device_list",
 * the boxes that we can see 802.11 beacons from directly
 */
void print_cloud_list(cloud_box_t *list, int list_len, char *title)
{
    int i;

    ddprintf("%s\n", title);
    for (i = 0; i < list_len; i++) {
        cloud_box_print(eprintf, stderr, &list[i], 4);
    }
}
예제 #12
0
/* debug-print the amount of time that has transpired since the box was
 * turned on in seconds, with fraction showing hundreth's of seconds.
 */
void ptime(char *title, struct timeval time)
{
    ddprintf("%s:  %.2f; ",
            title,
            (time.tv_sec == -1)
                ? -1
                : ((double) usec_diff(time.tv_sec, time.tv_usec,
                        start.tv_sec, start.tv_usec) / 1000000.));

}
예제 #13
0
static void ask_params(void)
{
	if (!*search_str) {
		char buffer[512], *s = buffer;
		ddprintf("%s", errstr[TS_STRING_PROMPT]);
		buffer[0] = 0;
		if (!Prompt(buffer, 512, 0))
			return;
		
		quoted2plain(&s, search_str);
		if (!*search_str) {
			ddprintf("%s", errstr[TS_CANCEL]);
			return;
		}
	}
	
	if (pattern_type < 2)
		shrink_spaces(search_str);
}
예제 #14
0
/* this routine is called periodically based on timed interrupts.
 * it sends a character into a pipe we use to talk to ourselves.
 * the arrival of a character causes the main routine to break out
 * of its "select()" statement and do periodic activities that we
 * are supposed to initiate, such as sending out stp beacons.
 */
void send_interrupt_pipe_char()
{
    char c = 'x';
    int result = write(interrupt_pipe[1], &c, 1);
    if (result == -1) {
        ddprintf("send_interrupt_pipe_char; write failed:  %s\n",
                strerror(errno));
        return;
    }
}
예제 #15
0
static void typedlprompt(void)
{
	char buffer1[256];
	char buffer2[256];

	recountfiles();
	freefstr(buffer1, sizeof buffer1);
	freebstr(buffer2, sizeof buffer2);
	ddprintf(sd[dlpromptstr], filestagged, buffer1, bytestagged, buffer2);
}
예제 #16
0
/* this is a light-weight message that sometimes is sent even if we sent
 * no ping out.
 */
void process_ping_response_msg(message_t *message, int device_index)
{
    mac_address_ptr_t sender;

    sender = get_name(device_index, message->eth_header.h_source);

    if ((sender != NULL) && do_wrt_beacon) {
        wrt_util_update_time(sender);
    }

    if (db[7].d) {
        ddprintf("got ping response from ");
        if (sender == NULL) {
            ddprintf(" <NULL> (from get_name)\n");
        } else {
            mac_dprint(eprintf, stderr, sender);
        }
    }
}
예제 #17
0
파일: driver.c 프로젝트: looncraz/haiku
/*
 * Returns B_OK if one is found, otherwise returns
 * B_ERROR so the driver will be unloaded.
 */
status_t init_hardware(void) {
long pciIndex = 0;
pci_info pcii;
bool foundOne = FALSE;

    /* choke if we can't find the PCI bus */
    if (get_module(B_PCI_MODULE_NAME, (module_info **)&pci_bus) != B_OK)
        return B_ERROR;

    /* while there are more pci devices */
    while ((*pci_bus->get_nth_pci_info)(pciIndex, &pcii) == B_NO_ERROR) {
        int vendor = 0;

        ddprintf(("ET6000 init_hardware(): checking pci index %ld, device 0x%04x/0x%04x\n", pciIndex, pcii.vendor_id, pcii.device_id));
        /* if we match a supported vendor */
        while (supportedDevices[vendor].vendor) {
            if (supportedDevices[vendor].vendor == pcii.vendor_id) {
                uint16 *devices = supportedDevices[vendor].devices;
                /* while there are more supported devices */
                while (*devices) {
                    /* if we match a supported device */
                    if (*devices == pcii.device_id) {
                        ddprintf(("ET6000: we support this device\n"));
                        foundOne = TRUE;
                        goto done;
                    }
                    /* next supported device */
                    devices++;
                }
            }
            vendor++;
        }
        /* next pci_info struct, please */
        pciIndex++;
    }
    ddprintf(("ET6000: init_hardware - no supported devices\n"));

done:
    /* put away the module manager */
    put_module(B_PCI_MODULE_NAME);
    return (foundOne ? B_OK : B_ERROR);
}
예제 #18
0
/* delete device_list[d], and close the file descriptor that is open on
 * that device.
 */
void delete_device(int d)
{
    int i;
    int result;
    
    if (db[0].d) { ddprintf("hi from delete_device..\n"); }

    result = close(device_list[d].fd);
    if (result != 0) {
        ddprintf("delete_device:  could not close %s\n",
                device_list[d].device_name);
    }

    for (i = d; i < device_list_count - 1; i++) {
        device_list[i] = device_list[i + 1];
    }
    device_list_count--;

    if (db[0].d) { print_devices(); }
}
예제 #19
0
파일: midi.c 프로젝트: AmirAbrams/haiku
static status_t
midi_free(
	void * cookie)
{
	int ix;
	status_t f;
	ddprintf(("cmedia_pci: midi_free()\n"));
	f = (*mpu401->free_hook)(cookie);
	for (ix=0; ix<num_cards; ix++) {
		if (cards[ix].midi.cookie == cookie) {
			if (atomic_add(&cards[ix].midi.count, -1) == 1) {
				cards[ix].midi.cookie = NULL;
				ddprintf(("cleared %p card %d\n", cookie, ix));
			}
			break;
		}
	}
	ddprintf(("cmedia_pci: midi_free() done\n"));
	return f;
}
예제 #20
0
파일: version.c 프로젝트: hlyytine/daydream
void versioninfo(void)
{
    struct utsname pilu;
    uname(&pilu);

    ddprintf("\033[2J\033[H\033[0;33mDayDream/UNiX BBS %s\n"
             "\033[32mCopyright (C) 1996, 1997 Antti Häyrynen\n"
             "\033[32mCopyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 DayDream Development Team\n"
             "\033[0mRunning on %s/%s %s\n\n",
             versionstring, pilu.sysname, pilu.machine, pilu.release);
}
예제 #21
0
/* the array of cloud boxes describes a spanning tree, with children of
 * each node in a contiguous block in the array.  print each cloud box
 * and the index range of its children.
 */
static void dprint_db_cloud_stats(ddprintf_t *fn, FILE *f, message_t *cloud,
    int *child_start, int *child_count, int cloud_count)
{
    int i;

    for (i = 0; i < cloud_count; i++) {
        mac_dprint_no_eoln(fn, f, cloud[i].v.stp_beacon.originator);
        ddprintf(" child start %d; child count %d\n",
                child_start[i], child_count[i]);
    }
}
예제 #22
0
파일: pxe.c 프로젝트: emmericp/syslinux
/* Generate ip= option and print the ip adress */
static void ip_init(void)
{
    uint32_t ip = IPInfo.myip;
    char dot_quad_buf[16];

    genipopt();
    gendotquad(dot_quad_buf, ip);

    ip = ntohl(ip);
    ddprintf("My IP address seems to be %08X %s\n", ip, dot_quad_buf);
}
예제 #23
0
/* used to add wds or ad-hoc devices.  uses cloud_box_t, which would cause
 * circularities in .h files, so leave it here.
 */
void add_perm_io_stat_index(int *nbr_perm_io_stat_index,
        mac_address_t neighbor_name, device_type_t type)
{
    int i;
    bool_t found;
    status_t *p;

    ddprintf("\n\n ADD_PERM_IO_STAT_INDEX \n\n");
    found = false;
    for (i = 0; i < perm_io_stat_count; i++) {
        if (mac_equal(perm_io_stat[i].name, neighbor_name)) {
            *nbr_perm_io_stat_index = i;
            found = true;
            break;
        }
    }

    if (!found) {
        if (perm_io_stat_count >= MAX_CLOUD) {
            ddprintf("add_perm_io_stat_index; too many perm_io_stat's\n");
            /* at some point, garbage collect perm_io_stat with oldest
             * last-update time
             */
            goto done;
        }

        p = &perm_io_stat[perm_io_stat_count++];
        status_init(p);
        mac_copy(p->name, neighbor_name);
        p->device_type = type;

        *nbr_perm_io_stat_index = perm_io_stat_count - 1;
    }

    done : ;

    status_dprint_short_array(eprintf, stderr, perm_io_stat, perm_io_stat_count);
    ddprintf("perm_io_stat_count:  %d\n", perm_io_stat_count);

} /* add_perm_io_stat_index */
예제 #24
0
/* we have added a granted lock, or a lock request, or an owned lock.
 * all locks time out by themselves if they aren't explicitly updated
 * as part of the cloud protocol.  for the given lock, set its timeout
 * time, and schedule a timer interrupt when that time is reached.
 */
void set_lock_timer(lockable_resource_t *l)
{
    struct timeval now;
    /* don't know why we commented this out; probably a mistake */
    // if (!db[22].d) { return; }

    if (db[28].d) { ddprintf("set_lock_timer..\n"); }

    while (!checked_gettimeofday(&now));
    l->sec = now.tv_sec;
    l->usec = now.tv_usec;
    usec_add_msecs(&l->sec, &l->usec, RECV_TIMEOUT_USEC / 1000);

    reset_lock_timer();

    if (db[28].d) {
        ptime("\nset_lock_timer now", now);
        ptime("set_lock_timer interrupt", times[4]);
        ddprintf("\n");
    }

} /* set_lock_timer */
예제 #25
0
파일: pxe.c 프로젝트: emmericp/syslinux
/* Load the config file, return -1 if failed, or 0 */
static int pxe_open_config(struct com32_filedata *filedata)
{
    const char *cfgprefix = "pxelinux.cfg/";
    const char *default_str = "default";
    char *config_file;
    char *last;
    int tries = 8;

    chdir(path_prefix);
    if (DHCPMagic & 0x02) {
        /* We got a DHCP option, try it first */
	if (open_file(ConfigName, O_RDONLY, filedata) >= 0)
	    return 0;
    }

    /*
     * Have to guess config file name ...
     */
    config_file = stpcpy(ConfigName, cfgprefix);

    /* Try loading by UUID */
    if (sysappend_strings[SYSAPPEND_SYSUUID]) {
	strcpy(config_file, sysappend_strings[SYSAPPEND_SYSUUID]+8);
	if (open_file(ConfigName, O_RDONLY, filedata) >= 0)
            return 0;
    }

    /* Try loading by MAC address */
    strcpy(config_file, sysappend_strings[SYSAPPEND_BOOTIF]+7);
    if (open_file(ConfigName, O_RDONLY, filedata) >= 0)
        return 0;

    /* Nope, try hexadecimal IP prefixes... */
    sprintf(config_file, "%08X", ntohl(IPInfo.myip));
    last = &config_file[8];
    while (tries) {
        *last = '\0';        /* Zero-terminate string */
	if (open_file(ConfigName, O_RDONLY, filedata) >= 0)
            return 0;
        last--;           /* Drop one character */
        tries--;
    };

    /* Final attempt: "default" string */
    strcpy(config_file, default_str);
    if (open_file(ConfigName, O_RDONLY, filedata) >= 0)
        return 0;

    ddprintf("%-68s\n", "Unable to locate configuration file");
    kaboom();
}
예제 #26
0
파일: pxe.c 프로젝트: emmericp/syslinux
/*
 * Store standard filename prefix
 */
static void get_prefix(void)
{
    int len;
    char *p;
    char c;

    if (!(DHCPMagic & 0x04)) {
	/* No path prefix option, derive from boot file */

	strlcpy(path_prefix, boot_file, sizeof path_prefix);
	len = strlen(path_prefix);
	p = &path_prefix[len - 1];
	
	while (len--) {
	    c = *p--;
	    c |= 0x20;
	    
	    c = (c >= '0' && c <= '9') ||
		(c >= 'a' && c <= 'z') ||
		(c == '.' || c == '-');
	    if (!c)
		break;
	};
	
	if (len < 0)
	    p --;
	
	*(p + 2) = 0;                /* Zero-terminate after delimiter */
    }

    ddprintf("TFTP prefix: %s\n", path_prefix);

    if (url_type(path_prefix) == URL_SUFFIX) {
	/*
	 * Construct a ::-style TFTP path.
	 *
	 * We may have moved out of the root directory at the time
	 * this function is invoked, but to maintain compatibility
	 * with versions of Syslinux < 5.00, path_prefix must be
	 * relative to "::".
	 */
	p = strdup(path_prefix);
	if (!p)
	    return;

	snprintf(path_prefix, sizeof path_prefix, "::%s", p);
	free(p);
    }

    chdir(path_prefix);
}
예제 #27
0
/* figure out when in the future to send our next ping broadcast message.
 * we do this based on a uniform[PING_INTERVAL_MIN .. PING_INTERVAL_MAX]
 * probability distribution, where the high end of the range is shorter
 * than the stp timeout window.  so, we have a fighting chance to have
 * other cloud boxes hear something from us before they time us out and
 * assume we are dead.
 */
void set_next_scan_alarm(void)
{
    int msec;

    if (times[8].tv_sec != -1) {
        if (db[28].d) { ddprintf("already set; returning.\n"); }
        return;
    }

    while (!checked_gettimeofday(&times[8]));
    msec = discrete_unif(SCAN_INTERVAL_MAX - SCAN_INTERVAL_MIN);
    msec += PING_INTERVAL_MIN;

    if (db[7].d) {
        ddprintf("next time:  %d\n", msec);
    }

    usec_add_msecs(&times[8].tv_sec, &times[8].tv_usec, msec);

    block_timer_interrupts(SIG_BLOCK);
    set_next_alarm();
    block_timer_interrupts(SIG_UNBLOCK);
}
예제 #28
0
파일: driver.c 프로젝트: looncraz/haiku
/*
 * et6000FreeHook - close down the device
 */
static status_t et6000FreeHook(void* dev) {
ET6000DeviceInfo *di = (ET6000DeviceInfo *)dev;
ET6000SharedInfo *si = di->si;

    ddprintf(("SKD et6000FreeHook() begins...\n"));
    /* lock the driver */
    AQUIRE_BEN(pd->kernel);

    /* if opened multiple times, decrement the open count and exit */
    if (di->isOpen > 1)
        goto unlock_and_exit;

    /* Clear any pending interrupts and disable interrupts. */
    et6000aclReadInterruptClear(si->mmRegs);
    et6000aclWriteInterruptClear(si->mmRegs);
    et6000aclMasterInterruptDisable(si->mmRegs);

    /* Remove the interrupt handler */
    remove_io_interrupt_handler(di->pcii.u.h0.interrupt_line, et6000Interrupt, di);

    /* free framebuffer area */
    et6000UnmapDevice(di);

    /* clean up our shared area */
    delete_area(di->sharedArea);
    di->sharedArea = -1;
    di->si = NULL;

unlock_and_exit:
    /* mark the device available */
    di->isOpen--;
    /* unlock the driver */
    RELEASE_BEN(pd->kernel);
    ddprintf(("SKD et6000FreeHook() ends.\n"));
    /* all done */
    return B_OK;
}
예제 #29
0
파일: lineed.c 프로젝트: hlyytine/daydream
int fileattach(void)
{
	char olddir[1024];
	char fabuf[1024];
	FILE *falist;
	int cnt = 0;
	struct dirent *dent;
	DIR *dh;

	if (cleantemp() == -1) {
		DDPut(sd[tempcleanerrstr]);
		return 0;
	}
	recfiles(currnode->MULTI_TEMPORARY, 0);

	snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node);
	/* FIXME: check falist == NULL */
	falist = fopen(fabuf, "w");

	if ((dh = opendir(currnode->MULTI_TEMPORARY))) {
		getcwd(olddir, 1024);
		chdir(currnode->MULTI_TEMPORARY);
		while ((dent = readdir(dh))) {
			if (dent->d_name[0] == '.' && (dent->d_name[1] == '\0' || (dent->d_name[1] == '.' && dent->d_name[2] == '\0')))
				continue;
			if (!strcmp(".packtmp", dent->d_name))
				continue;

			deldir(".packtmp");
			ddprintf(sd[afqstr], dent->d_name);
			if (HotKey(HOT_YESNO) == 1) {
				fprintf(falist, "%s\n", dent->d_name);
				cnt++;
			} else {
				unlink(dent->d_name);
			}
			if (!checkcarrier())
				break;
		}
		chdir(olddir);
		closedir(dh);
	}
	fclose(falist);
	if (!cnt) {
		snprintf(fabuf, sizeof fabuf, "%s/attachs.%d", DDTMP, node);
		unlink(fabuf);
	}
	return 1;
}
예제 #30
0
/* block or unblock timer interrupts based on "todo" */
void block_timer_interrupts(int todo)
{   
    sigset_t blockum;
    int result;

    while (true) {
        if ((result = sigemptyset(&blockum)) == -1) { continue; }
        if ((result = sigaddset(&blockum, SIGALRM)) == -1) { continue; }
        if ((result = sigprocmask(todo, &blockum, NULL)) == -1) {
            ddprintf("block_timer_interrupts problem:  %s\n",
                    strerror(errno));
        }
        break;
    }
}