KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > alfresco > filesys > smb > NTIOCtl


1 /*
2  * Copyright (C) 2005 Alfresco, Inc.
3  *
4  * Licensed under the Mozilla Public License version 1.1
5  * with a permitted attribution clause. You may obtain a
6  * copy of the License at
7  *
8  * http://www.alfresco.org/legal/license.txt
9  *
10  * Unless required by applicable law or agreed to in writing,
11  * software distributed under the License is distributed on an
12  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13  * either express or implied. See the License for the specific
14  * language governing permissions and limitations under the
15  * License.
16  */

17 package org.alfresco.filesys.smb;
18
19 /**
20  * NT IO Control Codes Class
21  */

22 public class NTIOCtl
23 {
24
25     // Device type codes
26

27     public static final int DeviceBeep = 0x0001;
28     public static final int DeviceCDRom = 0x0002;
29     public static final int DeviceCDRomFileSystem = 0x0003;
30     public static final int DeviceController = 0x0004;
31     public static final int DeviceDataLink = 0x0005;
32     public static final int DeviceDFS = 0x0006;
33     public static final int DeviceDisk = 0x0007;
34     public static final int DeviceDiskFileSystem = 0x0008;
35     public static final int DeviceFileSystem = 0x0009;
36     public static final int DeviceInportPort = 0x000A;
37     public static final int DeviceKeyboard = 0x000B;
38     public static final int DeviceMailSlot = 0x000C;
39     public static final int DeviceMidiIn = 0x000D;
40     public static final int DeviceMidiOut = 0x000E;
41     public static final int DeviceMouse = 0x000F;
42     public static final int DeviceMultiUNCProvider = 0x0010;
43     public static final int DeviceNamedPipe = 0x0011;
44     public static final int DeviceNetwork = 0x0012;
45     public static final int DeviceNetworkBrowser = 0x0013;
46     public static final int DeviceNetworkFileSystem = 0x0014;
47     public static final int DeviceNull = 0x0015;
48     public static final int DeviceParallelPort = 0x0016;
49     public static final int DevicePhysicalNetCard = 0x0017;
50     public static final int DevicePrinter = 0x0018;
51     public static final int DeviceScanner = 0x0019;
52     public static final int DeviceSerialMousePort = 0x001A;
53     public static final int DeviceSerialPort = 0x001B;
54     public static final int DeviceScreen = 0x001C;
55     public static final int DeviceSound = 0x001D;
56     public static final int DeviceStreams = 0x001E;
57     public static final int DeviceTape = 0x001F;
58     public static final int DeviceTapeFileSystem = 0x0020;
59     public static final int DeviceTransport = 0x0021;
60     public static final int DeviceUnknown = 0x0022;
61     public static final int DeviceVideo = 0x0023;
62     public static final int DeviceVirtualDisk = 0x0024;
63     public static final int DeviceWaveIn = 0x0025;
64     public static final int DeviceWaveOut = 0x0026;
65     public static final int Device8042Port = 0x0027;
66     public static final int DeviceNetworkRedirector = 0x0028;
67     public static final int DeviceBattery = 0x0029;
68     public static final int DeviceBusExtender = 0x002A;
69     public static final int DeviceModem = 0x002B;
70     public static final int DeviceVDM = 0x002C;
71     public static final int DeviceMassStorage = 0x002D;
72     public static final int DeviceSMB = 0x002E;
73     public static final int DeviceKS = 0x002F;
74     public static final int DeviceChanger = 0x0030;
75     public static final int DeviceSmartCard = 0x0031;
76     public static final int DeviceACPI = 0x0032;
77     public static final int DeviceDVD = 0x0033;
78     public static final int DeviceFullScreenVideo = 0x0034;
79     public static final int DeviceDFSFileSystem = 0x0035;
80     public static final int DeviceDFSVolume = 0x0036;
81   
82     // Method types for I/O and filesystem controls
83

84     public static final int MethodBuffered = 0;
85     public static final int MethodInDirect = 1;
86     public static final int MethodOutDirect = 2;
87     public static final int MethodNeither = 3;
88   
89     // Access check types
90

91     public static final int AccessAny = 0;
92     public static final int AccessRead = 0x0001;
93     public static final int AccessWrite = 0x0002;
94   
95     // Filesystem function codes
96

97     public static final int FsCtlRequestOplockLevel1 = 0;
98     public static final int FsCtlRequestOplockLevel2 = 1;
99     public static final int FsCtlRequestBatchOplock = 2;
100     public static final int FsCtlOplockBreakAck = 3;
101     public static final int FsCtlOpBatchAckClosePend = 4;
102     public static final int FsCtlOplockBreakNotify = 5;
103     public static final int FsCtlLockVolume = 6;
104     public static final int FsCtlUnlockVolume = 7;
105     public static final int FsCtlDismountVolume = 8;
106     public static final int FsCtlIsVolumeMounted = 10;
107     public static final int FsCtlIsPathnameValid = 11;
108     public static final int FsCtlMarkVolumeDirty = 12;
109     public static final int FsCtlQueryRetrievalPtrs = 14;
110     public static final int FsCtlGetCompression = 15;
111     public static final int FsCtlSetCompression = 16;
112     public static final int FsCtlMarkAsSystemHive = 19;
113     public static final int FsCtlOplockBreakAck2 = 20;
114     public static final int FsCtlInvalidateVolumes = 21;
115     public static final int FsCtlQueryFatBPB = 22;
116     public static final int FsCtlRequestFilterOplock = 23;
117     public static final int FsCtlFileSysGetStats = 24;
118     public static final int FsCtlGetNTFSVolumeData = 25;
119     public static final int FsCtlGetNTFSFileRecord = 26;
120     public static final int FsCtlGetVolumeBitmap = 27;
121     public static final int FsCtlGetRetrievalPtrs = 28;
122     public static final int FsCtlMoveFile = 29;
123     public static final int FsCtlIsVolumeDirty = 30;
124     public static final int FsCtlGetHFSInfo = 31;
125     public static final int FsCtlAllowExtenDasdIO = 32;
126     public static final int FsCtlReadPropertyData = 33;
127     public static final int FsCtlWritePropertyData = 34;
128     public static final int FsCtlFindFilesBySID = 35;
129     public static final int FsCtlDumpPropertyData = 37;
130     public static final int FsCtlSetObjectId = 38;
131     public static final int FsCtlGetObjectId = 39;
132     public static final int FsCtlDeleteObjectId = 40;
133     public static final int FsCtlSetReparsePoint = 41;
134     public static final int FsCtlGetReparsePoint = 42;
135     public static final int FsCtlDeleteReparsePoint = 43;
136     public static final int FsCtlEnumUsnData = 44;
137     public static final int FsCtlSecurityIdCheck = 45;
138     public static final int FsCtlReadUsnJournal = 46;
139     public static final int FsCtlSetObjectIdExtended = 47;
140     public static final int FsCtlCreateOrGetObjectId = 48;
141     public static final int FsCtlSetSparse = 49;
142     public static final int FsCtlSetZeroData = 50;
143     public static final int FsCtlQueryAllocRanges = 51;
144     public static final int FsCtlEnableUpgrade = 52;
145     public static final int FsCtlSetEncryption = 53;
146     public static final int FsCtlEncryptionFsCtlIO = 54;
147     public static final int FsCtlWriteRawEncrypted = 55;
148     public static final int FsCtlReadRawEncrypted = 56;
149     public static final int FsCtlCreateUsnJournal = 57;
150     public static final int FsCtlReadFileUsnData = 58;
151     public static final int FsCtlWriteUsnCloseRecord = 59;
152     public static final int FsCtlExtendVolume = 60;
153
154     // Base value for custom control codes
155

156     public static final int FsCtlCustom = 0x800;
157     
158     /**
159      * Extract the device type from an I/O control code
160      *
161      * @param ioctl int
162      * @return int
163      */

164     public final static int getDeviceType(int ioctl)
165     {
166         return (ioctl >> 16) & 0x0000FFFF;
167     }
168
169     /**
170      * Extract the access type from an I/O control code
171      *
172      * @param ioctl int
173      * @return int
174      */

175     public final static int getAccessType(int ioctl)
176     {
177         return (ioctl >> 14) & 0x00000003;
178     }
179
180     /**
181      * Extract the function code from the I/O control code
182      *
183      * @param ioctl int
184      * @return int
185      */

186     public final static int getFunctionCode(int ioctl)
187     {
188         return (ioctl >> 2) & 0x00000FFF;
189     }
190
191     /**
192      * Extract the method code from the I/O control code
193      *
194      * @param ioctl int
195      * @return int
196      */

197     public final static int getMethod(int ioctl)
198     {
199         return ioctl & 0x00000003;
200     }
201
202     /**
203      * Make a control code
204      *
205      * @param devType int
206      * @param func int
207      * @param method int
208      * @param access int
209      * @return int
210      */

211     public final static int makeControlCode(int devType, int func, int method, int access)
212     {
213         return (devType << 16) + (access << 14) + (func << 2) + (method);
214     }
215
216     /**
217      * Return an I/O control code as a string
218      *
219      * @param ioctl int
220      * @return String
221      */

222     public final static String JavaDoc asString(int ioctl)
223     {
224         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
225
226         str.append("[Func:");
227         str.append(getFunctionCode(ioctl));
228
229         str.append(",DevType:");
230         str.append(getDeviceType(ioctl));
231
232         str.append(",Access:");
233         str.append(getAccessType(ioctl));
234
235         str.append(",Method:");
236         str.append(getMethod(ioctl));
237
238         str.append("]");
239
240         return str.toString();
241     }
242 }
243
Popular Tags