示例#1
0
文件: hid.c 项目: bagong/hidapi
int HID_API_EXPORT hid_init(void)
{
	const char *locale;

	/* Set the locale if it's not set. */
	locale = setlocale(LC_CTYPE, NULL);
	if (!locale)
		setlocale(LC_CTYPE, "");

	kernel_version = detect_kernel_version();

	return 0;
}
示例#2
0
文件: libdlm.c 项目: beekhof/dlm
static int open_control_device(void)
{
	struct stat st;
	int i, rv, minor, found = 0;

	if (control_fd > -1)
		goto out;

	rv = find_control_minor(&minor);
	if (rv < 0)
		return -1;

	/* wait for udev to create the device */

	for (i = 0; i < 10; i++) {
		if (stat(DLM_CONTROL_PATH, &st) == 0 &&
		    minor(st.st_rdev) == minor) {
			found = 1;
			break;
		}
		sleep(1);
		continue;
	}

	if (!found)
		return -1;

	control_fd = open(DLM_CONTROL_PATH, O_RDWR);
	if (control_fd == -1)
		return -1;

 out:
	fcntl(control_fd, F_SETFD, 1);

	if (!kernel_version_detected)
		detect_kernel_version();
	return 0;
}