From: John Kohl Date: Thu, 18 Jan 1990 11:37:59 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: krb5-1.0-alpha2~1266 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e1efe3707f94b3f1ec5ecbb5da338e34ca68b119;p=krb5.git *** empty log message *** git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@116 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/lock_file.c b/src/lib/krb5/os/lock_file.c new file mode 100644 index 000000000..ce1862f24 --- /dev/null +++ b/src/lib/krb5/os/lock_file.c @@ -0,0 +1,52 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * libos: krb5_lock_file routine + */ + +#ifndef lint +static char rcsid_lock_file_c [] = +"$Id$"; +#endif lint + +#include + +#include +#include +#include + +#include +#include + +extern int errno; + +krb5_error_code +krb5_lock_file(filep, mode) +FILE *filep; +int mode; +{ + int flock_flag = -1; + + switch (mode & ~KRB5_LOCKMODE_DONTBLOCK) { + case KRB5_LOCKMODE_SHARED: + flock_flag = LOCK_SH; + case KRB5_LOCKMODE_EXCLUSIVE: + flock_flag = LOCK_EX; + case KRB5_LOCKMODE_UNLOCK: + flock_flag = LOCK_UN; + } + if (flock_flag == -1) + return(KRB5_LIBOS_BADLOCKFLAG); + if (mode & KRB5_LOCKMODE_DONTBLOCK) + flock_flag |= LOCK_NB; + + if (flock(fileno(filep), flock_flag) == -1) + return(errno); + return 0; +} diff --git a/src/lib/krb5/os/unlck_file.c b/src/lib/krb5/os/unlck_file.c new file mode 100644 index 000000000..eb581c264 --- /dev/null +++ b/src/lib/krb5/os/unlck_file.c @@ -0,0 +1,31 @@ +/* + * $Source$ + * $Author$ + * + * Copyright 1990 by the Massachusetts Institute of Technology. + * + * For copying and distribution information, please see the file + * . + * + * libos: krb5_lock_file routine + */ + +#ifndef lint +static char rcsid_unlock_file_c [] = +"$Id$"; +#endif lint + +#include + +#include +#include +#include + +#include + +krb5_error_code +krb5_unlock_file(filep) +FILE *filep; +{ + return krb5_lock_file(filep, KRB5_LOCKMODE_UNLOCK); +}