]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/dossrv/lock.c
9bootfat: rename open() to fileinit and make it static as its really a internal funct...
[plan9front.git] / sys / src / cmd / dossrv / lock.c
1 #include <u.h>
2 #include <libc.h>
3 #include "iotrack.h"
4 #include "dat.h"
5 #include "fns.h"
6
7 void
8 mlock(MLock *l)
9 {
10
11         if(l->key != 0 && l->key != 1)
12                 panic("uninitialized lock");
13         if (l->key)
14                 panic("lock");
15         l->key = 1;
16 }
17
18 void
19 unmlock(MLock *l)
20 {
21
22         if(l->key != 0 && l->key != 1)
23                 panic("uninitialized unlock");
24         if (!l->key)
25                 panic("unlock");
26         l->key = 0;
27 }
28
29 int
30 canmlock(MLock *l)
31 {
32         if(l->key != 0 && l->key != 1)
33                 panic("uninitialized canlock");
34         if (l->key)
35                 return 0;
36         l->key = 1;
37         return 1;
38 }