~ubuntu-branches/ubuntu/edgy/rxtx/edgy

« back to all changes in this revision

Viewing changes to src/lfd/LockFileServer.rfc

  • Committer: Bazaar Package Importer
  • Author(s): Mario Joussen
  • Date: 2002-03-06 00:50:09 UTC
  • Revision ID: james.westby@ubuntu.com-20020306005009-8myjehevn1eu3u78
Tags: upstream-1.5.9pre5
ImportĀ upstreamĀ versionĀ 1.5.9pre5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
                          LOCK FILE PROTOCOL (LFP)
 
2
 
 
3
 
 
4
Status of this Memo
 
5
 
 
6
   This memo is a proposed specification for the Lock File Protocol (LPF).
 
7
   Distribution of this memo is currently limited.
 
8
 
 
9
   The following commands are currently in this edition of this specification.
 
10
 
 
11
      LOCK (lock a resource), UNLOCK (unlock a resource), QUIT (disconnect)
 
12
 
 
13
 
 
14
1.  INTRODUCTION
 
15
 
 
16
    The objectives of LPF are 1) to make administration of machines with a
 
17
    large number of users easier 2) to encourage a common mechanism for
 
18
    applications to share resources 3) to provide a platform neutral
 
19
    interface for applications.
 
20
 
 
21
    This specification tries to outline the minimal required features for
 
22
    a LPF.
 
23
 
 
24
2.  OVERVIEW
 
25
 
 
26
    Lock files can be located in as many as 10 different directories depending
 
27
    on the OS.  Writing applications that handle all of the lock directories
 
28
    is redundant and error prone.
 
29
 
 
30
    By enabling three commands much of the redundant work can be eliminated and
 
31
    a common locking scheme can be used.  The end result is a consistant easy
 
32
    to use interface.
 
33
 
 
34
2.1.  HISTORY
 
35
 
 
36
    Lock files have been used for a long time.  For more information on
 
37
    lock files see:
 
38
 
 
39
         The File System Hierarchy Standard
 
40
         http://www.pathname.com/fhs/
 
41
         UUCP Lock Files
 
42
         http://docs.freebsd.org/info/uucp/uucp.info.UUCP_Lock_Files.html
 
43
         FSSTND
 
44
         ftp://tsx-11.mit.edu/pub/linux/docs/linux-standards/fsstnd/
 
45
         Proposed Changes to the File System Hierarchy Standard
 
46
         ftp://scicom.alphacdc.com/pub/linux/devlock-0.X.tgz
 
47
         "UNIX Network Programming", W. Richard Stevens,
 
48
         Prentice-Hall, 1990, pages 96-101.
 
49
 
 
50
2.2  TERMINOLOGY
 
51
 
 
52
   lock file
 
53
   lock directory
 
54
   uucp lock
 
55
   fhs lock
 
56
 
 
57
2.3  THE LFP MODEL
 
58
 
 
59
        lock
 
60
        directory<----->Server<-----Client<---->User
 
61
 
 
62
3.  LOCKFILE FUNCTIONS
 
63
 
 
64
4.  LFP FUNCTIONS
 
65
4.1  LFP COMMANDS
 
66
 
 
67
   4.1.1   ACCEESS CONTROL COMMANDS
 
68
 
 
69
        QUIT  The session is ended.
 
70
 
 
71
   4.1.2   LOCK FILE CONTROL COMMANDS
 
72
        
 
73
        LOCK If the device that is trying to be locked and the pid of the
 
74
             requesting application are passed, an attempt will be made to
 
75
             lock the device.
 
76
 
 
77
        UNLOCK If the pid of the application requesting to unlock a device
 
78
             is passed an attempt will be made to unlock the device.
 
79
 
 
80
Lock File Protocol                                              January 2001
 
81
 
 
82
4.2  LFP REPLIES
 
83
 
 
84
        The following replies exist and try to follow the same format as FTP
 
85
        reply commands (rfc 959)
 
86
 
 
87
        200 Command okay.
 
88
        202 Command not implemented
 
89
        220 hostname Lock File Server (Version rxtx-1.5-9) ready
 
90
        221 Thank you for using the Lock File service on hostname
 
91
        450 : File busy
 
92
        500 'command': command not understood
 
93
        550 : Permission denied.
 
94
 
 
95
5.  DECLARATIVE SPECIFICATIONS
 
96
      5.1 Minimum IMPLEMENTATION
 
97
 
 
98
         The following commands must be in a minimum implementation
 
99
         QUIT, LOCK, UNLOCK.
 
100
 
 
101
      5.2  CONNECTIONS
 
102
 
 
103
          Currently on connections assisted by inetd are supported.
 
104
          Though not official, LFP currently listens on port 50001.
 
105
          Only connections from localhost should be allowed.
 
106
 
 
107
      5.3 COMMANDS
 
108
 
 
109
          5.3.1  LFP COMMANDS
 
110
 
 
111
             The following are the LFP COMMANDS
 
112
 
 
113
             QUIT <CRLF>
 
114
             LOCK <SP> <device> <sp> <pid> <CRLF>
 
115
             UNLOCK <SP> <device> <sp> <pid> <CRLF>
 
116
 
 
117
          5.3.2  LFP COMMAND ARGUMENTS
 
118
 
 
119
             <device> ::= <string>
 
120
             <pid>    ::= any decimal integer
 
121
 
 
122
      5.4.  SEQUENCING OF COMMANDS AND REPLIES
 
123
                
 
124
                Connection Establisment
 
125
                LOCK
 
126
                UNLOCK
 
127
                QUIT
 
128
 
 
129
6.  STATE DIAGRAMS
 
130
 
 
131
 
 
132
   [ from rfc 959 ]
 
133
 
 
134
   Here we present state diagrams for a very simple minded LFP
 
135
   implementation.  Only the first digit of the reply codes is used.
 
136
   There is one state diagram for each group of LFP commands or command
 
137
   sequences.
 
138
 
 
139
   The command groupings were determined by constructing a model for
 
140
   each command then collecting together the commands with structurally
 
141
   identical models.
 
142
 
 
143
   For each command or command sequence there are three possible
 
144
   outcomes: success (S), failure (F), and error (E).  In the state
 
145
   diagrams below we use the symbol B for "begin", and the symbol W for
 
146
   "wait for reply".
 
147
 
 
148
Lock File Protocol                                              January 2001
 
149
 
 
150
   We present the diagram that represents the largest group of LFP
 
151
   commands:
 
152
 
 
153
                               1,3    +---+
 
154
                          ----------->| E |
 
155
                         |            +---+
 
156
                         |
 
157
      +---+    cmd    +---+    2      +---+
 
158
      | B |---------->| W |---------->| S |
 
159
      +---+           +---+           +---+
 
160
                         |
 
161
                         |     4,5    +---+
 
162
                          ----------->| F |
 
163
                                      +---+
 
164
 
 
165
      This diagram models the commands:
 
166
        
 
167
         QUIT, LOCK, UNLOCK.
 
168
 
 
169
 
 
170
7.  TYPICAL LFP SCENARIO
 
171
 
 
172
      $ telnet 127.0.0.1 50001
 
173
      Trying 127.0.0.1...
 
174
      Connected to 127.0.0.1.
 
175
      Escape character is '^]'.
 
176
      lock /dev/ttyS1 1234
 
177
      200 Command okay.
 
178
      unlock /dev/ttyS1 1234         
 
179
      200 Command okay.
 
180
      quit
 
181
      221 Thank you for using the Lock File Service on servertrent.korpivaara.org.
 
182
      Connection closed by foreign host.
 
183
      $
 
184
 
 
185
 
 
186
 
 
187