⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lock.c

📁 linux下的ppp协议簇开源代码; 可以进行linux内核级的pppoe拨号
💻 C
字号:
/* * $Id: lock.c,v 1.1 2004/11/14 07:26:26 paulus Exp $ * * Copyright (C) 1997 Lars Fenneberg * * See the file COPYRIGHT for the respective terms and conditions. * If the file is missing contact me at lf@elemental.net * and I'll send you a copy. * */#include "includes.h"#include <unistd.h>#include <fcntl.h>int do_lock_exclusive(int fd){	struct flock fl;	int res;	memset((void *)&fl, 0, sizeof(fl));	fl.l_type = F_WRLCK;	fl.l_whence = fl.l_start = 0;	fl.l_len = 0; /* 0 means "to end of file" */	res = fcntl(fd, F_SETLK, &fl);	if ((res == -1) && (errno == EAGAIN))		errno = EWOULDBLOCK;	return res;}int do_unlock(int fd){	struct flock fl;	memset((void *)&fl, 0, sizeof(fl));	fl.l_type = F_UNLCK;	fl.l_whence = fl.l_start = 0;	fl.l_len = 0; /* 0 means "to end of file" */	return fcntl(fd, F_SETLK, &fl);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -