1 17 package org.alfresco.filesys.smb.server; 18 19 import org.alfresco.filesys.server.filesys.DiskInfo; 20 import org.alfresco.filesys.server.filesys.SrvDiskInfo; 21 import org.alfresco.filesys.server.filesys.VolumeInfo; 22 import org.alfresco.filesys.smb.NTTime; 23 import org.alfresco.filesys.util.DataBuffer; 24 import org.alfresco.filesys.util.DataPacker; 25 26 29 class DiskInfoPacker 30 { 31 32 34 public static final int InfoStandard = 1; 35 public static final int InfoVolume = 2; 36 public static final int InfoFsVolume = 0x102; 37 public static final int InfoFsSize = 0x103; 38 public static final int InfoFsDevice = 0x104; 39 public static final int InfoFsAttribute = 0x105; 40 public static final int InfoCifsUnix = 0x200; 41 public static final int InfoMacFsInfo = 0x301; 42 public static final int InfoFullFsSize = 0x3EF; 43 44 46 public static final int MacAccessControl = 0x0010; 47 public static final int MacGetSetComments = 0x0020; 48 public static final int MacDesktopDbCalls = 0x0040; 49 public static final int MacUniqueIds = 0x0080; 50 public static final int MacNoStreamsOrMacSupport = 0x0100; 51 52 55 public DiskInfoPacker() 56 { 57 super(); 58 } 59 60 66 public final static void packStandardInfo(DiskInfo info, DataBuffer buf) 67 { 68 69 76 78 buf.putZeros(4); 79 81 83 buf.putInt(info.getBlocksPerAllocationUnit()); 84 buf.putInt((int) info.getTotalUnits()); 85 buf.putInt((int) info.getFreeUnits()); 86 buf.putShort(info.getBlockSize()); 87 } 88 89 96 public final static void packVolumeInfo(VolumeInfo info, DataBuffer buf, boolean uni) 97 { 98 99 104 106 buf.putInt(info.getSerialNumber()); 107 108 110 buf.putByte(info.getVolumeLabel().length()); 111 buf.putString(info.getVolumeLabel(), uni); 112 } 113 114 120 public final static void packFsSizeInformation(SrvDiskInfo info, DataBuffer buf) 121 { 122 123 129 buf.putLong(info.getTotalUnits()); 130 buf.putLong(info.getFreeUnits()); 131 buf.putInt(info.getBlocksPerAllocationUnit()); 132 buf.putInt(info.getBlockSize()); 133 } 134 135 142 public final static void packFsVolumeInformation(VolumeInfo info, DataBuffer buf, boolean uni) 143 { 144 145 152 if (info.hasCreationDateTime()) 153 buf.putLong(NTTime.toNTTime(info.getCreationDateTime())); 154 else 155 buf.putZeros(8); 156 157 if (info.hasSerialNumber()) 158 buf.putInt(info.getSerialNumber()); 159 else 160 buf.putZeros(4); 161 162 int len = info.getVolumeLabel().length(); 163 if (uni) 164 len *= 2; 165 buf.putInt(len); 166 167 buf.putZeros(2); buf.putString(info.getVolumeLabel(), uni, false); 169 } 170 171 178 public final static void packFsDevice(int typ, int devChar, DataBuffer buf) 179 { 180 181 185 buf.putInt(typ); 186 buf.putInt(devChar); 187 } 188 189 198 public final static void packFsAttribute(int attr, int maxName, String fsType, boolean uni, DataBuffer buf) 199 { 200 201 207 buf.putInt(attr); 208 buf.putInt(maxName); 209 210 if (uni) 211 buf.putInt(fsType.length() * 2); 212 else 213 buf.putInt(fsType.length()); 214 buf.putString(fsType, uni, false); 215 } 216 217 225 public final static void packMacFsInformation(DiskInfo diskInfo, VolumeInfo volInfo, boolean ntfs, DataBuffer buf) 226 { 227 228 242 244 if (volInfo.hasCreationDateTime()) 245 { 246 long ntTime = NTTime.toNTTime(volInfo.getCreationDateTime()); 247 buf.putLong(ntTime); 248 buf.putLong(ntTime); 249 buf.putLong(ntTime); 250 } 251 else 252 buf.putZeros(24); 253 254 256 buf.putInt((int) diskInfo.getTotalUnits()); 257 buf.putInt(diskInfo.getBlockSize() * diskInfo.getBlocksPerAllocationUnit()); 258 buf.putInt((int) diskInfo.getFreeUnits()); 259 260 262 buf.putZeros(32); 263 264 266 buf.putInt(0); 267 buf.putInt(0); 268 buf.putInt(0); 269 buf.putInt(0); 270 271 273 DataPacker.putIntelInt(ntfs ? 0 : MacNoStreamsOrMacSupport, buf.getBuffer(), buf.getPosition()); 274 buf.setPosition(buf.getPosition() + 4); 275 } 276 277 284 public final static void packFullFsSizeInformation(long userLimit, SrvDiskInfo info, DataBuffer buf) 285 { 286 287 294 buf.putLong(info.getTotalUnits()); 295 buf.putLong(userLimit); 296 buf.putLong(info.getFreeUnits()); 297 buf.putInt(info.getBlocksPerAllocationUnit()); 298 buf.putInt(info.getBlockSize()); 299 } 300 } | Popular Tags |